2017-01-11 10:06:31 +08:00
|
|
|
#ifndef JEMALLOC_INTERNAL_TCACHE_STRUCTS_H
|
|
|
|
#define JEMALLOC_INTERNAL_TCACHE_STRUCTS_H
|
|
|
|
|
2017-08-11 05:27:58 +08:00
|
|
|
#include "jemalloc/internal/cache_bin.h"
|
2017-12-15 04:46:39 +08:00
|
|
|
#include "jemalloc/internal/ql.h"
|
|
|
|
#include "jemalloc/internal/sc.h"
|
2017-04-20 04:39:33 +08:00
|
|
|
#include "jemalloc/internal/ticker.h"
|
2019-02-21 10:45:23 +08:00
|
|
|
#include "jemalloc/internal/tsd_types.h"
|
2017-04-11 08:11:33 +08:00
|
|
|
|
2020-04-08 08:48:35 +08:00
|
|
|
/*
|
|
|
|
* The tcache state is split into the slow and hot path data. Each has a
|
|
|
|
* pointer to the other, and the data always comes in pairs. The layout of each
|
|
|
|
* of them varies in practice; tcache_slow lives in the TSD for the automatic
|
|
|
|
* tcache, and as part of a dynamic allocation for manual allocations. Keeping
|
|
|
|
* a pointer to tcache_slow lets us treat these cases uniformly, rather than
|
|
|
|
* splitting up the tcache [de]allocation code into those paths called with the
|
|
|
|
* TSD tcache and those called with a manual tcache.
|
|
|
|
*/
|
2017-08-12 08:34:21 +08:00
|
|
|
|
2020-04-08 08:48:35 +08:00
|
|
|
struct tcache_slow_s {
|
2017-08-12 08:34:21 +08:00
|
|
|
/* Lets us track all the tcaches in an arena. */
|
2020-04-08 08:48:35 +08:00
|
|
|
ql_elm(tcache_slow_t) link;
|
2018-06-22 04:02:49 +08:00
|
|
|
|
2017-08-12 08:34:21 +08:00
|
|
|
/*
|
|
|
|
* The descriptor lets the arena find our cache bins without seeing the
|
|
|
|
* tcache definition. This enables arenas to aggregate stats across
|
|
|
|
* tcaches without having a tcache dependency.
|
|
|
|
*/
|
|
|
|
cache_bin_array_descriptor_t cache_bin_array_descriptor;
|
|
|
|
|
|
|
|
/* The arena this tcache is associated with. */
|
|
|
|
arena_t *arena;
|
|
|
|
/* Next bin to GC. */
|
|
|
|
szind_t next_gc_bin;
|
2017-04-07 03:35:22 +08:00
|
|
|
/* For small bins, fill (ncached_max >> lg_fill_div). */
|
2017-12-15 04:46:39 +08:00
|
|
|
uint8_t lg_fill_div[SC_NBINS];
|
2019-08-21 09:14:18 +08:00
|
|
|
/* For small bins, whether has been refilled since last GC. */
|
|
|
|
bool bin_refilled[SC_NBINS];
|
2020-03-03 10:28:17 +08:00
|
|
|
/*
|
|
|
|
* The start of the allocation containing the dynamic allocation for
|
|
|
|
* either the cache bins alone, or the cache bin memory as well as this
|
2020-04-08 08:48:35 +08:00
|
|
|
* tcache_slow_t and its associated tcache_t.
|
2020-03-03 10:28:17 +08:00
|
|
|
*/
|
|
|
|
void *dyn_alloc;
|
2020-04-08 08:48:35 +08:00
|
|
|
|
|
|
|
/* The associated bins. */
|
|
|
|
tcache_t *tcache;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct tcache_s {
|
|
|
|
tcache_slow_t *tcache_slow;
|
2020-04-08 11:04:46 +08:00
|
|
|
cache_bin_t bins[SC_NSIZES];
|
2017-01-11 10:06:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Linkage for list of available (previously used) explicit tcache IDs. */
|
|
|
|
struct tcaches_s {
|
|
|
|
union {
|
|
|
|
tcache_t *tcache;
|
|
|
|
tcaches_t *next;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* JEMALLOC_INTERNAL_TCACHE_STRUCTS_H */
|