Skip to content

Commit 76151c4

Browse files
authored
Revert "[scudo] Fix the logic of MaxAllowedFragmentedPages" (llvm#108130)
Reverts llvm#107927 We are supposed to check the MaxAllowedFragmentedPages instead.
1 parent 5773adb commit 76151c4

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

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

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,13 @@ namespace {
7272
struct CachedBlock {
7373
static constexpr u16 CacheIndexMax = UINT16_MAX;
7474
static constexpr u16 InvalidEntry = CacheIndexMax;
75-
// We allow a certain amount of fragmentation and part of the fragmented bytes
76-
// will be released by `releaseAndZeroPagesToOS()`. This increases the chance
77-
// of cache hit rate and reduces the overhead to the RSS at the same time. See
78-
// more details in the `MapAllocatorCache::retrieve()` section.
79-
//
80-
// We arrived at this default value after noticing that mapping in larger
81-
// memory regions performs better than releasing memory and forcing a cache
82-
// hit. According to the data, it suggests that beyond 4 pages, the release
83-
// execution time is longer than the map execution time. In this way,
84-
// the default is dependent on the platform.
75+
// * MaxReleasedCachePages default is currently 4
76+
// - We arrived at this value after noticing that mapping
77+
// in larger memory regions performs better than releasing
78+
// memory and forcing a cache hit. According to the data,
79+
// it suggests that beyond 4 pages, the release execution time is
80+
// longer than the map execution time. In this way, the default
81+
// is dependent on the platform.
8582
static constexpr uptr MaxReleasedCachePages = 4U;
8683

8784
uptr CommitBase = 0;
@@ -728,14 +725,8 @@ MapAllocator<Config>::tryAllocateFromCache(const Options &Options, uptr Size,
728725
uptr EntryHeaderPos;
729726
uptr MaxAllowedFragmentedPages = MaxUnreleasedCachePages;
730727

731-
if (LIKELY(!useMemoryTagging<Config>(Options))) {
728+
if (UNLIKELY(useMemoryTagging<Config>(Options)))
732729
MaxAllowedFragmentedPages += CachedBlock::MaxReleasedCachePages;
733-
} else {
734-
// TODO: Enable MaxReleasedCachePages may result in pages for an entry being
735-
// partially released and it erases the tag of those pages as well. To
736-
// support this feature for MTE, we need to tag those pages again.
737-
DCHECK_EQ(CachedBlock::MaxReleasedCachePages, 0U);
738-
}
739730

740731
Entry = Cache.retrieve(MaxAllowedFragmentedPages, Size, Alignment,
741732
getHeadersSize(), EntryHeaderPos);

0 commit comments

Comments
 (0)