2017-01-11 10:06:31 +08:00
|
|
|
#ifndef JEMALLOC_INTERNAL_TCACHE_EXTERNS_H
|
|
|
|
#define JEMALLOC_INTERNAL_TCACHE_EXTERNS_H
|
|
|
|
|
2020-05-12 06:03:06 +08:00
|
|
|
extern bool opt_tcache;
|
2020-10-20 13:48:26 +08:00
|
|
|
extern size_t opt_tcache_max;
|
2020-05-12 03:08:19 +08:00
|
|
|
extern ssize_t opt_lg_tcache_nslots_mul;
|
2020-05-12 06:03:06 +08:00
|
|
|
extern unsigned opt_tcache_nslots_small_min;
|
|
|
|
extern unsigned opt_tcache_nslots_small_max;
|
|
|
|
extern unsigned opt_tcache_nslots_large;
|
|
|
|
extern ssize_t opt_lg_tcache_shift;
|
2020-05-12 06:53:30 +08:00
|
|
|
extern size_t opt_tcache_gc_incr_bytes;
|
2020-05-12 07:24:17 +08:00
|
|
|
extern size_t opt_tcache_gc_delay_bytes;
|
2020-05-14 06:32:18 +08:00
|
|
|
extern unsigned opt_lg_tcache_flush_small_div;
|
|
|
|
extern unsigned opt_lg_tcache_flush_large_div;
|
2017-01-11 10:06:31 +08:00
|
|
|
|
|
|
|
/*
|
2017-12-15 04:46:39 +08:00
|
|
|
* Number of tcache bins. There are SC_NBINS small-object bins, plus 0 or more
|
2017-01-11 10:06:31 +08:00
|
|
|
* large-object bins.
|
|
|
|
*/
|
|
|
|
extern unsigned nhbins;
|
|
|
|
|
|
|
|
/* Maximum cached size class. */
|
|
|
|
extern size_t tcache_maxclass;
|
|
|
|
|
2020-02-26 04:14:48 +08:00
|
|
|
extern cache_bin_info_t *tcache_bin_info;
|
|
|
|
|
2017-01-11 10:06:31 +08:00
|
|
|
/*
|
|
|
|
* Explicit tcaches, managed via the tcache.{create,flush,destroy} mallctls and
|
|
|
|
* usable via the MALLOCX_TCACHE() flag. The automatic per thread tcaches are
|
|
|
|
* completely disjoint from this data structure. tcaches starts off as a sparse
|
|
|
|
* array, so it has no physical memory footprint until individual pages are
|
|
|
|
* touched. This allows the entire array to be allocated the first time an
|
|
|
|
* explicit tcache is created without a disproportionate impact on memory usage.
|
|
|
|
*/
|
|
|
|
extern tcaches_t *tcaches;
|
|
|
|
|
2021-10-19 08:33:15 +08:00
|
|
|
size_t tcache_salloc(tsdn_t *tsdn, const void *ptr);
|
|
|
|
void *tcache_alloc_small_hard(tsdn_t *tsdn, arena_t *arena, tcache_t *tcache,
|
2023-07-07 07:27:56 +08:00
|
|
|
cache_bin_t *cache_bin, szind_t binind, bool *tcache_success);
|
2020-04-08 08:48:35 +08:00
|
|
|
|
2023-07-07 07:27:56 +08:00
|
|
|
void tcache_bin_flush_small(tsd_t *tsd, tcache_t *tcache,
|
|
|
|
cache_bin_t *cache_bin, szind_t binind, unsigned rem);
|
|
|
|
void tcache_bin_flush_large(tsd_t *tsd, tcache_t *tcache,
|
|
|
|
cache_bin_t *cache_bin, szind_t binind, unsigned rem);
|
|
|
|
void tcache_bin_flush_stashed(tsd_t *tsd, tcache_t *tcache,
|
|
|
|
cache_bin_t *cache_bin, szind_t binind, bool is_small);
|
2021-10-19 08:33:15 +08:00
|
|
|
void tcache_arena_reassociate(tsdn_t *tsdn, tcache_slow_t *tcache_slow,
|
2020-04-08 08:48:35 +08:00
|
|
|
tcache_t *tcache, arena_t *arena);
|
2017-03-28 12:50:38 +08:00
|
|
|
tcache_t *tcache_create_explicit(tsd_t *tsd);
|
2021-10-19 08:33:15 +08:00
|
|
|
void tcache_cleanup(tsd_t *tsd);
|
|
|
|
void tcache_stats_merge(tsdn_t *tsdn, tcache_t *tcache, arena_t *arena);
|
|
|
|
bool tcaches_create(tsd_t *tsd, base_t *base, unsigned *r_ind);
|
|
|
|
void tcaches_flush(tsd_t *tsd, unsigned ind);
|
|
|
|
void tcaches_destroy(tsd_t *tsd, unsigned ind);
|
|
|
|
bool tcache_boot(tsdn_t *tsdn, base_t *base);
|
2020-04-08 08:48:35 +08:00
|
|
|
void tcache_arena_associate(tsdn_t *tsdn, tcache_slow_t *tcache_slow,
|
|
|
|
tcache_t *tcache, arena_t *arena);
|
2017-01-30 13:32:39 +08:00
|
|
|
void tcache_prefork(tsdn_t *tsdn);
|
|
|
|
void tcache_postfork_parent(tsdn_t *tsdn);
|
|
|
|
void tcache_postfork_child(tsdn_t *tsdn);
|
2017-06-16 06:16:18 +08:00
|
|
|
void tcache_flush(tsd_t *tsd);
|
2017-03-28 12:50:38 +08:00
|
|
|
bool tsd_tcache_data_init(tsd_t *tsd);
|
|
|
|
bool tsd_tcache_enabled_data_init(tsd_t *tsd);
|
2017-01-11 10:06:31 +08:00
|
|
|
|
2020-04-08 11:04:46 +08:00
|
|
|
void tcache_assert_initialized(tcache_t *tcache);
|
|
|
|
|
2020-04-16 01:49:08 +08:00
|
|
|
/* Only accessed by thread event. */
|
|
|
|
uint64_t tcache_gc_new_event_wait(tsd_t *tsd);
|
2020-04-17 04:33:56 +08:00
|
|
|
uint64_t tcache_gc_postponed_event_wait(tsd_t *tsd);
|
2020-04-18 01:38:06 +08:00
|
|
|
void tcache_gc_event_handler(tsd_t *tsd, uint64_t elapsed);
|
2020-04-16 01:49:08 +08:00
|
|
|
uint64_t tcache_gc_dalloc_new_event_wait(tsd_t *tsd);
|
2020-04-17 04:33:56 +08:00
|
|
|
uint64_t tcache_gc_dalloc_postponed_event_wait(tsd_t *tsd);
|
2020-04-18 01:38:06 +08:00
|
|
|
void tcache_gc_dalloc_event_handler(tsd_t *tsd, uint64_t elapsed);
|
2020-04-16 01:49:08 +08:00
|
|
|
|
2017-01-11 10:06:31 +08:00
|
|
|
#endif /* JEMALLOC_INTERNAL_TCACHE_EXTERNS_H */
|