[compiler-rt] Fix the calculation of fragmented bytes in secondary (PR #66422)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 14 12:28:56 PDT 2023
https://github.com/ChiaHungDuan created https://github.com/llvm/llvm-project/pull/66422:
None
>From 66502478aa8074d4a18388d73d4c8cac6096f2b3 Mon Sep 17 00:00:00 2001
From: Chia-hung Duan <chiahungduan at google.com>
Date: Wed, 13 Sep 2023 00:06:37 +0000
Subject: [PATCH] Fix the calculation of fragmented bytes in secondary
---
compiler-rt/lib/scudo/standalone/secondary.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/compiler-rt/lib/scudo/standalone/secondary.h b/compiler-rt/lib/scudo/standalone/secondary.h
index 01a4108a75f368b..d0890d1c5e2d3d5 100644
--- a/compiler-rt/lib/scudo/standalone/secondary.h
+++ b/compiler-rt/lib/scudo/standalone/secondary.h
@@ -594,7 +594,7 @@ void *MapAllocator<Config>::allocate(const Options &Options, uptr Size,
ScopedLock L(Mutex);
InUseBlocks.push_back(H);
AllocatedBytes += H->CommitSize;
- FragmentedBytes += reinterpret_cast<uptr>(H) - H->CommitBase;
+ FragmentedBytes += H->MemMap.getCapacity() - H->CommitSize;
NumberOfAllocs++;
Stats.add(StatAllocated, H->CommitSize);
Stats.add(StatMapped, H->MemMap.getCapacity());
@@ -668,7 +668,7 @@ void *MapAllocator<Config>::allocate(const Options &Options, uptr Size,
ScopedLock L(Mutex);
InUseBlocks.push_back(H);
AllocatedBytes += CommitSize;
- FragmentedBytes += reinterpret_cast<uptr>(H) - H->CommitBase;
+ FragmentedBytes += H->MemMap.getCapacity() - CommitSize;
if (LargestSize < CommitSize)
LargestSize = CommitSize;
NumberOfAllocs++;
@@ -687,7 +687,7 @@ void MapAllocator<Config>::deallocate(const Options &Options, void *Ptr)
ScopedLock L(Mutex);
InUseBlocks.remove(H);
FreedBytes += CommitSize;
- FragmentedBytes -= reinterpret_cast<uptr>(H) - H->CommitBase;
+ FragmentedBytes -= H->MemMap.getCapacity() - CommitSize;
NumberOfFrees++;
Stats.sub(StatAllocated, CommitSize);
Stats.sub(StatMapped, H->MemMap.getCapacity());
More information about the llvm-commits
mailing list