2017-01-11 10:06:31 +08:00
|
|
|
#ifndef JEMALLOC_INTERNAL_BASE_STRUCTS_H
|
|
|
|
#define JEMALLOC_INTERNAL_BASE_STRUCTS_H
|
|
|
|
|
2019-09-21 07:18:41 +08:00
|
|
|
#include "jemalloc/internal/extent.h"
|
2017-04-20 06:09:01 +08:00
|
|
|
#include "jemalloc/internal/jemalloc_internal_types.h"
|
2017-05-24 03:28:19 +08:00
|
|
|
#include "jemalloc/internal/mutex.h"
|
2017-12-15 04:46:39 +08:00
|
|
|
#include "jemalloc/internal/sc.h"
|
2017-04-20 06:09:01 +08:00
|
|
|
|
2017-01-11 10:06:31 +08:00
|
|
|
/* Embedded at the beginning of every block of base-managed virtual memory. */
|
|
|
|
struct base_block_s {
|
|
|
|
/* Total size of block's virtual memory mapping. */
|
|
|
|
size_t size;
|
|
|
|
|
|
|
|
/* Next block in list of base's blocks. */
|
|
|
|
base_block_t *next;
|
|
|
|
|
|
|
|
/* Tracks unused trailing space. */
|
|
|
|
extent_t extent;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct base_s {
|
|
|
|
/* Associated arena's index within the arenas array. */
|
|
|
|
unsigned ind;
|
|
|
|
|
2017-04-05 08:32:21 +08:00
|
|
|
/*
|
|
|
|
* User-configurable extent hook functions. Points to an
|
|
|
|
* extent_hooks_t.
|
|
|
|
*/
|
2017-04-17 09:39:14 +08:00
|
|
|
atomic_p_t extent_hooks;
|
2017-01-11 10:06:31 +08:00
|
|
|
|
|
|
|
/* Protects base_alloc() and base_stats_get() operations. */
|
|
|
|
malloc_mutex_t mtx;
|
|
|
|
|
2017-11-08 11:40:38 +08:00
|
|
|
/* Using THP when true (metadata_thp auto mode). */
|
|
|
|
bool auto_thp_switched;
|
2017-04-17 09:39:14 +08:00
|
|
|
/*
|
|
|
|
* Most recent size class in the series of increasingly large base
|
|
|
|
* extents. Logarithmic spacing between subsequent allocations ensures
|
|
|
|
* that the total number of distinct mappings remains small.
|
|
|
|
*/
|
|
|
|
pszind_t pind_last;
|
|
|
|
|
2017-01-11 10:06:31 +08:00
|
|
|
/* Serial number generation state. */
|
|
|
|
size_t extent_sn_next;
|
|
|
|
|
|
|
|
/* Chain of all blocks associated with base. */
|
|
|
|
base_block_t *blocks;
|
|
|
|
|
|
|
|
/* Heap of extents that track unused trailing space within blocks. */
|
2017-12-15 04:46:39 +08:00
|
|
|
extent_heap_t avail[SC_NSIZES];
|
2017-01-11 10:06:31 +08:00
|
|
|
|
|
|
|
/* Stats, only maintained if config_stats. */
|
|
|
|
size_t allocated;
|
|
|
|
size_t resident;
|
|
|
|
size_t mapped;
|
2017-08-26 04:24:49 +08:00
|
|
|
/* Number of THP regions touched. */
|
|
|
|
size_t n_thp;
|
2017-01-11 10:06:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* JEMALLOC_INTERNAL_BASE_STRUCTS_H */
|