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