[compiler-rt] b3e4283 - [scudo] Fix insufficient blocks when pushing BatchClass blocks
Chia-hung Duan via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 26 15:44:09 PDT 2023
Author: Chia-hung Duan
Date: 2023-06-26T22:37:58Z
New Revision: b3e42830aba036e8ef1a37734872dba73ee750e7
URL: https://github.com/llvm/llvm-project/commit/b3e42830aba036e8ef1a37734872dba73ee750e7
DIFF: https://github.com/llvm/llvm-project/commit/b3e42830aba036e8ef1a37734872dba73ee750e7.diff
LOG: [scudo] Fix insufficient blocks when pushing BatchClass blocks
`populateFreeListAndPopBatch` may return batch with single block. Merge
it with the reported free blocks and enqueue them together.
Reviewed By: cferris, fabio-d
Differential Revision: https://reviews.llvm.org/D153787
Added:
Modified:
compiler-rt/lib/scudo/standalone/primary64.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/scudo/standalone/primary64.h b/compiler-rt/lib/scudo/standalone/primary64.h
index 43a977b19628f..ab75f19d8a18d 100644
--- a/compiler-rt/lib/scudo/standalone/primary64.h
+++ b/compiler-rt/lib/scudo/standalone/primary64.h
@@ -224,9 +224,24 @@ template <typename Config> class SizeClassAllocator64 {
B == nullptr;
if (UNLIKELY(!NeedToRefill)) {
if (UNLIKELY(B)) {
+ // Even though we always populate the blocks with the number which
+ // is multiple of TransferBatch::getMaxCached() , the top
+ // `TransferBatch` from the freelist may still have fewer elements
+ // than the size of TransferBatch::getMaxCached() because we
+ // always fill up the top `TransferBatch` first when it's not
+ // full.
+ // When this happens, simply push the block in `TransferBatch` and
+ // `Array` together.
+ if (UNLIKELY(B->getCount() == 1)) {
+ DCHECK_EQ(Size, 1U);
+ B->appendFromArray(Array, 1U);
+ Size = 0;
+ }
pushBlocksImpl(C, SizeClassMap::BatchClassId, Region,
B->getRawArray(), B->getCount());
CHECK(!Region->FreeListInfo.BlockList.empty());
+ if (Size == 0)
+ return;
}
pushBlocksImpl(C, SizeClassMap::BatchClassId, Region, Array, Size);
return;
More information about the llvm-commits
mailing list