MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / large_palloc

Function large_palloc

deps/jemalloc/src/large.c:20–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20void *
21large_palloc(tsdn_t *tsdn, arena_t *arena, size_t usize, size_t alignment,
22 bool zero) {
23 size_t ausize;
24 extent_t *extent;
25 bool is_zeroed;
26 UNUSED bool idump JEMALLOC_CC_SILENCE_INIT(false);
27
28 assert(!tsdn_null(tsdn) || arena != NULL);
29
30 ausize = sz_sa2u(usize, alignment);
31 if (unlikely(ausize == 0 || ausize > SC_LARGE_MAXCLASS)) {
32 return NULL;
33 }
34
35 if (config_fill && unlikely(opt_zero)) {
36 zero = true;
37 }
38 /*
39 * Copy zero into is_zeroed and pass the copy when allocating the
40 * extent, so that it is possible to make correct junk/zero fill
41 * decisions below, even if is_zeroed ends up true when zero is false.
42 */
43 is_zeroed = zero;
44 if (likely(!tsdn_null(tsdn))) {
45 arena = arena_choose_maybe_huge(tsdn_tsd(tsdn), arena, usize);
46 }
47 if (unlikely(arena == NULL) || (extent = arena_extent_alloc_large(tsdn,
48 arena, usize, alignment, &is_zeroed)) == NULL) {
49 return NULL;
50 }
51
52 /* See comments in arena_bin_slabs_full_insert(). */
53 if (!arena_is_auto(arena)) {
54 /* Insert extent into large. */
55 malloc_mutex_lock(tsdn, &arena->large_mtx);
56 extent_list_append(&arena->large, extent);
57 malloc_mutex_unlock(tsdn, &arena->large_mtx);
58 }
59 if (config_prof && arena_prof_accum(tsdn, arena, usize)) {
60 prof_idump(tsdn);
61 }
62
63 if (zero) {
64 assert(is_zeroed);
65 } else if (config_fill && unlikely(opt_junk_alloc)) {
66 memset(extent_addr_get(extent), JEMALLOC_ALLOC_JUNK,
67 extent_usize_get(extent));
68 }
69
70 arena_decay_tick(tsdn, arena);
71 return extent_addr_get(extent);
72}
73
74static void
75large_dalloc_junk_impl(void *ptr, size_t size) {

Callers 3

large_mallocFunction · 0.70
large_ralloc_move_helperFunction · 0.70
arena_pallocFunction · 0.70

Calls 14

arena_choose_maybe_hugeFunction · 0.85
arena_extent_alloc_largeFunction · 0.70
prof_idumpFunction · 0.70
tsdn_nullFunction · 0.50
sz_sa2uFunction · 0.50
tsdn_tsdFunction · 0.50
arena_is_autoFunction · 0.50
malloc_mutex_lockFunction · 0.50
extent_list_appendFunction · 0.50
malloc_mutex_unlockFunction · 0.50
arena_prof_accumFunction · 0.50
extent_addr_getFunction · 0.50

Tested by

no test coverage detected