1#ifndef JEMALLOC_INTERNAL_TCACHE_STRUCTS_H
2#define JEMALLOC_INTERNAL_TCACHE_STRUCTS_H
3
4#include "jemalloc/internal/cache_bin.h"
5#include "jemalloc/internal/ql.h"
6#include "jemalloc/internal/sc.h"
7#include "jemalloc/internal/ticker.h"
8#include "jemalloc/internal/tsd_types.h"
9
10/* Various uses of this struct need it to be a named type. */
11typedef ql_elm(tsd_t) tsd_link_t;
12
13struct tcache_s {
14 /*
15 * To minimize our cache-footprint, we put the frequently accessed data
16 * together at the start of this struct.
17 */
18
19 /* Cleared after arena_prof_accum(). */
20 uint64_t prof_accumbytes;
21 /* Drives incremental GC. */
22 ticker_t gc_ticker;
23 /*
24 * The pointer stacks associated with bins follow as a contiguous array.
25 * During tcache initialization, the avail pointer in each element of
26 * tbins is initialized to point to the proper offset within this array.
27 */
28 cache_bin_t bins_small[SC_NBINS];
29
30 /*
31 * This data is less hot; we can be a little less careful with our
32 * footprint here.
33 */
34 /* Lets us track all the tcaches in an arena. */
35 ql_elm(tcache_t) link;
36
37 /* Logically scoped to tsd, but put here for cache layout reasons. */
38 ql_elm(tsd_t) tsd_link;
39 bool in_hook;
40
41 /*
42 * The descriptor lets the arena find our cache bins without seeing the
43 * tcache definition. This enables arenas to aggregate stats across
44 * tcaches without having a tcache dependency.
45 */
46 cache_bin_array_descriptor_t cache_bin_array_descriptor;
47
48 /* The arena this tcache is associated with. */
49 arena_t *arena;
50 /* Next bin to GC. */
51 szind_t next_gc_bin;
52 /* For small bins, fill (ncached_max >> lg_fill_div). */
53 uint8_t lg_fill_div[SC_NBINS];
54 /*
55 * We put the cache bins for large size classes at the end of the
56 * struct, since some of them might not get used. This might end up
57 * letting us avoid touching an extra page if we don't have to.
58 */
59 cache_bin_t bins_large[SC_NSIZES-SC_NBINS];
60};
61
62/* Linkage for list of available (previously used) explicit tcache IDs. */
63struct tcaches_s {
64 union {
65 tcache_t *tcache;
66 tcaches_t *next;
67 };
68};
69
70#endif /* JEMALLOC_INTERNAL_TCACHE_STRUCTS_H */
71