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

base/allocator: Record a synthetic field trial: PAE-and-PCScan

In order to perform a tri-arm experiment of
PartitionAlloc-Everywhere and PCScan, adds a new synthetic
field trial.

Bug: 1121427
Change-Id: I70a1b8384cd066cea2d92000364877e965d6b82c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2573560
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: default avatarBartek Nowierski <bartekn@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834706}
parent 76bc9679
...@@ -25,5 +25,11 @@ const Feature kPartitionAllocGigaCage{"PartitionAllocGigaCage32bit", ...@@ -25,5 +25,11 @@ const Feature kPartitionAllocGigaCage{"PartitionAllocGigaCage32bit",
const Feature kPartitionAllocPCScan{"PartitionAllocPCScan", const Feature kPartitionAllocPCScan{"PartitionAllocPCScan",
FEATURE_DISABLED_BY_DEFAULT}; FEATURE_DISABLED_BY_DEFAULT};
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
// If enabled, PCScan is turned on only for the browser's malloc partition.
const Feature kPartitionAllocPCScanBrowserOnly{
"PartitionAllocPCScanBrowserOnly", FEATURE_DISABLED_BY_DEFAULT};
#endif
} // namespace features } // namespace features
} // namespace base } // namespace base
...@@ -27,6 +27,9 @@ namespace features { ...@@ -27,6 +27,9 @@ namespace features {
extern const BASE_EXPORT Feature kPartitionAllocGigaCage; extern const BASE_EXPORT Feature kPartitionAllocGigaCage;
extern const BASE_EXPORT Feature kPartitionAllocPCScan; extern const BASE_EXPORT Feature kPartitionAllocPCScan;
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
extern const BASE_EXPORT Feature kPartitionAllocPCScanBrowserOnly;
#endif
ALWAYS_INLINE bool IsPartitionAllocGigaCageEnabled() { ALWAYS_INLINE bool IsPartitionAllocGigaCageEnabled() {
#if defined(PA_HAS_64_BITS_POINTERS) && defined(OS_WIN) #if defined(PA_HAS_64_BITS_POINTERS) && defined(OS_WIN)
...@@ -61,12 +64,23 @@ ALWAYS_INLINE bool IsPartitionAllocGigaCageEnabled() { ...@@ -61,12 +64,23 @@ ALWAYS_INLINE bool IsPartitionAllocGigaCageEnabled() {
} }
ALWAYS_INLINE bool IsPartitionAllocPCScanEnabled() { ALWAYS_INLINE bool IsPartitionAllocPCScanEnabled() {
#if !defined(PA_HAS_64_BITS_POINTERS) #if defined(PA_HAS_64_BITS_POINTERS)
return false;
#endif // !PA_HAS_64_BITS_POINTERS
return FeatureList::IsEnabled(kPartitionAllocPCScan); return FeatureList::IsEnabled(kPartitionAllocPCScan);
#else // PA_HAS_64_BITS_POINTERS
return false;
#endif
} }
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
ALWAYS_INLINE bool IsPartitionAllocPCScanBrowserOnlyEnabled() {
#if defined(PA_HAS_64_BITS_POINTERS)
return FeatureList::IsEnabled(kPartitionAllocPCScanBrowserOnly);
#else // PA_HAS_64_BITS_POINTERS
return false;
#endif
}
#endif
} // namespace features } // namespace features
} // namespace base } // namespace base
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <cmath> #include <cmath>
#include <string> #include <string>
#include "base/allocator/partition_allocator/partition_alloc_features.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/cpu.h" #include "base/cpu.h"
...@@ -546,11 +547,14 @@ void ChromeBrowserMainExtraPartsMetrics::PreBrowserStart() { ...@@ -546,11 +547,14 @@ void ChromeBrowserMainExtraPartsMetrics::PreBrowserStart() {
#endif // defined(OS_WIN) #endif // defined(OS_WIN)
// Records whether or not PartitionAlloc is used as the default allocator. // Records whether or not PartitionAlloc is used as the default allocator,
// plus whether or not PCScan is enabled.
ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial( ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial(
"PartitionAllocEverywhere", "PartitionAllocEverywhereAndPCScan",
#if BUILDFLAG(USE_PARTITION_ALLOC_EVERYWHERE) #if BUILDFLAG(USE_PARTITION_ALLOC_EVERYWHERE)
"Enabled" base::features::IsPartitionAllocPCScanBrowserOnlyEnabled()
? "EnabledWithPCScan"
: "EnabledWithoutPCScan"
#else #else
"Disabled" "Disabled"
#endif #endif
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "base/allocator/allocator_extension.h" #include "base/allocator/allocator_extension.h"
#include "base/allocator/allocator_shim.h" #include "base/allocator/allocator_shim.h"
#include "base/allocator/buildflags.h" #include "base/allocator/buildflags.h"
#include "base/allocator/partition_allocator/partition_alloc_features.h"
#include "base/at_exit.h" #include "base/at_exit.h"
#include "base/base_switches.h" #include "base/base_switches.h"
#include "base/bind.h" #include "base/bind.h"
...@@ -246,12 +247,9 @@ void EnablePCScanForMallocPartitionsIfNeeded() { ...@@ -246,12 +247,9 @@ void EnablePCScanForMallocPartitionsIfNeeded() {
} }
void EnablePCScanForMallocPartitionsInBrowserProcessIfNeeded() { void EnablePCScanForMallocPartitionsInBrowserProcessIfNeeded() {
static const base::Feature kPartitionAllocPCScanBrowserOnly{
"PartitionAllocPCScanBrowserOnly", base::FEATURE_DISABLED_BY_DEFAULT};
(void)kPartitionAllocPCScanBrowserOnly;
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) #if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
CHECK(base::FeatureList::GetInstance()); CHECK(base::FeatureList::GetInstance());
if (base::FeatureList::IsEnabled(kPartitionAllocPCScanBrowserOnly)) { if (base::features::IsPartitionAllocPCScanBrowserOnlyEnabled()) {
base::allocator::EnablePCScan(); base::allocator::EnablePCScan();
} }
#endif #endif
......
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