diff options
author | Chia-hung Duan <chiahungduan@google.com> | 2023-07-10 21:29:16 +0000 |
---|---|---|
committer | Chia-hung Duan <chiahungduan@google.com> | 2023-07-10 21:29:18 +0000 |
commit | 316ca42a65ce0078ba3380f135ced8f36859dfa5 (patch) | |
tree | ab900f4c2c4f8c3ddbb1ad44f1273add1d2350e7 /compiler-rt | |
parent | dbd47c4489b1680b0753c30745588c6248a8b448 (diff) | |
download | llvm-316ca42a65ce0078ba3380f135ced8f36859dfa5.zip llvm-316ca42a65ce0078ba3380f135ced8f36859dfa5.tar.gz llvm-316ca42a65ce0078ba3380f135ced8f36859dfa5.tar.bz2 |
[scudo] Print PushedBytesDelta in getStats()
This gives a hint of potential bytes to release. Also remove the RSS
which is not supported yet. Will add it back when it's available.
Reviewed By: cferris
Differential Revision: https://reviews.llvm.org/D154551
Diffstat (limited to 'compiler-rt')
-rw-r--r-- | compiler-rt/lib/scudo/standalone/primary32.h | 21 | ||||
-rw-r--r-- | compiler-rt/lib/scudo/standalone/primary64.h | 37 |
2 files changed, 38 insertions, 20 deletions
diff --git a/compiler-rt/lib/scudo/standalone/primary32.h b/compiler-rt/lib/scudo/standalone/primary32.h index 0fbc02d..1d8a34e 100644 --- a/compiler-rt/lib/scudo/standalone/primary32.h +++ b/compiler-rt/lib/scudo/standalone/primary32.h @@ -307,7 +307,7 @@ public: for (uptr I = 0; I < NumClasses; I++) { SizeClassInfo *Sci = getSizeClassInfo(I); ScopedLock L(Sci->Mutex); - getStats(Str, I, Sci, 0); + getStats(Str, I, Sci); } } @@ -832,19 +832,28 @@ private: return true; } - void getStats(ScopedString *Str, uptr ClassId, SizeClassInfo *Sci, uptr Rss) + void getStats(ScopedString *Str, uptr ClassId, SizeClassInfo *Sci) REQUIRES(Sci->Mutex) { if (Sci->AllocatedUser == 0) return; + const uptr BlockSize = getSizeByClassId(ClassId); const uptr InUse = Sci->FreeListInfo.PoppedBlocks - Sci->FreeListInfo.PushedBlocks; - const uptr AvailableChunks = Sci->AllocatedUser / getSizeByClassId(ClassId); + const uptr BytesInFreeList = Sci->AllocatedUser - InUse * BlockSize; + uptr PushedBytesDelta = 0; + if (BytesInFreeList >= Sci->ReleaseInfo.BytesInFreeListAtLastCheckpoint) { + PushedBytesDelta = + BytesInFreeList - Sci->ReleaseInfo.BytesInFreeListAtLastCheckpoint; + } + const uptr AvailableChunks = Sci->AllocatedUser / BlockSize; Str->append(" %02zu (%6zu): mapped: %6zuK popped: %7zu pushed: %7zu " - "inuse: %6zu avail: %6zu rss: %6zuK releases: %6zu\n", + "inuse: %6zu avail: %6zu releases: %6zu last released: %6zuK " + "latest pushed bytes: %6zuK\n", ClassId, getSizeByClassId(ClassId), Sci->AllocatedUser >> 10, Sci->FreeListInfo.PoppedBlocks, Sci->FreeListInfo.PushedBlocks, - InUse, AvailableChunks, Rss >> 10, - Sci->ReleaseInfo.RangesReleased); + InUse, AvailableChunks, Sci->ReleaseInfo.RangesReleased, + Sci->ReleaseInfo.LastReleasedBytes >> 10, + PushedBytesDelta >> 10); } NOINLINE uptr releaseToOSMaybe(SizeClassInfo *Sci, uptr ClassId, diff --git a/compiler-rt/lib/scudo/standalone/primary64.h b/compiler-rt/lib/scudo/standalone/primary64.h index 0abed6a..c9958ea 100644 --- a/compiler-rt/lib/scudo/standalone/primary64.h +++ b/compiler-rt/lib/scudo/standalone/primary64.h @@ -359,7 +359,7 @@ public: RegionInfo *Region = getRegionInfo(I); ScopedLock L1(Region->MMLock); ScopedLock L2(Region->FLLock); - getStats(Str, I, Region, 0); + getStats(Str, I, Region); } } @@ -952,24 +952,33 @@ private: return B; } - void getStats(ScopedString *Str, uptr ClassId, RegionInfo *Region, uptr Rss) + void getStats(ScopedString *Str, uptr ClassId, RegionInfo *Region) REQUIRES(Region->MMLock, Region->FLLock) { if (Region->MemMapInfo.MappedUser == 0) return; + const uptr BlockSize = getSizeByClassId(ClassId); const uptr InUse = Region->FreeListInfo.PoppedBlocks - Region->FreeListInfo.PushedBlocks; - const uptr TotalChunks = - Region->MemMapInfo.AllocatedUser / getSizeByClassId(ClassId); - Str->append("%s %02zu (%6zu): mapped: %6zuK popped: %7zu pushed: %7zu " - "inuse: %6zu total: %6zu rss: %6zuK releases: %6zu last " - "released: %6zuK region: 0x%zx (0x%zx)\n", - Region->Exhausted ? "F" : " ", ClassId, - getSizeByClassId(ClassId), Region->MemMapInfo.MappedUser >> 10, - Region->FreeListInfo.PoppedBlocks, - Region->FreeListInfo.PushedBlocks, InUse, TotalChunks, - Rss >> 10, Region->ReleaseInfo.RangesReleased, - Region->ReleaseInfo.LastReleasedBytes >> 10, Region->RegionBeg, - getRegionBaseByClassId(ClassId)); + const uptr BytesInFreeList = + Region->MemMapInfo.AllocatedUser - InUse * BlockSize; + uptr RegionPushedBytesDelta = 0; + if (BytesInFreeList >= + Region->ReleaseInfo.BytesInFreeListAtLastCheckpoint) { + RegionPushedBytesDelta = + BytesInFreeList - Region->ReleaseInfo.BytesInFreeListAtLastCheckpoint; + } + const uptr TotalChunks = Region->MemMapInfo.AllocatedUser / BlockSize; + Str->append( + "%s %02zu (%6zu): mapped: %6zuK popped: %7zu pushed: %7zu " + "inuse: %6zu total: %6zu releases: %6zu last " + "released: %6zuK latest pushed bytes: %6zuK region: 0x%zx (0x%zx)\n", + Region->Exhausted ? "F" : " ", ClassId, getSizeByClassId(ClassId), + Region->MemMapInfo.MappedUser >> 10, Region->FreeListInfo.PoppedBlocks, + Region->FreeListInfo.PushedBlocks, InUse, TotalChunks, + Region->ReleaseInfo.RangesReleased, + Region->ReleaseInfo.LastReleasedBytes >> 10, + RegionPushedBytesDelta >> 10, Region->RegionBeg, + getRegionBaseByClassId(ClassId)); } NOINLINE uptr releaseToOSMaybe(RegionInfo *Region, uptr ClassId, |