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