From 1c0e96835da7c1257eff50ede824ea966dd301f5 Mon Sep 17 00:00:00 2001 From: sadafebrahimi Date: Tue, 4 Nov 2025 22:22:45 +0000 Subject: [PATCH] [scudo] Add last release time info to getStats Knowing when the last page release happened can help us figure out if the page release is skipped or not. --- compiler-rt/lib/scudo/standalone/primary64.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/compiler-rt/lib/scudo/standalone/primary64.h b/compiler-rt/lib/scudo/standalone/primary64.h index 747b1a2233d32..4756f6fbfde4c 100644 --- a/compiler-rt/lib/scudo/standalone/primary64.h +++ b/compiler-rt/lib/scudo/standalone/primary64.h @@ -1146,17 +1146,27 @@ void SizeClassAllocator64::getStats(ScopedString *Str, uptr ClassId, BytesInFreeList - Region->ReleaseInfo.BytesInFreeListAtLastCheckpoint; } const uptr TotalChunks = Region->MemMapInfo.AllocatedUser / BlockSize; + const s32 IntervalMs = atomic_load_relaxed(&ReleaseToOsIntervalMs); + const u64 IntervalNs = static_cast(IntervalMs) * 1000000; + const u64 CurTimeNs = getMonotonicTime(); + const u64 DiffSinceLastReleaseNs = + CurTimeNs - Region->ReleaseInfo.LastReleaseAtNs; + Str->append( "%s %02zu (%6zu): mapped: %6zuK popped: %7zu pushed: %7zu " "inuse: %6zu total: %6zu releases attempted: %6zu last " "released: %6zuK latest pushed bytes: %6zuK region: 0x%zx " - "(0x%zx)\n", + "(0x%zx) ", Region->Exhausted ? "E" : " ", ClassId, getSizeByClassId(ClassId), Region->MemMapInfo.MappedUser >> 10, Region->FreeListInfo.PoppedBlocks, Region->FreeListInfo.PushedBlocks, InUseBlocks, TotalChunks, Region->ReleaseInfo.NumReleasesAttempted, Region->ReleaseInfo.LastReleasedBytes >> 10, RegionPushedBytesDelta >> 10, Region->RegionBeg, getRegionBaseByClassId(ClassId)); + if (DiffSinceLastReleaseNs > IntervalNs) + Str->append("Last page release > ReleaseToOsInterval\n"); + else + Str->append("Last page release <= ReleaseToOsInterval\n"); } template