2017-01-11 10:06:31 +08:00
|
|
|
#ifndef JEMALLOC_INTERNAL_BASE_STRUCTS_H
|
|
|
|
#define JEMALLOC_INTERNAL_BASE_STRUCTS_H
|
|
|
|
|
2019-12-03 06:19:22 +08:00
|
|
|
#include "jemalloc/internal/ehooks.h"
|
2019-12-10 02:41:25 +08:00
|
|
|
#include "jemalloc/internal/edata.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. */
|
2019-11-19 06:43:48 +08:00
|
|
|
size_t size;
|
2017-01-11 10:06:31 +08:00
|
|
|
|
|
|
|
/* Next block in list of base's blocks. */
|
2019-11-19 06:43:48 +08:00
|
|
|
base_block_t *next;
|
2017-01-11 10:06:31 +08:00
|
|
|
|
|
|
|
/* Tracks unused trailing space. */
|
2019-12-10 06:36:45 +08:00
|
|
|
edata_t edata;
|
2017-01-11 10:06:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct base_s {
|
2017-04-05 08:32:21 +08:00
|
|
|
/*
|
2019-12-03 06:19:22 +08:00
|
|
|
* User-configurable extent hook functions.
|
2017-04-05 08:32:21 +08:00
|
|
|
*/
|
2019-12-03 06:19:22 +08:00
|
|
|
ehooks_t ehooks;
|
2017-01-11 10:06:31 +08:00
|
|
|
|
|
|
|
/* Protects base_alloc() and base_stats_get() operations. */
|
2019-11-19 06:43:48 +08:00
|
|
|
malloc_mutex_t mtx;
|
2017-01-11 10:06:31 +08:00
|
|
|
|
2017-11-08 11:40:38 +08:00
|
|
|
/* Using THP when true (metadata_thp auto mode). */
|
2019-11-19 06:43:48 +08:00
|
|
|
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.
|
|
|
|
*/
|
2019-11-19 06:43:48 +08:00
|
|
|
pszind_t pind_last;
|
2017-04-17 09:39:14 +08:00
|
|
|
|
2017-01-11 10:06:31 +08:00
|
|
|
/* Serial number generation state. */
|
2019-11-19 06:43:48 +08:00
|
|
|
size_t extent_sn_next;
|
2017-01-11 10:06:31 +08:00
|
|
|
|
|
|
|
/* Chain of all blocks associated with base. */
|
2019-11-19 06:43:48 +08:00
|
|
|
base_block_t *blocks;
|
2017-01-11 10:06:31 +08:00
|
|
|
|
|
|
|
/* Heap of extents that track unused trailing space within blocks. */
|
2019-12-10 06:36:45 +08:00
|
|
|
edata_heap_t avail[SC_NSIZES];
|
2017-01-11 10:06:31 +08:00
|
|
|
|
|
|
|
/* Stats, only maintained if config_stats. */
|
2019-11-19 06:43:48 +08:00
|
|
|
size_t allocated;
|
|
|
|
size_t resident;
|
|
|
|
size_t mapped;
|
2017-08-26 04:24:49 +08:00
|
|
|
/* Number of THP regions touched. */
|
2019-11-19 06:43:48 +08:00
|
|
|
size_t n_thp;
|
2017-01-11 10:06:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* JEMALLOC_INTERNAL_BASE_STRUCTS_H */
|