1*8e33eff8Schristos #ifndef JEMALLOC_INTERNAL_BASE_STRUCTS_H 2*8e33eff8Schristos #define JEMALLOC_INTERNAL_BASE_STRUCTS_H 3*8e33eff8Schristos 4*8e33eff8Schristos #include "jemalloc/internal/jemalloc_internal_types.h" 5*8e33eff8Schristos #include "jemalloc/internal/mutex.h" 6*8e33eff8Schristos #include "jemalloc/internal/size_classes.h" 7*8e33eff8Schristos 8*8e33eff8Schristos /* Embedded at the beginning of every block of base-managed virtual memory. */ 9*8e33eff8Schristos struct base_block_s { 10*8e33eff8Schristos /* Total size of block's virtual memory mapping. */ 11*8e33eff8Schristos size_t size; 12*8e33eff8Schristos 13*8e33eff8Schristos /* Next block in list of base's blocks. */ 14*8e33eff8Schristos base_block_t *next; 15*8e33eff8Schristos 16*8e33eff8Schristos /* Tracks unused trailing space. */ 17*8e33eff8Schristos extent_t extent; 18*8e33eff8Schristos }; 19*8e33eff8Schristos 20*8e33eff8Schristos struct base_s { 21*8e33eff8Schristos /* Associated arena's index within the arenas array. */ 22*8e33eff8Schristos unsigned ind; 23*8e33eff8Schristos 24*8e33eff8Schristos /* 25*8e33eff8Schristos * User-configurable extent hook functions. Points to an 26*8e33eff8Schristos * extent_hooks_t. 27*8e33eff8Schristos */ 28*8e33eff8Schristos atomic_p_t extent_hooks; 29*8e33eff8Schristos 30*8e33eff8Schristos /* Protects base_alloc() and base_stats_get() operations. */ 31*8e33eff8Schristos malloc_mutex_t mtx; 32*8e33eff8Schristos 33*8e33eff8Schristos /* Using THP when true (metadata_thp auto mode). */ 34*8e33eff8Schristos bool auto_thp_switched; 35*8e33eff8Schristos /* 36*8e33eff8Schristos * Most recent size class in the series of increasingly large base 37*8e33eff8Schristos * extents. Logarithmic spacing between subsequent allocations ensures 38*8e33eff8Schristos * that the total number of distinct mappings remains small. 39*8e33eff8Schristos */ 40*8e33eff8Schristos pszind_t pind_last; 41*8e33eff8Schristos 42*8e33eff8Schristos /* Serial number generation state. */ 43*8e33eff8Schristos size_t extent_sn_next; 44*8e33eff8Schristos 45*8e33eff8Schristos /* Chain of all blocks associated with base. */ 46*8e33eff8Schristos base_block_t *blocks; 47*8e33eff8Schristos 48*8e33eff8Schristos /* Heap of extents that track unused trailing space within blocks. */ 49*8e33eff8Schristos extent_heap_t avail[NSIZES]; 50*8e33eff8Schristos 51*8e33eff8Schristos /* Stats, only maintained if config_stats. */ 52*8e33eff8Schristos size_t allocated; 53*8e33eff8Schristos size_t resident; 54*8e33eff8Schristos size_t mapped; 55*8e33eff8Schristos /* Number of THP regions touched. */ 56*8e33eff8Schristos size_t n_thp; 57*8e33eff8Schristos }; 58*8e33eff8Schristos 59*8e33eff8Schristos #endif /* JEMALLOC_INTERNAL_BASE_STRUCTS_H */ 60