1 | #ifndef JEMALLOC_INTERNAL_TCACHE_EXTERNS_H |
2 | #define JEMALLOC_INTERNAL_TCACHE_EXTERNS_H |
3 | |
4 | extern bool opt_tcache; |
5 | extern size_t opt_tcache_max; |
6 | extern ssize_t opt_lg_tcache_nslots_mul; |
7 | extern unsigned opt_tcache_nslots_small_min; |
8 | extern unsigned opt_tcache_nslots_small_max; |
9 | extern unsigned opt_tcache_nslots_large; |
10 | extern ssize_t opt_lg_tcache_shift; |
11 | extern size_t opt_tcache_gc_incr_bytes; |
12 | extern size_t opt_tcache_gc_delay_bytes; |
13 | extern unsigned opt_lg_tcache_flush_small_div; |
14 | extern 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 | */ |
20 | extern unsigned nhbins; |
21 | |
22 | /* Maximum cached size class. */ |
23 | extern size_t tcache_maxclass; |
24 | |
25 | extern 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 | */ |
35 | extern tcaches_t *tcaches; |
36 | |
37 | size_t tcache_salloc(tsdn_t *tsdn, const void *ptr); |
38 | void *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 | |
41 | void tcache_bin_flush_small(tsd_t *tsd, tcache_t *tcache, cache_bin_t *tbin, |
42 | szind_t binind, unsigned rem); |
43 | void tcache_bin_flush_large(tsd_t *tsd, tcache_t *tcache, cache_bin_t *tbin, |
44 | szind_t binind, unsigned rem); |
45 | void tcache_bin_flush_stashed(tsd_t *tsd, tcache_t *tcache, cache_bin_t *bin, |
46 | szind_t binind, bool is_small); |
47 | void tcache_arena_reassociate(tsdn_t *tsdn, tcache_slow_t *tcache_slow, |
48 | tcache_t *tcache, arena_t *arena); |
49 | tcache_t *tcache_create_explicit(tsd_t *tsd); |
50 | void tcache_cleanup(tsd_t *tsd); |
51 | void tcache_stats_merge(tsdn_t *tsdn, tcache_t *tcache, arena_t *arena); |
52 | bool tcaches_create(tsd_t *tsd, base_t *base, unsigned *r_ind); |
53 | void tcaches_flush(tsd_t *tsd, unsigned ind); |
54 | void tcaches_destroy(tsd_t *tsd, unsigned ind); |
55 | bool tcache_boot(tsdn_t *tsdn, base_t *base); |
56 | void tcache_arena_associate(tsdn_t *tsdn, tcache_slow_t *tcache_slow, |
57 | tcache_t *tcache, arena_t *arena); |
58 | void tcache_prefork(tsdn_t *tsdn); |
59 | void tcache_postfork_parent(tsdn_t *tsdn); |
60 | void tcache_postfork_child(tsdn_t *tsdn); |
61 | void tcache_flush(tsd_t *tsd); |
62 | bool tsd_tcache_data_init(tsd_t *tsd); |
63 | bool tsd_tcache_enabled_data_init(tsd_t *tsd); |
64 | |
65 | void tcache_assert_initialized(tcache_t *tcache); |
66 | |
67 | /* Only accessed by thread event. */ |
68 | uint64_t tcache_gc_new_event_wait(tsd_t *tsd); |
69 | uint64_t tcache_gc_postponed_event_wait(tsd_t *tsd); |
70 | void tcache_gc_event_handler(tsd_t *tsd, uint64_t elapsed); |
71 | uint64_t tcache_gc_dalloc_new_event_wait(tsd_t *tsd); |
72 | uint64_t tcache_gc_dalloc_postponed_event_wait(tsd_t *tsd); |
73 | void tcache_gc_dalloc_event_handler(tsd_t *tsd, uint64_t elapsed); |
74 | |
75 | #endif /* JEMALLOC_INTERNAL_TCACHE_EXTERNS_H */ |
76 | |