xref: /freebsd/contrib/jemalloc/include/jemalloc/internal/arena_externs.h (revision d4eeb02986980bf33dd56c41ceb9fc5f180c0d47)
1 #ifndef JEMALLOC_INTERNAL_ARENA_EXTERNS_H
2 #define JEMALLOC_INTERNAL_ARENA_EXTERNS_H
3 
4 #include "jemalloc/internal/bin.h"
5 #include "jemalloc/internal/extent_dss.h"
6 #include "jemalloc/internal/hook.h"
7 #include "jemalloc/internal/pages.h"
8 #include "jemalloc/internal/stats.h"
9 
10 extern ssize_t opt_dirty_decay_ms;
11 extern ssize_t opt_muzzy_decay_ms;
12 
13 extern percpu_arena_mode_t opt_percpu_arena;
14 extern const char *percpu_arena_mode_names[];
15 
16 extern const uint64_t h_steps[SMOOTHSTEP_NSTEPS];
17 extern malloc_mutex_t arenas_lock;
18 
19 extern size_t opt_oversize_threshold;
20 extern size_t oversize_threshold;
21 
22 void arena_basic_stats_merge(tsdn_t *tsdn, arena_t *arena,
23     unsigned *nthreads, const char **dss, ssize_t *dirty_decay_ms,
24     ssize_t *muzzy_decay_ms, size_t *nactive, size_t *ndirty, size_t *nmuzzy);
25 void arena_stats_merge(tsdn_t *tsdn, arena_t *arena, unsigned *nthreads,
26     const char **dss, ssize_t *dirty_decay_ms, ssize_t *muzzy_decay_ms,
27     size_t *nactive, size_t *ndirty, size_t *nmuzzy, arena_stats_t *astats,
28     bin_stats_t *bstats, arena_stats_large_t *lstats,
29     arena_stats_extents_t *estats);
30 void arena_extents_dirty_dalloc(tsdn_t *tsdn, arena_t *arena,
31     extent_hooks_t **r_extent_hooks, extent_t *extent);
32 #ifdef JEMALLOC_JET
33 size_t arena_slab_regind(extent_t *slab, szind_t binind, const void *ptr);
34 #endif
35 extent_t *arena_extent_alloc_large(tsdn_t *tsdn, arena_t *arena,
36     size_t usize, size_t alignment, bool *zero);
37 void arena_extent_dalloc_large_prep(tsdn_t *tsdn, arena_t *arena,
38     extent_t *extent);
39 void arena_extent_ralloc_large_shrink(tsdn_t *tsdn, arena_t *arena,
40     extent_t *extent, size_t oldsize);
41 void arena_extent_ralloc_large_expand(tsdn_t *tsdn, arena_t *arena,
42     extent_t *extent, size_t oldsize);
43 ssize_t arena_dirty_decay_ms_get(arena_t *arena);
44 bool arena_dirty_decay_ms_set(tsdn_t *tsdn, arena_t *arena, ssize_t decay_ms);
45 ssize_t arena_muzzy_decay_ms_get(arena_t *arena);
46 bool arena_muzzy_decay_ms_set(tsdn_t *tsdn, arena_t *arena, ssize_t decay_ms);
47 void arena_decay(tsdn_t *tsdn, arena_t *arena, bool is_background_thread,
48     bool all);
49 void arena_reset(tsd_t *tsd, arena_t *arena);
50 void arena_destroy(tsd_t *tsd, arena_t *arena);
51 void arena_tcache_fill_small(tsdn_t *tsdn, arena_t *arena, tcache_t *tcache,
52     cache_bin_t *tbin, szind_t binind, uint64_t prof_accumbytes);
53 void arena_alloc_junk_small(void *ptr, const bin_info_t *bin_info,
54     bool zero);
55 
56 typedef void (arena_dalloc_junk_small_t)(void *, const bin_info_t *);
57 extern arena_dalloc_junk_small_t *JET_MUTABLE arena_dalloc_junk_small;
58 
59 void *arena_malloc_hard(tsdn_t *tsdn, arena_t *arena, size_t size,
60     szind_t ind, bool zero);
61 void *arena_palloc(tsdn_t *tsdn, arena_t *arena, size_t usize,
62     size_t alignment, bool zero, tcache_t *tcache);
63 void arena_prof_promote(tsdn_t *tsdn, void *ptr, size_t usize);
64 void arena_dalloc_promoted(tsdn_t *tsdn, void *ptr, tcache_t *tcache,
65     bool slow_path);
66 void arena_dalloc_bin_junked_locked(tsdn_t *tsdn, arena_t *arena, bin_t *bin,
67     szind_t binind, extent_t *extent, void *ptr);
68 void arena_dalloc_small(tsdn_t *tsdn, void *ptr);
69 bool arena_ralloc_no_move(tsdn_t *tsdn, void *ptr, size_t oldsize, size_t size,
70     size_t extra, bool zero, size_t *newsize);
71 void *arena_ralloc(tsdn_t *tsdn, arena_t *arena, void *ptr, size_t oldsize,
72     size_t size, size_t alignment, bool zero, tcache_t *tcache,
73     hook_ralloc_args_t *hook_args);
74 dss_prec_t arena_dss_prec_get(arena_t *arena);
75 bool arena_dss_prec_set(arena_t *arena, dss_prec_t dss_prec);
76 ssize_t arena_dirty_decay_ms_default_get(void);
77 bool arena_dirty_decay_ms_default_set(ssize_t decay_ms);
78 ssize_t arena_muzzy_decay_ms_default_get(void);
79 bool arena_muzzy_decay_ms_default_set(ssize_t decay_ms);
80 bool arena_retain_grow_limit_get_set(tsd_t *tsd, arena_t *arena,
81     size_t *old_limit, size_t *new_limit);
82 unsigned arena_nthreads_get(arena_t *arena, bool internal);
83 void arena_nthreads_inc(arena_t *arena, bool internal);
84 void arena_nthreads_dec(arena_t *arena, bool internal);
85 size_t arena_extent_sn_next(arena_t *arena);
86 arena_t *arena_new(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks);
87 bool arena_init_huge(void);
88 bool arena_is_huge(unsigned arena_ind);
89 arena_t *arena_choose_huge(tsd_t *tsd);
90 bin_t *arena_bin_choose_lock(tsdn_t *tsdn, arena_t *arena, szind_t binind,
91     unsigned *binshard);
92 void arena_boot(sc_data_t *sc_data);
93 void arena_prefork0(tsdn_t *tsdn, arena_t *arena);
94 void arena_prefork1(tsdn_t *tsdn, arena_t *arena);
95 void arena_prefork2(tsdn_t *tsdn, arena_t *arena);
96 void arena_prefork3(tsdn_t *tsdn, arena_t *arena);
97 void arena_prefork4(tsdn_t *tsdn, arena_t *arena);
98 void arena_prefork5(tsdn_t *tsdn, arena_t *arena);
99 void arena_prefork6(tsdn_t *tsdn, arena_t *arena);
100 void arena_prefork7(tsdn_t *tsdn, arena_t *arena);
101 void arena_postfork_parent(tsdn_t *tsdn, arena_t *arena);
102 void arena_postfork_child(tsdn_t *tsdn, arena_t *arena);
103 
104 #endif /* JEMALLOC_INTERNAL_ARENA_EXTERNS_H */
105