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

Function extents_remove_locked

deps/jemalloc/src/extent.c:370–399  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

368}
369
370static void
371extents_remove_locked(tsdn_t *tsdn, extents_t *extents, extent_t *extent) {
372 malloc_mutex_assert_owner(tsdn, &extents->mtx);
373 assert(extent_state_get(extent) == extents->state);
374
375 size_t size = extent_size_get(extent);
376 size_t psz = extent_size_quantize_floor(size);
377 pszind_t pind = sz_psz2ind(psz);
378 extent_heap_remove(&extents->heaps[pind], extent);
379
380 if (config_stats) {
381 extents_stats_sub(extents, pind, size);
382 }
383
384 if (extent_heap_empty(&extents->heaps[pind])) {
385 bitmap_set(extents->bitmap, &extents_bitmap_info,
386 (size_t)pind);
387 }
388 extent_list_remove(&extents->lru, extent);
389 size_t npages = size >> LG_PAGE;
390 /*
391 * As in extents_insert_locked, we hold extents->mtx and so don't need
392 * atomic operations for updating extents->npages.
393 */
394 size_t cur_extents_npages =
395 atomic_load_zu(&extents->npages, ATOMIC_RELAXED);
396 assert(cur_extents_npages >= npages);
397 atomic_store_zu(&extents->npages,
398 cur_extents_npages - (size >> LG_PAGE), ATOMIC_RELAXED);
399}
400
401/*
402 * Find an extent with size [min_size, max_size) to satisfy the alignment

Callers 2

extents_evictFunction · 0.70
extent_activate_lockedFunction · 0.70

Calls 8

extents_stats_subFunction · 0.85
extent_state_getFunction · 0.50
extent_size_getFunction · 0.50
sz_psz2indFunction · 0.50
bitmap_setFunction · 0.50
extent_list_removeFunction · 0.50

Tested by

no test coverage detected