Commit 01e77f25 authored by Vlad Tsyrklevich's avatar Vlad Tsyrklevich Committed by Commit Bot

GWP-ASan: Reduce RSS on macOS

Currently we mark unused pages inaccessible but don't release their
memory back to the OS. Release it so that we can make use of a large
quarantine without incurring memory overhead. This showed a ~2-4%
regression on a microbenchmark that looped allocating and
deallocating.

Bug: 912286
Change-Id: Iab5fd441071ef0fc45aa793708b886c7fe864158
Reviewed-on: https://chromium-review.googlesource.com/c/1471331
Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
Auto-Submit: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
Reviewed-by: default avatarVitaly Buka <vitalybuka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#632020}
parent 3bafc4d9
......@@ -30,8 +30,12 @@ void GuardedPageAllocator::MarkPageReadWrite(void* ptr) {
}
void GuardedPageAllocator::MarkPageInaccessible(void* ptr) {
int err = mprotect(ptr, state_.page_size, PROT_NONE);
PCHECK(err == 0) << "mprotect";
// mmap() a PROT_NONE page over the address to release it to the system, if
// we used mprotect() here the system would count pages in the quarantine
// against the RSS.
void* err = mmap(ptr, state_.page_size, PROT_NONE,
MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
PCHECK(err == ptr) << "mmap";
}
} // namespace internal
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment