1 #ifndef JEMALLOC_INTERNAL_EDATA_CACHE_H 2 #define JEMALLOC_INTERNAL_EDATA_CACHE_H 3 4 #include "jemalloc/internal/base.h" 5 6 /* For tests only. */ 7 #define EDATA_CACHE_FAST_FILL 4 8 9 /* 10 * A cache of edata_t structures allocated via base_alloc_edata (as opposed to 11 * the underlying extents they describe). The contents of returned edata_t 12 * objects are garbage and cannot be relied upon. 13 */ 14 15 typedef struct edata_cache_s edata_cache_t; 16 struct edata_cache_s { 17 edata_avail_t avail; 18 atomic_zu_t count; 19 malloc_mutex_t mtx; 20 base_t *base; 21 }; 22 23 bool edata_cache_init(edata_cache_t *edata_cache, base_t *base); 24 edata_t *edata_cache_get(tsdn_t *tsdn, edata_cache_t *edata_cache); 25 void edata_cache_put(tsdn_t *tsdn, edata_cache_t *edata_cache, edata_t *edata); 26 27 void edata_cache_prefork(tsdn_t *tsdn, edata_cache_t *edata_cache); 28 void edata_cache_postfork_parent(tsdn_t *tsdn, edata_cache_t *edata_cache); 29 void edata_cache_postfork_child(tsdn_t *tsdn, edata_cache_t *edata_cache); 30 31 /* 32 * An edata_cache_small is like an edata_cache, but it relies on external 33 * synchronization and avoids first-fit strategies. 34 */ 35 36 typedef struct edata_cache_fast_s edata_cache_fast_t; 37 struct edata_cache_fast_s { 38 edata_list_inactive_t list; 39 edata_cache_t *fallback; 40 bool disabled; 41 }; 42 43 void edata_cache_fast_init(edata_cache_fast_t *ecs, edata_cache_t *fallback); 44 edata_t *edata_cache_fast_get(tsdn_t *tsdn, edata_cache_fast_t *ecs); 45 void edata_cache_fast_put(tsdn_t *tsdn, edata_cache_fast_t *ecs, 46 edata_t *edata); 47 void edata_cache_fast_disable(tsdn_t *tsdn, edata_cache_fast_t *ecs); 48 49 #endif /* JEMALLOC_INTERNAL_EDATA_CACHE_H */ 50