Skip to content

Commit e425a55

Browse files
committed
[scudo] Mitigate the overhead in cache storing when MTE enabled
mapSecondary() requires two mmap calls and may impact the performance in some cases that use secondary allocator heavily. Only use setMemoryPermission to reduce the time in contention of memory system calls.
1 parent 9389b05 commit e425a55

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,18 +210,10 @@ template <typename Config> class MapAllocatorCache {
210210
Entry.MemMap = H->MemMap;
211211
Entry.Time = Time;
212212
if (useMemoryTagging<Config>(Options)) {
213-
if (Interval == 0 && !SCUDO_FUCHSIA) {
214-
// Release the memory and make it inaccessible at the same time by
215-
// creating a new MAP_NOACCESS mapping on top of the existing mapping.
216-
// Fuchsia does not support replacing mappings by creating a new mapping
217-
// on top so we just do the two syscalls there.
213+
if (Interval == 0)
218214
Entry.Time = 0;
219-
mapSecondary<Config>(Options, Entry.CommitBase, Entry.CommitSize,
220-
Entry.CommitBase, MAP_NOACCESS, Entry.MemMap);
221-
} else {
222-
Entry.MemMap.setMemoryPermission(Entry.CommitBase, Entry.CommitSize,
223-
MAP_NOACCESS);
224-
}
215+
Entry.MemMap.setMemoryPermission(Entry.CommitBase, Entry.CommitSize,
216+
MAP_NOACCESS);
225217
} else if (Interval == 0) {
226218
Entry.MemMap.releasePagesToOS(Entry.CommitBase, Entry.CommitSize);
227219
Entry.Time = 0;

0 commit comments

Comments
 (0)