Commit e7bad2c5 authored by Bartek Nowierski's avatar Bartek Nowierski Committed by Chromium LUCI CQ

[PA] Purge thread cache before other purgers kick in, but after PCScan

Change-Id: Iad90f5b80ec9effdb9737568ef83a8e8676ae31f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2563382
Commit-Queue: Bartek Nowierski <bartekn@chromium.org>
Reviewed-by: default avatarBenoit L <lizeb@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Auto-Submit: Bartek Nowierski <bartekn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832315}
parent 8cb8ef61
...@@ -596,6 +596,16 @@ void* PartitionRoot<thread_safe>::ReallocFlags(int flags, ...@@ -596,6 +596,16 @@ void* PartitionRoot<thread_safe>::ReallocFlags(int flags,
template <bool thread_safe> template <bool thread_safe>
void PartitionRoot<thread_safe>::PurgeMemory(int flags) { void PartitionRoot<thread_safe>::PurgeMemory(int flags) {
// PCScan quarantines freed slots. Trigger the scan first to let it call
// FreeNoHooksImmediate on slots that pass the quarantine.
//
// In turn, FreeNoHooksImmediate may add slots to thread cache. Purge it next
// so that the slots are actually freed. (This is done synchronously only for
// the current thread.)
//
// Lastly decommit empty slot spans and lastly try to discard unused pages at
// the end of the remaining active slots.
// TODO(chromium:1129751): Change to LIKELY once PCScan is enabled by default. // TODO(chromium:1129751): Change to LIKELY once PCScan is enabled by default.
if (UNLIKELY(IsScanEnabled())) { if (UNLIKELY(IsScanEnabled())) {
if (flags & PartitionPurgeForceAllFreed) if (flags & PartitionPurgeForceAllFreed)
...@@ -603,6 +613,10 @@ void PartitionRoot<thread_safe>::PurgeMemory(int flags) { ...@@ -603,6 +613,10 @@ void PartitionRoot<thread_safe>::PurgeMemory(int flags) {
else else
PCScan::Instance().PerformScanIfNeeded(PCScan::InvocationMode::kBlocking); PCScan::Instance().PerformScanIfNeeded(PCScan::InvocationMode::kBlocking);
} }
if (with_thread_cache)
internal::ThreadCacheRegistry::Instance().PurgeAll();
{ {
ScopedGuard guard{lock_}; ScopedGuard guard{lock_};
if (flags & PartitionPurgeDecommitEmptySlotSpans) if (flags & PartitionPurgeDecommitEmptySlotSpans)
...@@ -615,9 +629,6 @@ void PartitionRoot<thread_safe>::PurgeMemory(int flags) { ...@@ -615,9 +629,6 @@ void PartitionRoot<thread_safe>::PurgeMemory(int flags) {
} }
} }
} }
if (with_thread_cache)
internal::ThreadCacheRegistry::Instance().PurgeAll();
} }
template <bool thread_safe> template <bool thread_safe>
......
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