This is an archive of the discontinued LLVM Phabricator instance.

[scudo] CanCache should use Size + HeadersSize instead of RoundedSize
ClosedPublic

Authored by Chia-hungDuan on Jul 28 2023, 4:31 PM.

Details

Summary

Cached block may have nearly aligned address for a certain alignment so
that we don't have to round up the size in advance. The rounding should
only happen at determing the availability of a cached block.

Diff Detail

Event Timeline

Chia-hungDuan created this revision.Jul 28 2023, 4:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 28 2023, 4:31 PM
Herald added subscribers: yaneury, Enna1. · View Herald Transcript
Chia-hungDuan requested review of this revision.Jul 28 2023, 4:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 28 2023, 4:31 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript

Just reviewed this again. canCache() may still want to consider the size of headers. Instead of using Size nor RoundedSize, Size + size-of-all-headers is more reasonable here.

Pass Size + HeadersSize instead.

cferris accepted this revision.Jul 28 2023, 8:42 PM

LGTM as long as I am correct about the one comment I left.

compiler-rt/lib/scudo/standalone/secondary.h
265

I presume you are passing in the HeadersSize to avoid calling getHeadersSize() again. Or to add tests for the function in the future.

If I'm wrong, let me know.

This revision is now accepted and ready to land.Jul 28 2023, 8:42 PM
Chia-hungDuan added inline comments.Jul 28 2023, 9:48 PM
compiler-rt/lib/scudo/standalone/secondary.h
265

Calling getHeadersSize() in Cache will be MapAllocator<Config>::getHeadersSize(). Instead of adding direct dependency with MapAllocator, I tend to inject the dependency by passing the size. (However, it's called MapAllocatorCache...)

No strong opinion here, let me know if you think calling getHeadersSize is better.

Chia-hungDuan retitled this revision from [scudo] CanCache should use Size instead of RoundedSize to [scudo] CanCache should use Size + HeadersSize instead of RoundedSize.Jul 28 2023, 9:49 PM

LGTM.

compiler-rt/lib/scudo/standalone/secondary.h
265

I think it's fine the way it is. Having the parameter does allow for testing that value in the future.