MCPcopy Create free account
hub / github.com/beefytech/Beef / prof_recent_alloc_restore_locked

Function prof_recent_alloc_restore_locked

BeefRT/JEMalloc/src/prof_recent.c:412–442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

410}
411
412static void
413prof_recent_alloc_restore_locked(tsd_t *tsd, prof_recent_list_t *to_delete) {
414 malloc_mutex_assert_owner(tsd_tsdn(tsd), &prof_recent_alloc_mtx);
415 ssize_t max = prof_recent_alloc_max_get(tsd);
416 if (max == -1 || prof_recent_alloc_count <= max) {
417 /* Easy case - no need to alter the list. */
418 ql_new(to_delete);
419 prof_recent_alloc_assert_count(tsd);
420 return;
421 }
422
423 prof_recent_t *node;
424 ql_foreach(node, &prof_recent_alloc_list, link) {
425 if (prof_recent_alloc_count == max) {
426 break;
427 }
428 prof_recent_alloc_evict_edata(tsd, node);
429 --prof_recent_alloc_count;
430 }
431 assert(prof_recent_alloc_count == max);
432
433 ql_move(to_delete, &prof_recent_alloc_list);
434 if (max == 0) {
435 assert(node == NULL);
436 } else {
437 assert(node != NULL);
438 ql_split(to_delete, node, &prof_recent_alloc_list, link);
439 }
440 assert(!ql_empty(to_delete));
441 prof_recent_alloc_assert_count(tsd);
442}
443
444static void
445prof_recent_alloc_async_cleanup(tsd_t *tsd, prof_recent_list_t *to_delete) {

Callers 2

prof_recent_alloc_dumpFunction · 0.85

Calls 6

tsd_tsdnFunction · 0.85
ql_foreachFunction · 0.85

Tested by

no test coverage detected