Commit 0c428a36 authored by Anton Bikineev's avatar Anton Bikineev Committed by Chromium LUCI CQ

PCScan: Avoid purging PA memory if PCScan task is scheduled

This fixes the race between PCScan and memory reclaimer (if reclaimer
decommits a page that was snapshotted before running a PCScan task, the
scanner will hit a page fault).

Bug: 1156011
Change-Id: I90a9655962f4cc0849165287b3c8199d7401d386
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2579911Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/master@{#835117}
parent 36bfbbb1
......@@ -614,6 +614,12 @@ void PartitionRoot<thread_safe>::PurgeMemory(int flags) {
{
ScopedGuard guard{lock_};
// Avoid purging if there is PCScan task currently scheduled. Since pcscan
// takes snapshot of all allocated pages, decommitting pages here (even
// under the lock) is racy.
// TODO(bikineev): Consider rescheduling the purging after PCScan.
if (PCScan::Instance().IsInProgress())
return;
if (flags & PartitionPurgeDecommitEmptySlotSpans)
DecommitEmptySlotSpans();
if (flags & PartitionPurgeDiscardUnusedSystemPages) {
......
......@@ -73,6 +73,10 @@ class BASE_EXPORT PCScan final {
void ClearRootsForTesting();
bool IsInProgress() const {
return in_progress_.load(std::memory_order_relaxed);
}
private:
class PCScanTask;
class PCScanThread;
......
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