This is an archive of the discontinued LLVM Phabricator instance.

[scudo] Allow pushing single block to the freelist of BatchClass
ClosedPublic

Authored by Chia-hungDuan on Jun 21 2023, 7:38 PM.

Details

Summary

This CL removes the restriction that pushing blocks into BatchClassId
can only be done when freelist is not empty. Without this constraint,
BatchClassId is also available for gathering blocks into groups.

Diff Detail

Event Timeline

Chia-hungDuan created this revision.Jun 21 2023, 7:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 21 2023, 7:38 PM
Chia-hungDuan requested review of this revision.Jun 21 2023, 7:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 21 2023, 7:38 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
Chia-hungDuan planned changes to this revision.Jun 22 2023, 6:35 PM

It may miss one block from BatchClass in multithreads, I'm looking into it.

Fix missing one block in BatchClass

cferris requested changes to this revision.Jun 28 2023, 7:34 PM
cferris added inline comments.
compiler-rt/lib/scudo/standalone/primary32.h
143–144

Should this be in an else block?

Also, would it be useful to rewrite this as:

if (LIKELY(!BG.Batches.empty())

for (...)

else

++TotalBlocks;

I don't know if most batches are empty or not, so that LIKELY might be wrong.

462

This was memory in the original comment and make a bit more sense. Or did you mean use a single extra block here?

This revision now requires changes to proceed.Jun 28 2023, 7:34 PM

Address review comment

Chia-hungDuan added inline comments.Jun 28 2023, 10:38 PM
compiler-rt/lib/scudo/standalone/primary32.h
143–144

I was trying to make it less indent. It does look better to put it in an else block.

Done.

462

I mean the single extra block here.

Suppose a TransferBatch records 10 free blocks of BatchClass, A TransferBatch used in the freelist of BatchClass records 9 blocks + itself. Instead of recording 10 blocks excluding itself.

cferris accepted this revision.Jun 29 2023, 3:23 PM

LGTM.

This revision is now accepted and ready to land.Jun 29 2023, 3:23 PM