1#ifndef JEMALLOC_INTERNAL_TCACHE_EXTERNS_H
2#define JEMALLOC_INTERNAL_TCACHE_EXTERNS_H
3
4extern bool opt_tcache;
5extern size_t opt_tcache_max;
6extern ssize_t opt_lg_tcache_nslots_mul;
7extern unsigned opt_tcache_nslots_small_min;
8extern unsigned opt_tcache_nslots_small_max;
9extern unsigned opt_tcache_nslots_large;
10extern ssize_t opt_lg_tcache_shift;
11extern size_t opt_tcache_gc_incr_bytes;
12extern size_t opt_tcache_gc_delay_bytes;
13extern unsigned opt_lg_tcache_flush_small_div;
14extern unsigned opt_lg_tcache_flush_large_div;
15
16/*
17 * Number of tcache bins. There are SC_NBINS small-object bins, plus 0 or more
18 * large-object bins.
19 */
20extern unsigned nhbins;
21
22/* Maximum cached size class. */
23extern size_t tcache_maxclass;
24
25extern cache_bin_info_t *tcache_bin_info;
26
27/*
28 * Explicit tcaches, managed via the tcache.{create,flush,destroy} mallctls and
29 * usable via the MALLOCX_TCACHE() flag. The automatic per thread tcaches are
30 * completely disjoint from this data structure. tcaches starts off as a sparse
31 * array, so it has no physical memory footprint until individual pages are
32 * touched. This allows the entire array to be allocated the first time an
33 * explicit tcache is created without a disproportionate impact on memory usage.
34 */
35extern tcaches_t *tcaches;
36
37size_t tcache_salloc(tsdn_t *tsdn, const void *ptr);
38void *tcache_alloc_small_hard(tsdn_t *tsdn, arena_t *arena, tcache_t *tcache,
39 cache_bin_t *tbin, szind_t binind, bool *tcache_success);
40
41void tcache_bin_flush_small(tsd_t *tsd, tcache_t *tcache, cache_bin_t *tbin,
42 szind_t binind, unsigned rem);
43void tcache_bin_flush_large(tsd_t *tsd, tcache_t *tcache, cache_bin_t *tbin,
44 szind_t binind, unsigned rem);
45void tcache_bin_flush_stashed(tsd_t *tsd, tcache_t *tcache, cache_bin_t *bin,
46 szind_t binind, bool is_small);
47void tcache_arena_reassociate(tsdn_t *tsdn, tcache_slow_t *tcache_slow,
48 tcache_t *tcache, arena_t *arena);
49tcache_t *tcache_create_explicit(tsd_t *tsd);
50void tcache_cleanup(tsd_t *tsd);
51void tcache_stats_merge(tsdn_t *tsdn, tcache_t *tcache, arena_t *arena);
52bool tcaches_create(tsd_t *tsd, base_t *base, unsigned *r_ind);
53void tcaches_flush(tsd_t *tsd, unsigned ind);
54void tcaches_destroy(tsd_t *tsd, unsigned ind);
55bool tcache_boot(tsdn_t *tsdn, base_t *base);
56void tcache_arena_associate(tsdn_t *tsdn, tcache_slow_t *tcache_slow,
57 tcache_t *tcache, arena_t *arena);
58void tcache_prefork(tsdn_t *tsdn);
59void tcache_postfork_parent(tsdn_t *tsdn);
60void tcache_postfork_child(tsdn_t *tsdn);
61void tcache_flush(tsd_t *tsd);
62bool tsd_tcache_data_init(tsd_t *tsd);
63bool tsd_tcache_enabled_data_init(tsd_t *tsd);
64
65void tcache_assert_initialized(tcache_t *tcache);
66
67/* Only accessed by thread event. */
68uint64_t tcache_gc_new_event_wait(tsd_t *tsd);
69uint64_t tcache_gc_postponed_event_wait(tsd_t *tsd);
70void tcache_gc_event_handler(tsd_t *tsd, uint64_t elapsed);
71uint64_t tcache_gc_dalloc_new_event_wait(tsd_t *tsd);
72uint64_t tcache_gc_dalloc_postponed_event_wait(tsd_t *tsd);
73void tcache_gc_dalloc_event_handler(tsd_t *tsd, uint64_t elapsed);
74
75#endif /* JEMALLOC_INTERNAL_TCACHE_EXTERNS_H */
76