2019-12-13 08:25:24 +08:00
|
|
|
#ifndef JEMALLOC_INTERNAL_ECACHE_H
|
|
|
|
#define JEMALLOC_INTERNAL_ECACHE_H
|
|
|
|
|
|
|
|
#include "jemalloc/internal/eset.h"
|
2021-10-23 08:40:42 +08:00
|
|
|
#include "jemalloc/internal/san.h"
|
2019-12-13 08:25:24 +08:00
|
|
|
#include "jemalloc/internal/mutex.h"
|
|
|
|
|
|
|
|
typedef struct ecache_s ecache_t;
|
|
|
|
struct ecache_s {
|
|
|
|
malloc_mutex_t mtx;
|
|
|
|
eset_t eset;
|
2021-04-27 05:22:25 +08:00
|
|
|
eset_t guarded_eset;
|
2019-12-13 08:44:49 +08:00
|
|
|
/* All stored extents must be in the same state. */
|
|
|
|
extent_state_t state;
|
2019-12-14 03:33:03 +08:00
|
|
|
/* The index of the ehooks the ecache is associated with. */
|
|
|
|
unsigned ind;
|
2019-12-13 08:33:19 +08:00
|
|
|
/*
|
|
|
|
* If true, delay coalescing until eviction; otherwise coalesce during
|
|
|
|
* deallocation.
|
|
|
|
*/
|
|
|
|
bool delay_coalesce;
|
2019-12-13 08:25:24 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline size_t
|
|
|
|
ecache_npages_get(ecache_t *ecache) {
|
2021-04-27 05:22:25 +08:00
|
|
|
return eset_npages_get(&ecache->eset) +
|
|
|
|
eset_npages_get(&ecache->guarded_eset);
|
2019-12-13 08:25:24 +08:00
|
|
|
}
|
2021-04-27 05:22:25 +08:00
|
|
|
|
2019-12-13 08:25:24 +08:00
|
|
|
/* Get the number of extents in the given page size index. */
|
|
|
|
static inline size_t
|
|
|
|
ecache_nextents_get(ecache_t *ecache, pszind_t ind) {
|
2021-04-27 05:22:25 +08:00
|
|
|
return eset_nextents_get(&ecache->eset, ind) +
|
|
|
|
eset_nextents_get(&ecache->guarded_eset, ind);
|
2019-12-13 08:25:24 +08:00
|
|
|
}
|
2021-04-27 05:22:25 +08:00
|
|
|
|
2019-12-13 08:25:24 +08:00
|
|
|
/* Get the sum total bytes of the extents in the given page size index. */
|
|
|
|
static inline size_t
|
|
|
|
ecache_nbytes_get(ecache_t *ecache, pszind_t ind) {
|
2021-04-27 05:22:25 +08:00
|
|
|
return eset_nbytes_get(&ecache->eset, ind) +
|
|
|
|
eset_nbytes_get(&ecache->guarded_eset, ind);
|
2019-12-13 08:25:24 +08:00
|
|
|
}
|
|
|
|
|
2019-12-14 03:33:03 +08:00
|
|
|
static inline unsigned
|
|
|
|
ecache_ind_get(ecache_t *ecache) {
|
|
|
|
return ecache->ind;
|
|
|
|
}
|
|
|
|
|
2019-12-13 08:25:24 +08:00
|
|
|
bool ecache_init(tsdn_t *tsdn, ecache_t *ecache, extent_state_t state,
|
2019-12-14 03:33:03 +08:00
|
|
|
unsigned ind, bool delay_coalesce);
|
2019-12-13 08:25:24 +08:00
|
|
|
void ecache_prefork(tsdn_t *tsdn, ecache_t *ecache);
|
|
|
|
void ecache_postfork_parent(tsdn_t *tsdn, ecache_t *ecache);
|
|
|
|
void ecache_postfork_child(tsdn_t *tsdn, ecache_t *ecache);
|
|
|
|
|
|
|
|
#endif /* JEMALLOC_INTERNAL_ECACHE_H */
|