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