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"
|
2017-04-11 08:11:33 +08:00
|
|
|
|
2018-06-22 04:02:49 +08:00
|
|
|
/* Various uses of this struct need it to be a named type. */
|
|
|
|
typedef struct tsd_s tsd_t;
|
|
|
|
typedef ql_elm(tsd_t) tsd_link_t;
|
|
|
|
|
2017-01-11 10:06:31 +08:00
|
|
|
struct tcache_s {
|
2017-08-12 08:34:21 +08:00
|
|
|
/*
|
|
|
|
* To minimize our cache-footprint, we put the frequently accessed data
|
|
|
|
* together at the start of this struct.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Cleared after arena_prof_accum(). */
|
|
|
|
uint64_t prof_accumbytes;
|
|
|
|
/* Drives incremental GC. */
|
|
|
|
ticker_t gc_ticker;
|
2017-01-11 10:06:31 +08:00
|
|
|
/*
|
2017-08-11 05:27:58 +08:00
|
|
|
* The pointer stacks associated with bins follow as a contiguous array.
|
|
|
|
* During tcache initialization, the avail pointer in each element of
|
|
|
|
* tbins is initialized to point to the proper offset within this array.
|
2017-01-11 10:06:31 +08:00
|
|
|
*/
|
2017-12-15 04:46:39 +08:00
|
|
|
cache_bin_t bins_small[SC_NBINS];
|
2017-08-12 08:34:21 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This data is less hot; we can be a little less careful with our
|
|
|
|
* footprint here.
|
|
|
|
*/
|
|
|
|
/* Lets us track all the tcaches in an arena. */
|
|
|
|
ql_elm(tcache_t) link;
|
2018-06-22 04:02:49 +08:00
|
|
|
|
|
|
|
/* Logically scoped to tsd, but put here for cache layout reasons. */
|
|
|
|
ql_elm(tsd_t) tsd_link;
|
|
|
|
bool in_hook;
|
|
|
|
|
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];
|
2017-08-12 08:34:21 +08:00
|
|
|
/*
|
|
|
|
* We put the cache bins for large size classes at the end of the
|
|
|
|
* struct, since some of them might not get used. This might end up
|
|
|
|
* letting us avoid touching an extra page if we don't have to.
|
|
|
|
*/
|
2017-12-15 04:46:39 +08:00
|
|
|
cache_bin_t bins_large[SC_NSIZES-SC_NBINS];
|
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 */
|