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

Function base_extent_alloc

deps/jemalloc/src/base.c:307–342  ·  view source on GitHub ↗

* Allocate an extent that is at least as large as specified size, with * specified alignment. */

Source from the content-addressed store, hash-verified

305 * specified alignment.
306 */
307static extent_t *
308base_extent_alloc(tsdn_t *tsdn, base_t *base, size_t size, size_t alignment) {
309 malloc_mutex_assert_owner(tsdn, &base->mtx);
310
311 extent_hooks_t *extent_hooks = base_extent_hooks_get(base);
312 /*
313 * Drop mutex during base_block_alloc(), because an extent hook will be
314 * called.
315 */
316 malloc_mutex_unlock(tsdn, &base->mtx);
317 base_block_t *block = base_block_alloc(tsdn, base, extent_hooks,
318 base_ind_get(base), &base->pind_last, &base->extent_sn_next, size,
319 alignment);
320 malloc_mutex_lock(tsdn, &base->mtx);
321 if (block == NULL) {
322 return NULL;
323 }
324 block->next = base->blocks;
325 base->blocks = block;
326 if (config_stats) {
327 base->allocated += sizeof(base_block_t);
328 base->resident += PAGE_CEILING(sizeof(base_block_t));
329 base->mapped += block->size;
330 if (metadata_thp_madvise() &&
331 !(opt_metadata_thp == metadata_thp_auto
332 && !base->auto_thp_switched)) {
333 assert(base->n_thp > 0);
334 base->n_thp += HUGEPAGE_CEILING(sizeof(base_block_t)) >>
335 LG_HUGEPAGE;
336 }
337 assert(base->allocated <= base->resident);
338 assert(base->resident <= base->mapped);
339 assert(base->n_thp << LG_HUGEPAGE <= base->mapped);
340 }
341 return &block->extent;
342}
343
344base_t *
345b0get(void) {

Callers 1

base_alloc_implFunction · 0.70

Calls 7

metadata_thp_madviseFunction · 0.85
base_extent_hooks_getFunction · 0.70
base_block_allocFunction · 0.70
malloc_mutex_unlockFunction · 0.50
base_ind_getFunction · 0.50
malloc_mutex_lockFunction · 0.50

Tested by

no test coverage detected