Commit 6858190c authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

base/allocator: Enable PAMemoryReclaimer for PA-Everywhere

Runs PartitionAllocMemoryReclaimer for the PartitionRoot used by
ShimMalloc, etc. (partition alloc as malloc).

Change-Id: I636b7b2ca4fdda7de7b3a178e6193dea7c0605cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2532476Reviewed-by: default avatarWill Harris <wfh@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Reviewed-by: default avatarBenoit L <lizeb@chromium.org>
Reviewed-by: default avatarBartek Nowierski <bartekn@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829063}
parent a0ed9bde
...@@ -151,6 +151,10 @@ BASE_EXPORT void RemoveAllocatorDispatchForTesting(AllocatorDispatch* dispatch); ...@@ -151,6 +151,10 @@ BASE_EXPORT void RemoveAllocatorDispatchForTesting(AllocatorDispatch* dispatch);
BASE_EXPORT void InitializeAllocatorShim(); BASE_EXPORT void InitializeAllocatorShim();
#endif // defined(OS_APPLE) #endif // defined(OS_APPLE)
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
BASE_EXPORT void EnablePartitionAllocMemoryReclaimer();
#endif
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) #if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
BASE_EXPORT void EnablePCScanIfNeeded(); BASE_EXPORT void EnablePCScanIfNeeded();
#endif #endif
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "base/allocator/allocator_shim_default_dispatch_to_partition_alloc.h" #include "base/allocator/allocator_shim_default_dispatch_to_partition_alloc.h"
#include "base/allocator/allocator_shim_internals.h" #include "base/allocator/allocator_shim_internals.h"
#include "base/allocator/partition_allocator/memory_reclaimer.h"
#include "base/allocator/partition_allocator/partition_alloc.h" #include "base/allocator/partition_allocator/partition_alloc.h"
#include "base/allocator/partition_allocator/partition_alloc_constants.h" #include "base/allocator/partition_allocator/partition_alloc_constants.h"
#include "base/allocator/partition_allocator/partition_alloc_features.h" #include "base/allocator/partition_allocator/partition_alloc_features.h"
...@@ -225,6 +226,17 @@ ThreadSafePartitionRoot* PartitionAllocMalloc::AlignedAllocator() { ...@@ -225,6 +226,17 @@ ThreadSafePartitionRoot* PartitionAllocMalloc::AlignedAllocator() {
namespace base { namespace base {
namespace allocator { namespace allocator {
void EnablePartitionAllocMemoryReclaimer() {
// Allocator() and AlignedAllocator() do not register their PartitionRoots to
// the memory reclaimer because the memory reclaimer allocates memory. Thus,
// the registration to the memory reclaimer should be done sometime later.
// This function will be called sometime appropriate after PartitionRoots are
// initialized.
PartitionAllocMemoryReclaimer::Instance()->RegisterPartition(Allocator());
PartitionAllocMemoryReclaimer::Instance()->RegisterPartition(
AlignedAllocator());
}
void EnablePCScanIfNeeded() { void EnablePCScanIfNeeded() {
if (!features::IsPartitionAllocPCScanEnabled()) if (!features::IsPartitionAllocPCScanEnabled())
return; return;
......
...@@ -695,6 +695,9 @@ int ContentMainRunnerImpl::Initialize(const ContentMainParams& params) { ...@@ -695,6 +695,9 @@ int ContentMainRunnerImpl::Initialize(const ContentMainParams& params) {
// overriding logic is working correctly. If not causes a hard crash, as its // overriding logic is working correctly. If not causes a hard crash, as its
// unexpected absence has security implications. // unexpected absence has security implications.
CHECK(base::allocator::IsAllocatorInitialized()); CHECK(base::allocator::IsAllocatorInitialized());
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
base::allocator::EnablePartitionAllocMemoryReclaimer();
#endif
#if defined(OS_POSIX) || defined(OS_FUCHSIA) #if defined(OS_POSIX) || defined(OS_FUCHSIA)
if (!process_type.empty()) { if (!process_type.empty()) {
......
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