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