[compiler-rt] 4cf35a8 - [scudo] Secondary Cache Dump
Chia-hung Duan via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 26 15:44:12 PDT 2023
Author: fernandosalas
Date: 2023-06-26T22:41:19Z
New Revision: 4cf35a85c77db42b524459fe019a34c7306ca359
URL: https://github.com/llvm/llvm-project/commit/4cf35a85c77db42b524459fe019a34c7306ca359
DIFF: https://github.com/llvm/llvm-project/commit/4cf35a85c77db42b524459fe019a34c7306ca359.diff
LOG: [scudo] Secondary Cache Dump
Dumped some basic info about what is being cached and about the cache
itself. Output of test below:
...
Stats: MapAllocatorCache: EntriesCount: 33, MaxEntriesCount: 64, MaxEntrySize: 1048576
StartBlockAddress: 0x6d342c1000, EndBlockAddress: 0x6d342d2000, BlockSize: 69632
StartBlockAddress: 0x6fc45ff000, EndBlockAddress: 0x6fc462f000, BlockSize: 196608
...
Reviewed By: Chia-hungDuan
Differential Revision: https://reviews.llvm.org/D153483
Added:
Modified:
compiler-rt/lib/scudo/standalone/secondary.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/scudo/standalone/secondary.h b/compiler-rt/lib/scudo/standalone/secondary.h
index a259cb71e164c..226616cbda312 100644
--- a/compiler-rt/lib/scudo/standalone/secondary.h
+++ b/compiler-rt/lib/scudo/standalone/secondary.h
@@ -93,6 +93,10 @@ template <typename Config> class MapAllocatorNoCache {
// Not supported by the Secondary Cache, but not an error either.
return true;
}
+
+ void getStats(UNUSED ScopedString *Str) {
+ Str->append("Secondary Cache Disabled\n");
+ }
};
static const uptr MaxUnusedCachePages = 4U;
@@ -131,6 +135,21 @@ template <typename T> class NonZeroLengthArray<T, 0> {
template <typename Config> class MapAllocatorCache {
public:
using CacheConfig = typename Config::Secondary::Cache;
+
+ void getStats(ScopedString *Str) {
+ ScopedLock L(Mutex);
+ Str->append("Stats: MapAllocatorCache: EntriesCount: %d, "
+ "MaxEntriesCount: %u, MaxEntrySize: %zu\n",
+ EntriesCount, atomic_load_relaxed(&MaxEntriesCount),
+ atomic_load_relaxed(&MaxEntrySize));
+ for (CachedBlock Entry : Entries) {
+ Str->append("StartBlockAddress: 0x%zx, EndBlockAddress: 0x%zx, "
+ "BlockSize: %zu\n",
+ Entry.CommitBase, (Entry.CommitBase + Entry.CommitSize),
+ Entry.CommitSize);
+ }
+ }
+
// Ensure the default maximum specified fits the array.
static_assert(CacheConfig::DefaultMaxEntriesCount <=
CacheConfig::EntriesArraySize,
@@ -433,8 +452,6 @@ template <typename Config> class MapAllocator {
return getBlockEnd(Ptr) - reinterpret_cast<uptr>(Ptr);
}
- void getStats(ScopedString *Str);
-
void disable() NO_THREAD_SAFETY_ANALYSIS {
Mutex.lock();
Cache.disable();
@@ -466,6 +483,8 @@ template <typename Config> class MapAllocator {
void unmapTestOnly() { Cache.unmapTestOnly(); }
+ void getStats(ScopedString *Str);
+
private:
typename Config::Secondary::template CacheT<Config> Cache;
@@ -621,6 +640,7 @@ void MapAllocator<Config>::getStats(ScopedString *Str) EXCLUDES(Mutex) {
NumberOfAllocs, AllocatedBytes >> 10, NumberOfFrees,
FreedBytes >> 10, NumberOfAllocs - NumberOfFrees,
(AllocatedBytes - FreedBytes) >> 10, LargestSize >> 20);
+ Cache.getStats(Str);
}
} // namespace scudo
More information about the llvm-commits
mailing list