Home | History | Annotate | Line # | Download | only in internal
      1      1.1  christos #ifndef JEMALLOC_INTERNAL_TCACHE_STRUCTS_H
      2      1.1  christos #define JEMALLOC_INTERNAL_TCACHE_STRUCTS_H
      3      1.1  christos 
      4      1.1  christos #include "jemalloc/internal/cache_bin.h"
      5  1.1.1.2  christos #include "jemalloc/internal/ql.h"
      6  1.1.1.2  christos #include "jemalloc/internal/sc.h"
      7      1.1  christos #include "jemalloc/internal/ticker.h"
      8  1.1.1.2  christos #include "jemalloc/internal/tsd_types.h"
      9      1.1  christos 
     10  1.1.1.2  christos /*
     11  1.1.1.2  christos  * The tcache state is split into the slow and hot path data.  Each has a
     12  1.1.1.2  christos  * pointer to the other, and the data always comes in pairs.  The layout of each
     13  1.1.1.2  christos  * of them varies in practice; tcache_slow lives in the TSD for the automatic
     14  1.1.1.2  christos  * tcache, and as part of a dynamic allocation for manual allocations.  Keeping
     15  1.1.1.2  christos  * a pointer to tcache_slow lets us treat these cases uniformly, rather than
     16  1.1.1.2  christos  * splitting up the tcache [de]allocation code into those paths called with the
     17  1.1.1.2  christos  * TSD tcache and those called with a manual tcache.
     18  1.1.1.2  christos  */
     19      1.1  christos 
     20  1.1.1.2  christos struct tcache_slow_s {
     21      1.1  christos 	/* Lets us track all the tcaches in an arena. */
     22  1.1.1.2  christos 	ql_elm(tcache_slow_t) link;
     23  1.1.1.2  christos 
     24      1.1  christos 	/*
     25      1.1  christos 	 * The descriptor lets the arena find our cache bins without seeing the
     26      1.1  christos 	 * tcache definition.  This enables arenas to aggregate stats across
     27      1.1  christos 	 * tcaches without having a tcache dependency.
     28      1.1  christos 	 */
     29      1.1  christos 	cache_bin_array_descriptor_t cache_bin_array_descriptor;
     30      1.1  christos 
     31      1.1  christos 	/* The arena this tcache is associated with. */
     32      1.1  christos 	arena_t		*arena;
     33      1.1  christos 	/* Next bin to GC. */
     34      1.1  christos 	szind_t		next_gc_bin;
     35      1.1  christos 	/* For small bins, fill (ncached_max >> lg_fill_div). */
     36  1.1.1.2  christos 	uint8_t		lg_fill_div[SC_NBINS];
     37  1.1.1.2  christos 	/* For small bins, whether has been refilled since last GC. */
     38  1.1.1.2  christos 	bool		bin_refilled[SC_NBINS];
     39  1.1.1.2  christos 	/*
     40  1.1.1.2  christos 	 * For small bins, the number of items we can pretend to flush before
     41  1.1.1.2  christos 	 * actually flushing.
     42  1.1.1.2  christos 	 */
     43  1.1.1.2  christos 	uint8_t		bin_flush_delay_items[SC_NBINS];
     44      1.1  christos 	/*
     45  1.1.1.2  christos 	 * The start of the allocation containing the dynamic allocation for
     46  1.1.1.2  christos 	 * either the cache bins alone, or the cache bin memory as well as this
     47  1.1.1.2  christos 	 * tcache_slow_t and its associated tcache_t.
     48      1.1  christos 	 */
     49  1.1.1.2  christos 	void		*dyn_alloc;
     50  1.1.1.2  christos 
     51  1.1.1.2  christos 	/* The associated bins. */
     52  1.1.1.2  christos 	tcache_t	*tcache;
     53  1.1.1.2  christos };
     54  1.1.1.2  christos 
     55  1.1.1.2  christos struct tcache_s {
     56  1.1.1.2  christos 	tcache_slow_t	*tcache_slow;
     57  1.1.1.2  christos 	cache_bin_t	bins[TCACHE_NBINS_MAX];
     58      1.1  christos };
     59      1.1  christos 
     60      1.1  christos /* Linkage for list of available (previously used) explicit tcache IDs. */
     61      1.1  christos struct tcaches_s {
     62      1.1  christos 	union {
     63      1.1  christos 		tcache_t	*tcache;
     64      1.1  christos 		tcaches_t	*next;
     65      1.1  christos 	};
     66      1.1  christos };
     67      1.1  christos 
     68      1.1  christos #endif /* JEMALLOC_INTERNAL_TCACHE_STRUCTS_H */
     69