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

Function extent_record

BeefRT/JEMalloc/src/extent.c:914–953  ·  view source on GitHub ↗

* Does the metadata management portions of putting an unused extent into the * given ecache_t (coalesces and inserts into the eset). */

Source from the content-addressed store, hash-verified

912 * given ecache_t (coalesces and inserts into the eset).
913 */
914void
915extent_record(tsdn_t *tsdn, pac_t *pac, ehooks_t *ehooks, ecache_t *ecache,
916 edata_t *edata) {
917 assert((ecache->state != extent_state_dirty &&
918 ecache->state != extent_state_muzzy) ||
919 !edata_zeroed_get(edata));
920
921 malloc_mutex_lock(tsdn, &ecache->mtx);
922
923 emap_assert_mapped(tsdn, pac->emap, edata);
924
925 if (edata_guarded_get(edata)) {
926 goto label_skip_coalesce;
927 }
928 if (!ecache->delay_coalesce) {
929 edata = extent_try_coalesce(tsdn, pac, ehooks, ecache, edata,
930 NULL);
931 } else if (edata_size_get(edata) >= SC_LARGE_MINCLASS) {
932 assert(ecache == &pac->ecache_dirty);
933 /* Always coalesce large extents eagerly. */
934 bool coalesced;
935 do {
936 assert(edata_state_get(edata) == extent_state_active);
937 edata = extent_try_coalesce_large(tsdn, pac, ehooks,
938 ecache, edata, &coalesced);
939 } while (coalesced);
940 if (edata_size_get(edata) >=
941 atomic_load_zu(&pac->oversize_threshold, ATOMIC_RELAXED)
942 && extent_may_force_decay(pac)) {
943 /* Shortcut to purge the oversize extent eagerly. */
944 malloc_mutex_unlock(tsdn, &ecache->mtx);
945 extent_maximally_purge(tsdn, pac, ehooks, edata);
946 return;
947 }
948 }
949label_skip_coalesce:
950 extent_deactivate_locked(tsdn, pac, ecache, edata);
951
952 malloc_mutex_unlock(tsdn, &ecache->mtx);
953}
954
955void
956extent_dalloc_gap(tsdn_t *tsdn, pac_t *pac, ehooks_t *ehooks,

Callers 5

ecache_dallocFunction · 0.85
extent_recycleFunction · 0.85
extent_grow_retainedFunction · 0.85
extent_dalloc_wrapperFunction · 0.85
san_bump_allocFunction · 0.85

Calls 12

edata_zeroed_getFunction · 0.85
malloc_mutex_lockFunction · 0.85
emap_assert_mappedFunction · 0.85
edata_guarded_getFunction · 0.85
extent_try_coalesceFunction · 0.85
edata_size_getFunction · 0.85
edata_state_getFunction · 0.85
extent_may_force_decayFunction · 0.85
malloc_mutex_unlockFunction · 0.85
extent_maximally_purgeFunction · 0.85
extent_deactivate_lockedFunction · 0.85

Tested by

no test coverage detected