1#ifndef JEMALLOC_INTERNAL_ECACHE_H
2#define JEMALLOC_INTERNAL_ECACHE_H
3
4#include "jemalloc/internal/eset.h"
5#include "jemalloc/internal/san.h"
6#include "jemalloc/internal/mutex.h"
7
8typedef struct ecache_s ecache_t;
9struct ecache_s {
10 malloc_mutex_t mtx;
11 eset_t eset;
12 eset_t guarded_eset;
13 /* All stored extents must be in the same state. */
14 extent_state_t state;
15 /* The index of the ehooks the ecache is associated with. */
16 unsigned ind;
17 /*
18 * If true, delay coalescing until eviction; otherwise coalesce during
19 * deallocation.
20 */
21 bool delay_coalesce;
22};
23
24static inline size_t
25ecache_npages_get(ecache_t *ecache) {
26 return eset_npages_get(&ecache->eset) +
27 eset_npages_get(&ecache->guarded_eset);
28}
29
30/* Get the number of extents in the given page size index. */
31static inline size_t
32ecache_nextents_get(ecache_t *ecache, pszind_t ind) {
33 return eset_nextents_get(&ecache->eset, ind) +
34 eset_nextents_get(&ecache->guarded_eset, ind);
35}
36
37/* Get the sum total bytes of the extents in the given page size index. */
38static inline size_t
39ecache_nbytes_get(ecache_t *ecache, pszind_t ind) {
40 return eset_nbytes_get(&ecache->eset, ind) +
41 eset_nbytes_get(&ecache->guarded_eset, ind);
42}
43
44static inline unsigned
45ecache_ind_get(ecache_t *ecache) {
46 return ecache->ind;
47}
48
49bool ecache_init(tsdn_t *tsdn, ecache_t *ecache, extent_state_t state,
50 unsigned ind, bool delay_coalesce);
51void ecache_prefork(tsdn_t *tsdn, ecache_t *ecache);
52void ecache_postfork_parent(tsdn_t *tsdn, ecache_t *ecache);
53void ecache_postfork_child(tsdn_t *tsdn, ecache_t *ecache);
54
55#endif /* JEMALLOC_INTERNAL_ECACHE_H */
56