Avi Drissman | e4622aa | 2022-09-08 20:36:06 | [diff] [blame] | 1 | // Copyright 2020 The Chromium Authors |
Takashi Sakamoto | 0044f2f | 2020-06-04 04:19:16 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Takashi Sakamoto | 1b5312d | 2021-10-18 08:53:46 | [diff] [blame] | 5 | #include "base/allocator/partition_alloc_features.h" |
Takashi Sakamoto | 0044f2f | 2020-06-04 04:19:16 | [diff] [blame] | 6 | |
Mingyu Lei | f0cffc9 | 2023-10-18 18:20:07 | [diff] [blame] | 7 | #include "base/allocator/miracle_parameter.h" |
David Sanders | 6e70994 | 2022-04-05 06:49:26 | [diff] [blame] | 8 | #include "base/base_export.h" |
Takashi Sakamoto | 0044f2f | 2020-06-04 04:19:16 | [diff] [blame] | 9 | #include "base/feature_list.h" |
Takashi Sakamoto | 2e824dc | 2023-07-14 01:52:35 | [diff] [blame] | 10 | #include "base/features.h" |
Mingyu Lei | af2e0d9 | 2023-09-07 06:35:08 | [diff] [blame] | 11 | #include "base/metrics/field_trial_params.h" |
| 12 | #include "base/time/time.h" |
Benoit Lize | 2e4a8f6 | 2022-01-12 13:35:21 | [diff] [blame] | 13 | #include "build/build_config.h" |
Keishi Hattori | 50365c2 | 2023-04-27 08:09:23 | [diff] [blame] | 14 | #include "build/chromecast_buildflags.h" |
Arthur Sonzogni | fd39d61 | 2024-06-26 08:16:23 | [diff] [blame] | 15 | #include "partition_alloc/buildflags.h" |
Yuki Shiino | 985ab91e | 2024-03-14 07:20:46 | [diff] [blame] | 16 | #include "partition_alloc/partition_alloc_base/time/time.h" |
Kalvin Lee | e76b346 | 2024-05-15 00:47:13 | [diff] [blame] | 17 | #include "partition_alloc/partition_alloc_constants.h" |
Yuki Shiino | 985ab91e | 2024-03-14 07:20:46 | [diff] [blame] | 18 | #include "partition_alloc/partition_root.h" |
| 19 | #include "partition_alloc/shim/allocator_shim_dispatch_to_noop_on_free.h" |
| 20 | #include "partition_alloc/thread_cache.h" |
Takashi Sakamoto | 0044f2f | 2020-06-04 04:19:16 | [diff] [blame] | 21 | |
Peter Kasting | 811504a7 | 2025-01-09 03:18:50 | [diff] [blame] | 22 | namespace base::features { |
Takashi Sakamoto | 0044f2f | 2020-06-04 04:19:16 | [diff] [blame] | 23 | |
Takashi Sakamoto | 9f59021 | 2024-09-20 04:58:40 | [diff] [blame] | 24 | namespace { |
| 25 | |
| 26 | static constexpr char kPAFeatureEnabledProcessesStr[] = "enabled-processes"; |
| 27 | static constexpr char kBrowserOnlyStr[] = "browser-only"; |
| 28 | static constexpr char kBrowserAndRendererStr[] = "browser-and-renderer"; |
| 29 | static constexpr char kNonRendererStr[] = "non-renderer"; |
| 30 | static constexpr char kAllProcessesStr[] = "all-processes"; |
| 31 | |
| 32 | #if PA_CONFIG(ENABLE_SHADOW_METADATA) |
| 33 | static constexpr char kRendererOnlyStr[] = "renderer-only"; |
| 34 | static constexpr char kAllChildProcessesStr[] = "all-child-processes"; |
| 35 | #endif // PA_CONFIG(ENABLE_SHADOW_METADATA) |
| 36 | |
| 37 | } // namespace |
| 38 | |
Paul Semel | b0ce484 | 2022-09-28 08:09:53 | [diff] [blame] | 39 | BASE_FEATURE(kPartitionAllocUnretainedDanglingPtr, |
| 40 | "PartitionAllocUnretainedDanglingPtr", |
Paul Semel | 1c64c33 | 2023-06-13 12:52:39 | [diff] [blame] | 41 | FEATURE_ENABLED_BY_DEFAULT); |
Paul Semel | b0ce484 | 2022-09-28 08:09:53 | [diff] [blame] | 42 | |
| 43 | constexpr FeatureParam<UnretainedDanglingPtrMode>::Option |
| 44 | kUnretainedDanglingPtrModeOption[] = { |
| 45 | {UnretainedDanglingPtrMode::kCrash, "crash"}, |
| 46 | {UnretainedDanglingPtrMode::kDumpWithoutCrashing, |
| 47 | "dump_without_crashing"}, |
| 48 | }; |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 49 | // Note: Do not use the prepared macro as of no need for a local cache. |
| 50 | constinit const FeatureParam<UnretainedDanglingPtrMode> |
Paul Semel | b0ce484 | 2022-09-28 08:09:53 | [diff] [blame] | 51 | kUnretainedDanglingPtrModeParam = { |
| 52 | &kPartitionAllocUnretainedDanglingPtr, |
| 53 | "mode", |
Paul Semel | dafc4e52 | 2024-03-07 15:11:48 | [diff] [blame] | 54 | UnretainedDanglingPtrMode::kCrash, |
Paul Semel | b0ce484 | 2022-09-28 08:09:53 | [diff] [blame] | 55 | &kUnretainedDanglingPtrModeOption, |
| 56 | }; |
| 57 | |
Kalvin Lee | 8529bdde | 2024-10-25 14:10:42 | [diff] [blame] | 58 | // Note: DPD conflicts with no-op `free()` (see |
| 59 | // `base::allocator::MakeFreeNoOp()`). No-op `free()` stands down in the |
| 60 | // presence of DPD, but hypothetically fully launching DPD should prompt |
| 61 | // a rethink of no-op `free()`. |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 62 | BASE_FEATURE(kPartitionAllocDanglingPtr, |
| 63 | "PartitionAllocDanglingPtr", |
Arthur Sonzogni | 62e877a | 2024-04-30 16:09:43 | [diff] [blame] | 64 | #if PA_BUILDFLAG(ENABLE_DANGLING_RAW_PTR_FEATURE_FLAG) |
mikt | 16433307 | 2024-02-15 14:25:13 | [diff] [blame] | 65 | FEATURE_ENABLED_BY_DEFAULT |
| 66 | #else |
| 67 | FEATURE_DISABLED_BY_DEFAULT |
| 68 | #endif |
| 69 | ); |
Arthur Sonzogni | f6e556d0 | 2023-02-21 10:09:05 | [diff] [blame] | 70 | |
Arthur Sonzogni | be6f013 | 2022-07-06 13:54:12 | [diff] [blame] | 71 | constexpr FeatureParam<DanglingPtrMode>::Option kDanglingPtrModeOption[] = { |
| 72 | {DanglingPtrMode::kCrash, "crash"}, |
Pâris | e90af2c | 2023-01-30 14:22:41 | [diff] [blame] | 73 | {DanglingPtrMode::kLogOnly, "log_only"}, |
Arthur Sonzogni | be6f013 | 2022-07-06 13:54:12 | [diff] [blame] | 74 | }; |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 75 | // Note: Do not use the prepared macro as of no need for a local cache. |
| 76 | constinit const FeatureParam<DanglingPtrMode> kDanglingPtrModeParam{ |
Arthur Sonzogni | be6f013 | 2022-07-06 13:54:12 | [diff] [blame] | 77 | &kPartitionAllocDanglingPtr, |
| 78 | "mode", |
| 79 | DanglingPtrMode::kCrash, |
| 80 | &kDanglingPtrModeOption, |
| 81 | }; |
Pâris | e90af2c | 2023-01-30 14:22:41 | [diff] [blame] | 82 | constexpr FeatureParam<DanglingPtrType>::Option kDanglingPtrTypeOption[] = { |
| 83 | {DanglingPtrType::kAll, "all"}, |
| 84 | {DanglingPtrType::kCrossTask, "cross_task"}, |
| 85 | }; |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 86 | // Note: Do not use the prepared macro as of no need for a local cache. |
| 87 | constinit const FeatureParam<DanglingPtrType> kDanglingPtrTypeParam{ |
Pâris | e90af2c | 2023-01-30 14:22:41 | [diff] [blame] | 88 | &kPartitionAllocDanglingPtr, |
| 89 | "type", |
| 90 | DanglingPtrType::kAll, |
| 91 | &kDanglingPtrTypeOption, |
| 92 | }; |
Arthur Sonzogni | be6f013 | 2022-07-06 13:54:12 | [diff] [blame] | 93 | |
Arthur Sonzogni | 62e877a | 2024-04-30 16:09:43 | [diff] [blame] | 94 | #if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) |
Benoit Lize | 006cfcb | 2021-03-29 16:18:52 | [diff] [blame] | 95 | // Use a larger maximum thread cache cacheable bucket size. |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 96 | BASE_FEATURE(kPartitionAllocLargeThreadCacheSize, |
| 97 | "PartitionAllocLargeThreadCacheSize", |
Bartek Nowierski | 4152aa6 | 2023-09-11 14:48:40 | [diff] [blame] | 98 | FEATURE_ENABLED_BY_DEFAULT); |
Benoit Lize | 006cfcb | 2021-03-29 16:18:52 | [diff] [blame] | 99 | |
Kalvin Lee | e76b346 | 2024-05-15 00:47:13 | [diff] [blame] | 100 | MIRACLE_PARAMETER_FOR_INT(GetPartitionAllocLargeThreadCacheSizeValue, |
| 101 | kPartitionAllocLargeThreadCacheSize, |
| 102 | "PartitionAllocLargeThreadCacheSizeValue", |
| 103 | ::partition_alloc::kThreadCacheLargeSizeThreshold) |
Mingyu Lei | d313bb7 | 2023-09-06 02:23:28 | [diff] [blame] | 104 | |
Mingyu Lei | f0cffc9 | 2023-10-18 18:20:07 | [diff] [blame] | 105 | MIRACLE_PARAMETER_FOR_INT( |
| 106 | GetPartitionAllocLargeThreadCacheSizeValueForLowRAMAndroid, |
| 107 | kPartitionAllocLargeThreadCacheSize, |
| 108 | "PartitionAllocLargeThreadCacheSizeValueForLowRAMAndroid", |
Kalvin Lee | e76b346 | 2024-05-15 00:47:13 | [diff] [blame] | 109 | ::partition_alloc::kThreadCacheDefaultSizeThreshold) |
Mingyu Lei | d313bb7 | 2023-09-06 02:23:28 | [diff] [blame] | 110 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 111 | BASE_FEATURE(kPartitionAllocLargeEmptySlotSpanRing, |
| 112 | "PartitionAllocLargeEmptySlotSpanRing", |
François Doray | 65df3e4 | 2024-12-13 21:06:44 | [diff] [blame] | 113 | #if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) |
Scott Violet | d802f82 | 2024-06-05 16:00:19 | [diff] [blame] | 114 | FEATURE_ENABLED_BY_DEFAULT); |
| 115 | #else |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 116 | FEATURE_DISABLED_BY_DEFAULT); |
Scott Violet | d802f82 | 2024-06-05 16:00:19 | [diff] [blame] | 117 | #endif |
mikt | ca35b70b | 2023-11-01 12:55:56 | [diff] [blame] | 118 | |
mikt | 9e6b42c | 2024-09-10 07:59:30 | [diff] [blame] | 119 | BASE_FEATURE(kPartitionAllocWithAdvancedChecks, |
| 120 | "PartitionAllocWithAdvancedChecks", |
| 121 | FEATURE_DISABLED_BY_DEFAULT); |
| 122 | constexpr FeatureParam<PartitionAllocWithAdvancedChecksEnabledProcesses>::Option |
| 123 | kPartitionAllocWithAdvancedChecksEnabledProcessesOptions[] = { |
| 124 | {PartitionAllocWithAdvancedChecksEnabledProcesses::kBrowserOnly, |
Takashi Sakamoto | 9f59021 | 2024-09-20 04:58:40 | [diff] [blame] | 125 | kBrowserOnlyStr}, |
mikt | 9e6b42c | 2024-09-10 07:59:30 | [diff] [blame] | 126 | {PartitionAllocWithAdvancedChecksEnabledProcesses::kBrowserAndRenderer, |
Takashi Sakamoto | 9f59021 | 2024-09-20 04:58:40 | [diff] [blame] | 127 | kBrowserAndRendererStr}, |
mikt | 9e6b42c | 2024-09-10 07:59:30 | [diff] [blame] | 128 | {PartitionAllocWithAdvancedChecksEnabledProcesses::kNonRenderer, |
Takashi Sakamoto | 9f59021 | 2024-09-20 04:58:40 | [diff] [blame] | 129 | kNonRendererStr}, |
mikt | 9e6b42c | 2024-09-10 07:59:30 | [diff] [blame] | 130 | {PartitionAllocWithAdvancedChecksEnabledProcesses::kAllProcesses, |
Takashi Sakamoto | 9f59021 | 2024-09-20 04:58:40 | [diff] [blame] | 131 | kAllProcessesStr}}; |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 132 | // Note: Do not use the prepared macro as of no need for a local cache. |
| 133 | constinit const FeatureParam<PartitionAllocWithAdvancedChecksEnabledProcesses> |
mikt | 9e6b42c | 2024-09-10 07:59:30 | [diff] [blame] | 134 | kPartitionAllocWithAdvancedChecksEnabledProcessesParam{ |
Takashi Sakamoto | 9f59021 | 2024-09-20 04:58:40 | [diff] [blame] | 135 | &kPartitionAllocWithAdvancedChecks, kPAFeatureEnabledProcessesStr, |
mikt | 9e6b42c | 2024-09-10 07:59:30 | [diff] [blame] | 136 | PartitionAllocWithAdvancedChecksEnabledProcesses::kBrowserOnly, |
| 137 | &kPartitionAllocWithAdvancedChecksEnabledProcessesOptions}; |
| 138 | |
mikt | ca35b70b | 2023-11-01 12:55:56 | [diff] [blame] | 139 | BASE_FEATURE(kPartitionAllocSchedulerLoopQuarantine, |
| 140 | "PartitionAllocSchedulerLoopQuarantine", |
| 141 | FEATURE_DISABLED_BY_DEFAULT); |
mikt | 4b233ef7 | 2024-04-17 02:17:04 | [diff] [blame] | 142 | // Scheduler Loop Quarantine's per-branch capacity in bytes. |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 143 | // Note: Do not use the prepared macro as of no need for a local cache. |
| 144 | constinit const FeatureParam<int> |
mikt | 4b233ef7 | 2024-04-17 02:17:04 | [diff] [blame] | 145 | kPartitionAllocSchedulerLoopQuarantineBranchCapacity{ |
| 146 | &kPartitionAllocSchedulerLoopQuarantine, |
| 147 | "PartitionAllocSchedulerLoopQuarantineBranchCapacity", 0}; |
mikt | 0941a8e | 2025-01-08 15:02:48 | [diff] [blame] | 148 | // Scheduler Loop Quarantine's capacity for the UI thread in bytes. |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 149 | BASE_FEATURE_PARAM(int, |
| 150 | kPartitionAllocSchedulerLoopQuarantineBrowserUICapacity, |
| 151 | &kPartitionAllocSchedulerLoopQuarantine, |
| 152 | "PartitionAllocSchedulerLoopQuarantineBrowserUICapacity", |
| 153 | 0); |
mikt | 95ad4ae | 2023-11-27 05:29:54 | [diff] [blame] | 154 | |
| 155 | BASE_FEATURE(kPartitionAllocZappingByFreeFlags, |
| 156 | "PartitionAllocZappingByFreeFlags", |
| 157 | FEATURE_DISABLED_BY_DEFAULT); |
Benoît Lizé | b460d7e | 2024-10-30 13:17:48 | [diff] [blame] | 158 | |
| 159 | BASE_FEATURE(kPartitionAllocEventuallyZeroFreedMemory, |
| 160 | "PartitionAllocEventuallyZeroFreedMemory", |
| 161 | FEATURE_DISABLED_BY_DEFAULT); |
Benoît Lizé | 5369008 | 2025-01-09 12:26:03 | [diff] [blame] | 162 | |
Benoît Lizé | 4d62432 | 2025-04-10 15:42:21 | [diff] [blame] | 163 | // Evaluated and positive stability and peformance-wise on Linux-based systems, |
| 164 | // disabled elsewhere (for now). Does not apply to Windows. |
Benoît Lizé | 5369008 | 2025-01-09 12:26:03 | [diff] [blame] | 165 | BASE_FEATURE(kPartitionAllocFewerMemoryRegions, |
| 166 | "PartitionAllocFewerMemoryRegions", |
Benoît Lizé | 4d62432 | 2025-04-10 15:42:21 | [diff] [blame] | 167 | #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_CHROMEOS) |
Benoît Lizé | be2cb940 | 2025-04-09 17:34:09 | [diff] [blame] | 168 | FEATURE_ENABLED_BY_DEFAULT); |
Benoît Lizé | 4d62432 | 2025-04-10 15:42:21 | [diff] [blame] | 169 | #else |
| 170 | FEATURE_DISABLED_BY_DEFAULT); |
| 171 | #endif |
Arthur Sonzogni | 62e877a | 2024-04-30 16:09:43 | [diff] [blame] | 172 | #endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) |
Benoit Lize | f13d793 | 2022-01-07 10:29:32 | [diff] [blame] | 173 | |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 174 | BASE_FEATURE(kPartitionAllocBackupRefPtr, |
| 175 | "PartitionAllocBackupRefPtr", |
Arthur Sonzogni | 647b65eb6 | 2024-09-12 09:52:30 | [diff] [blame] | 176 | #if PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_FEATURE_FLAG) |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 177 | FEATURE_ENABLED_BY_DEFAULT |
Keishi Hattori | ebb719d | 2022-05-13 09:40:30 | [diff] [blame] | 178 | #else |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 179 | FEATURE_DISABLED_BY_DEFAULT |
Keishi Hattori | ebb719d | 2022-05-13 09:40:30 | [diff] [blame] | 180 | #endif |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 181 | ); |
Keishi Hattori | af499ac | 2021-09-22 23:45:04 | [diff] [blame] | 182 | |
| 183 | constexpr FeatureParam<BackupRefPtrEnabledProcesses>::Option |
| 184 | kBackupRefPtrEnabledProcessesOptions[] = { |
Takashi Sakamoto | 9f59021 | 2024-09-20 04:58:40 | [diff] [blame] | 185 | {BackupRefPtrEnabledProcesses::kBrowserOnly, kBrowserOnlyStr}, |
Keishi Hattori | af499ac | 2021-09-22 23:45:04 | [diff] [blame] | 186 | {BackupRefPtrEnabledProcesses::kBrowserAndRenderer, |
Takashi Sakamoto | 9f59021 | 2024-09-20 04:58:40 | [diff] [blame] | 187 | kBrowserAndRendererStr}, |
| 188 | {BackupRefPtrEnabledProcesses::kNonRenderer, kNonRendererStr}, |
| 189 | {BackupRefPtrEnabledProcesses::kAllProcesses, kAllProcessesStr}}; |
Keishi Hattori | af499ac | 2021-09-22 23:45:04 | [diff] [blame] | 190 | |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 191 | BASE_FEATURE_ENUM_PARAM(BackupRefPtrEnabledProcesses, |
| 192 | kBackupRefPtrEnabledProcessesParam, |
| 193 | &kPartitionAllocBackupRefPtr, |
| 194 | kPAFeatureEnabledProcessesStr, |
Keishi Hattori | 9753766fde | 2025-05-02 03:07:52 | [diff] [blame] | 195 | #if PA_BUILDFLAG(IS_ANDROID) |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 196 | BackupRefPtrEnabledProcesses::kNonRenderer, |
Keishi Hattori | 268fad4 | 2024-08-16 19:04:11 | [diff] [blame] | 197 | #else |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 198 | BackupRefPtrEnabledProcesses::kAllProcesses, |
Keishi Hattori | 268fad4 | 2024-08-16 19:04:11 | [diff] [blame] | 199 | #endif |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 200 | &kBackupRefPtrEnabledProcessesOptions); |
Keishi Hattori | af499ac | 2021-09-22 23:45:04 | [diff] [blame] | 201 | |
Bartek Nowierski | da7d8f1c | 2021-12-08 19:30:59 | [diff] [blame] | 202 | constexpr FeatureParam<BackupRefPtrMode>::Option kBackupRefPtrModeOptions[] = { |
Bartek Nowierski | ea35aa52 | 2021-12-10 07:08:20 | [diff] [blame] | 203 | {BackupRefPtrMode::kDisabled, "disabled"}, |
Bartek Nowierski | da7d8f1c | 2021-12-08 19:30:59 | [diff] [blame] | 204 | {BackupRefPtrMode::kEnabled, "enabled"}, |
Bartek Nowierski | da7d8f1c | 2021-12-08 19:30:59 | [diff] [blame] | 205 | }; |
Bartek Nowierski | e9ad8a7d | 2021-11-04 08:37:39 | [diff] [blame] | 206 | |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 207 | BASE_FEATURE_ENUM_PARAM(BackupRefPtrMode, |
| 208 | kBackupRefPtrModeParam, |
| 209 | &kPartitionAllocBackupRefPtr, |
| 210 | "brp-mode", |
| 211 | BackupRefPtrMode::kEnabled, |
| 212 | &kBackupRefPtrModeOptions); |
| 213 | // Note: Do not use the prepared macro as of no need for a local cache. |
| 214 | constinit const FeatureParam<int> kBackupRefPtrExtraExtrasSizeParam{ |
mikt | 2644530 | 2024-12-18 06:42:16 | [diff] [blame] | 215 | &kPartitionAllocBackupRefPtr, "brp-extra-extras-size", 0}; |
mikt | 3de8127 | 2025-06-19 06:25:47 | [diff] [blame] | 216 | constinit const FeatureParam<bool> kBackupRefPtrSuppressDoubleFreeDetectedCrash{ |
| 217 | &kPartitionAllocBackupRefPtr, "brp-suppress-double-free-detected-crash", |
| 218 | false}; |
| 219 | constinit const FeatureParam<bool> kBackupRefPtrSuppressCorruptionDetectedCrash{ |
| 220 | &kPartitionAllocBackupRefPtr, "brp-suppress-corruption-detected-crash", |
| 221 | false}; |
Bartek Nowierski | e9ad8a7d | 2021-11-04 08:37:39 | [diff] [blame] | 222 | |
Keishi Hattori | 5f94b5e0 | 2023-05-23 15:01:57 | [diff] [blame] | 223 | BASE_FEATURE(kPartitionAllocMemoryTagging, |
| 224 | "PartitionAllocMemoryTagging", |
Keishi Hattori | a600f3a | 2024-11-01 09:10:54 | [diff] [blame] | 225 | #if PA_BUILDFLAG(USE_FULL_MTE) || BUILDFLAG(IS_ANDROID) |
Keishi Hattori | ec5b03a | 2024-02-16 03:28:44 | [diff] [blame] | 226 | FEATURE_ENABLED_BY_DEFAULT |
| 227 | #else |
| 228 | FEATURE_DISABLED_BY_DEFAULT |
| 229 | #endif |
| 230 | ); |
Keishi Hattori | 5f94b5e0 | 2023-05-23 15:01:57 | [diff] [blame] | 231 | |
| 232 | constexpr FeatureParam<MemtagMode>::Option kMemtagModeOptions[] = { |
| 233 | {MemtagMode::kSync, "sync"}, |
| 234 | {MemtagMode::kAsync, "async"}}; |
| 235 | |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 236 | // Note: Do not use the prepared macro as of no need for a local cache. |
| 237 | constinit const FeatureParam<MemtagMode> kMemtagModeParam{ |
Keishi Hattori | ec5b03a | 2024-02-16 03:28:44 | [diff] [blame] | 238 | &kPartitionAllocMemoryTagging, "memtag-mode", |
Arthur Sonzogni | 62e877a | 2024-04-30 16:09:43 | [diff] [blame] | 239 | #if PA_BUILDFLAG(USE_FULL_MTE) |
Keishi Hattori | ec5b03a | 2024-02-16 03:28:44 | [diff] [blame] | 240 | MemtagMode::kSync, |
| 241 | #else |
| 242 | MemtagMode::kAsync, |
| 243 | #endif |
Keishi Hattori | 5f94b5e0 | 2023-05-23 15:01:57 | [diff] [blame] | 244 | &kMemtagModeOptions}; |
| 245 | |
Keishi Hattori | 1226316 | 2024-07-31 08:22:54 | [diff] [blame] | 246 | constexpr FeatureParam<RetagMode>::Option kRetagModeOptions[] = { |
| 247 | {RetagMode::kIncrement, "increment"}, |
| 248 | {RetagMode::kRandom, "random"}, |
| 249 | }; |
| 250 | |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 251 | // Note: Do not use the prepared macro as of no need for a local cache. |
| 252 | constinit const FeatureParam<RetagMode> kRetagModeParam{ |
Keishi Hattori | 1226316 | 2024-07-31 08:22:54 | [diff] [blame] | 253 | &kPartitionAllocMemoryTagging, "retag-mode", RetagMode::kIncrement, |
| 254 | &kRetagModeOptions}; |
| 255 | |
Keishi Hattori | 5f94b5e0 | 2023-05-23 15:01:57 | [diff] [blame] | 256 | constexpr FeatureParam<MemoryTaggingEnabledProcesses>::Option |
| 257 | kMemoryTaggingEnabledProcessesOptions[] = { |
Takashi Sakamoto | 9f59021 | 2024-09-20 04:58:40 | [diff] [blame] | 258 | {MemoryTaggingEnabledProcesses::kBrowserOnly, kBrowserOnlyStr}, |
| 259 | {MemoryTaggingEnabledProcesses::kNonRenderer, kNonRendererStr}, |
| 260 | {MemoryTaggingEnabledProcesses::kAllProcesses, kAllProcessesStr}}; |
Keishi Hattori | 5f94b5e0 | 2023-05-23 15:01:57 | [diff] [blame] | 261 | |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 262 | // Note: Do not use the prepared macro as of no need for a local cache. |
| 263 | constinit const FeatureParam<MemoryTaggingEnabledProcesses> |
Keishi Hattori | 5f94b5e0 | 2023-05-23 15:01:57 | [diff] [blame] | 264 | kMemoryTaggingEnabledProcessesParam{ |
Takashi Sakamoto | 9f59021 | 2024-09-20 04:58:40 | [diff] [blame] | 265 | &kPartitionAllocMemoryTagging, kPAFeatureEnabledProcessesStr, |
Arthur Sonzogni | 62e877a | 2024-04-30 16:09:43 | [diff] [blame] | 266 | #if PA_BUILDFLAG(USE_FULL_MTE) |
Keishi Hattori | ec5b03a | 2024-02-16 03:28:44 | [diff] [blame] | 267 | MemoryTaggingEnabledProcesses::kAllProcesses, |
| 268 | #else |
Keishi Hattori | a600f3a | 2024-11-01 09:10:54 | [diff] [blame] | 269 | MemoryTaggingEnabledProcesses::kNonRenderer, |
Keishi Hattori | ec5b03a | 2024-02-16 03:28:44 | [diff] [blame] | 270 | #endif |
Keishi Hattori | 5f94b5e0 | 2023-05-23 15:01:57 | [diff] [blame] | 271 | &kMemoryTaggingEnabledProcessesOptions}; |
| 272 | |
Keishi Hattori | 4dddbef2 | 2023-06-01 09:31:56 | [diff] [blame] | 273 | BASE_FEATURE(kKillPartitionAllocMemoryTagging, |
| 274 | "KillPartitionAllocMemoryTagging", |
| 275 | FEATURE_DISABLED_BY_DEFAULT); |
| 276 | |
Keishi Hattori | 806e3d8e | 2023-09-06 05:55:52 | [diff] [blame] | 277 | BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPermissiveMte); |
| 278 | BASE_FEATURE(kPartitionAllocPermissiveMte, |
| 279 | "PartitionAllocPermissiveMte", |
Arthur Sonzogni | 62e877a | 2024-04-30 16:09:43 | [diff] [blame] | 280 | #if PA_BUILDFLAG(USE_FULL_MTE) |
Keishi Hattori | ec5b03a | 2024-02-16 03:28:44 | [diff] [blame] | 281 | // We want to actually crash if USE_FULL_MTE is enabled. |
| 282 | FEATURE_DISABLED_BY_DEFAULT |
| 283 | #else |
| 284 | FEATURE_ENABLED_BY_DEFAULT |
| 285 | #endif |
| 286 | ); |
Keishi Hattori | 806e3d8e | 2023-09-06 05:55:52 | [diff] [blame] | 287 | |
Arthur Sonzogni | 44bc44b | 2025-02-17 13:59:07 | [diff] [blame] | 288 | BASE_FEATURE(kAsanBrpDereferenceCheck, |
| 289 | "AsanBrpDereferenceCheck", |
| 290 | FEATURE_ENABLED_BY_DEFAULT); |
| 291 | BASE_FEATURE(kAsanBrpExtractionCheck, |
| 292 | "AsanBrpExtractionCheck", // Not much noise at the moment to |
| 293 | FEATURE_DISABLED_BY_DEFAULT); // enable by default. |
| 294 | BASE_FEATURE(kAsanBrpInstantiationCheck, |
| 295 | "AsanBrpInstantiationCheck", |
| 296 | FEATURE_ENABLED_BY_DEFAULT); |
Anton Bikineev | db908de | 2020-12-08 14:48:13 | [diff] [blame] | 297 | |
Thiabaud Engelbrecht | 179001b | 2023-05-30 15:46:42 | [diff] [blame] | 298 | // If enabled, switches the bucket distribution to a denser one. |
Thiabaud Engelbrecht | 7cd1e4a | 2023-04-20 14:39:20 | [diff] [blame] | 299 | // |
| 300 | // We enable this by default everywhere except for 32-bit Android, since we saw |
| 301 | // regressions there. |
Thiabaud Engelbrecht | 179001b | 2023-05-30 15:46:42 | [diff] [blame] | 302 | BASE_FEATURE(kPartitionAllocUseDenserDistribution, |
| 303 | "PartitionAllocUseDenserDistribution", |
Thiabaud Engelbrecht | 7cd1e4a | 2023-04-20 14:39:20 | [diff] [blame] | 304 | #if BUILDFLAG(IS_ANDROID) && defined(ARCH_CPU_32_BITS) |
| 305 | FEATURE_DISABLED_BY_DEFAULT |
| 306 | #else |
| 307 | FEATURE_ENABLED_BY_DEFAULT |
| 308 | #endif // BUILDFLAG(IS_ANDROID) && defined(ARCH_CPU_32_BITS) |
| 309 | ); |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 310 | const FeatureParam<BucketDistributionMode>::Option |
Thiabaud Engelbrecht | 179001b | 2023-05-30 15:46:42 | [diff] [blame] | 311 | kPartitionAllocBucketDistributionOption[] = { |
| 312 | {BucketDistributionMode::kDefault, "default"}, |
| 313 | {BucketDistributionMode::kDenser, "denser"}, |
Thiabaud Engelbrecht | 05f8b811 | 2022-09-16 02:18:29 | [diff] [blame] | 314 | }; |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 315 | // Note: Do not use the prepared macro as of no need for a local cache. |
| 316 | constinit const FeatureParam<BucketDistributionMode> |
Peter Kasting | 134ef9af | 2024-12-28 02:30:09 | [diff] [blame] | 317 | kPartitionAllocBucketDistributionParam{ |
| 318 | &kPartitionAllocUseDenserDistribution, "mode", |
Thiabaud Engelbrecht | 179001b | 2023-05-30 15:46:42 | [diff] [blame] | 319 | #if BUILDFLAG(IS_ANDROID) && defined(ARCH_CPU_32_BITS) |
Peter Kasting | 134ef9af | 2024-12-28 02:30:09 | [diff] [blame] | 320 | BucketDistributionMode::kDefault, |
Thiabaud Engelbrecht | 179001b | 2023-05-30 15:46:42 | [diff] [blame] | 321 | #else |
Peter Kasting | 134ef9af | 2024-12-28 02:30:09 | [diff] [blame] | 322 | BucketDistributionMode::kDenser, |
Thiabaud Engelbrecht | 179001b | 2023-05-30 15:46:42 | [diff] [blame] | 323 | #endif // BUILDFLAG(IS_ANDROID) && defined(ARCH_CPU_32_BITS) |
Peter Kasting | 134ef9af | 2024-12-28 02:30:09 | [diff] [blame] | 324 | &kPartitionAllocBucketDistributionOption}; |
Thiabaud Engelbrecht | 1efe437 | 2022-02-16 19:33:09 | [diff] [blame] | 325 | |
Bartek Nowierski | 1992f453 | 2023-07-11 15:06:35 | [diff] [blame] | 326 | BASE_FEATURE(kPartitionAllocMemoryReclaimer, |
| 327 | "PartitionAllocMemoryReclaimer", |
| 328 | FEATURE_ENABLED_BY_DEFAULT); |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 329 | BASE_FEATURE_PARAM(TimeDelta, |
| 330 | kPartitionAllocMemoryReclaimerInterval, |
| 331 | &kPartitionAllocMemoryReclaimer, |
| 332 | "interval", |
| 333 | TimeDelta() // Defaults to zero. |
| 334 | ); |
Bartek Nowierski | 1992f453 | 2023-07-11 15:06:35 | [diff] [blame] | 335 | |
Arthur Sonzogni | a57023635 | 2022-12-19 13:18:54 | [diff] [blame] | 336 | // Configures whether we set a lower limit for renderers that do not have a main |
| 337 | // frame, similar to the limit that is already done for backgrounded renderers. |
| 338 | BASE_FEATURE(kLowerPAMemoryLimitForNonMainRenderers, |
| 339 | "LowerPAMemoryLimitForNonMainRenderers", |
| 340 | FEATURE_DISABLED_BY_DEFAULT); |
| 341 | |
Bartek Nowierski | afd8821 | 2023-08-23 15:25:24 | [diff] [blame] | 342 | // Whether to straighten free lists for larger slot spans in PurgeMemory() -> |
| 343 | // ... -> PartitionPurgeSlotSpan(). |
| 344 | BASE_FEATURE(kPartitionAllocStraightenLargerSlotSpanFreeLists, |
| 345 | "PartitionAllocStraightenLargerSlotSpanFreeLists", |
| 346 | FEATURE_ENABLED_BY_DEFAULT); |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 347 | const FeatureParam<partition_alloc::StraightenLargerSlotSpanFreeListsMode>:: |
| 348 | Option kPartitionAllocStraightenLargerSlotSpanFreeListsModeOption[] = { |
Bartek Nowierski | 5075053 | 2023-08-25 05:26:17 | [diff] [blame] | 349 | {partition_alloc::StraightenLargerSlotSpanFreeListsMode:: |
| 350 | kOnlyWhenUnprovisioning, |
| 351 | "only-when-unprovisioning"}, |
| 352 | {partition_alloc::StraightenLargerSlotSpanFreeListsMode::kAlways, |
| 353 | "always"}, |
| 354 | }; |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 355 | // Note: Do not use the prepared macro as of no need for a local cache. |
| 356 | constinit const FeatureParam< |
| 357 | partition_alloc::StraightenLargerSlotSpanFreeListsMode> |
Bartek Nowierski | 5075053 | 2023-08-25 05:26:17 | [diff] [blame] | 358 | kPartitionAllocStraightenLargerSlotSpanFreeListsMode = { |
| 359 | &kPartitionAllocStraightenLargerSlotSpanFreeLists, |
| 360 | "mode", |
| 361 | partition_alloc::StraightenLargerSlotSpanFreeListsMode:: |
| 362 | kOnlyWhenUnprovisioning, |
| 363 | &kPartitionAllocStraightenLargerSlotSpanFreeListsModeOption, |
| 364 | }; |
Bartek Nowierski | afd8821 | 2023-08-23 15:25:24 | [diff] [blame] | 365 | |
Bartek Nowierski | 3506afbc | 2023-08-18 03:58:38 | [diff] [blame] | 366 | // Whether to sort free lists for smaller slot spans in PurgeMemory(). |
Bartek Nowierski | 3506afbc | 2023-08-18 03:58:38 | [diff] [blame] | 367 | BASE_FEATURE(kPartitionAllocSortSmallerSlotSpanFreeLists, |
| 368 | "PartitionAllocSortSmallerSlotSpanFreeLists", |
| 369 | FEATURE_ENABLED_BY_DEFAULT); |
| 370 | |
Benoit Lize | c9ec6149 | 2022-05-20 10:51:25 | [diff] [blame] | 371 | // Whether to sort the active slot spans in PurgeMemory(). |
Daniel Cheng | 0fff5c23 | 2022-09-21 17:43:34 | [diff] [blame] | 372 | BASE_FEATURE(kPartitionAllocSortActiveSlotSpans, |
| 373 | "PartitionAllocSortActiveSlotSpans", |
| 374 | FEATURE_DISABLED_BY_DEFAULT); |
Benoit Lize | c9ec6149 | 2022-05-20 10:51:25 | [diff] [blame] | 375 | |
Benoit Lize | 7ebe3d4 | 2022-11-24 21:12:00 | [diff] [blame] | 376 | #if BUILDFLAG(IS_WIN) |
| 377 | // Whether to retry allocations when commit fails. |
| 378 | BASE_FEATURE(kPageAllocatorRetryOnCommitFailure, |
| 379 | "PageAllocatorRetryOnCommitFailure", |
| 380 | FEATURE_DISABLED_BY_DEFAULT); |
| 381 | #endif |
| 382 | |
Erik Chen | 6968d88 | 2023-10-17 23:14:42 | [diff] [blame] | 383 | #if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_CHROMEOS) |
Takashi Sakamoto | 2e824dc | 2023-07-14 01:52:35 | [diff] [blame] | 384 | // A parameter to exclude or not exclude PartitionAllocSupport from |
| 385 | // PartialLowModeOnMidRangeDevices. This is used to see how it affects |
| 386 | // renderer performances, e.g. blink_perf.parser benchmark. |
| 387 | // The feature: kPartialLowEndModeOnMidRangeDevices is defined in |
| 388 | // //base/features.cc. Since the following feature param is related to |
| 389 | // PartitionAlloc, define the param here. |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 390 | BASE_FEATURE_PARAM(bool, |
| 391 | kPartialLowEndModeExcludePartitionAllocSupport, |
| 392 | &kPartialLowEndModeOnMidRangeDevices, |
| 393 | "exclude-partition-alloc-support", |
| 394 | false); |
Takashi Sakamoto | 2e824dc | 2023-07-14 01:52:35 | [diff] [blame] | 395 | #endif |
| 396 | |
Mingyu Lei | 24762854 | 2023-09-04 06:40:21 | [diff] [blame] | 397 | BASE_FEATURE(kEnableConfigurableThreadCacheMultiplier, |
| 398 | "EnableConfigurableThreadCacheMultiplier", |
| 399 | base::FEATURE_DISABLED_BY_DEFAULT); |
| 400 | |
Mingyu Lei | 21e0a64 | 2023-10-18 18:29:02 | [diff] [blame] | 401 | MIRACLE_PARAMETER_FOR_DOUBLE(GetThreadCacheMultiplier, |
| 402 | kEnableConfigurableThreadCacheMultiplier, |
| 403 | "ThreadCacheMultiplier", |
| 404 | 2.) |
Mingyu Lei | 24762854 | 2023-09-04 06:40:21 | [diff] [blame] | 405 | |
Mingyu Lei | 21e0a64 | 2023-10-18 18:29:02 | [diff] [blame] | 406 | MIRACLE_PARAMETER_FOR_DOUBLE(GetThreadCacheMultiplierForAndroid, |
| 407 | kEnableConfigurableThreadCacheMultiplier, |
| 408 | "ThreadCacheMultiplierForAndroid", |
| 409 | 1.) |
Mingyu Lei | 24762854 | 2023-09-04 06:40:21 | [diff] [blame] | 410 | |
Mingyu Lei | af2e0d9 | 2023-09-07 06:35:08 | [diff] [blame] | 411 | constexpr partition_alloc::internal::base::TimeDelta ToPartitionAllocTimeDelta( |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 412 | TimeDelta time_delta) { |
Mingyu Lei | af2e0d9 | 2023-09-07 06:35:08 | [diff] [blame] | 413 | return partition_alloc::internal::base::Microseconds( |
| 414 | time_delta.InMicroseconds()); |
| 415 | } |
| 416 | |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 417 | constexpr TimeDelta FromPartitionAllocTimeDelta( |
Mingyu Lei | af2e0d9 | 2023-09-07 06:35:08 | [diff] [blame] | 418 | partition_alloc::internal::base::TimeDelta time_delta) { |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 419 | return Microseconds(time_delta.InMicroseconds()); |
Mingyu Lei | af2e0d9 | 2023-09-07 06:35:08 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | BASE_FEATURE(kEnableConfigurableThreadCachePurgeInterval, |
| 423 | "EnableConfigurableThreadCachePurgeInterval", |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 424 | FEATURE_DISABLED_BY_DEFAULT); |
Mingyu Lei | af2e0d9 | 2023-09-07 06:35:08 | [diff] [blame] | 425 | |
Mingyu Lei | dd8c3d5 | 2023-10-19 05:28:41 | [diff] [blame] | 426 | MIRACLE_PARAMETER_FOR_TIME_DELTA( |
| 427 | GetThreadCacheMinPurgeIntervalValue, |
| 428 | kEnableConfigurableThreadCachePurgeInterval, |
| 429 | "ThreadCacheMinPurgeInterval", |
| 430 | FromPartitionAllocTimeDelta(partition_alloc::kMinPurgeInterval)) |
Mingyu Lei | af2e0d9 | 2023-09-07 06:35:08 | [diff] [blame] | 431 | |
Mingyu Lei | dd8c3d5 | 2023-10-19 05:28:41 | [diff] [blame] | 432 | MIRACLE_PARAMETER_FOR_TIME_DELTA( |
| 433 | GetThreadCacheMaxPurgeIntervalValue, |
| 434 | kEnableConfigurableThreadCachePurgeInterval, |
| 435 | "ThreadCacheMaxPurgeInterval", |
| 436 | FromPartitionAllocTimeDelta(partition_alloc::kMaxPurgeInterval)) |
Mingyu Lei | af2e0d9 | 2023-09-07 06:35:08 | [diff] [blame] | 437 | |
Mingyu Lei | dd8c3d5 | 2023-10-19 05:28:41 | [diff] [blame] | 438 | MIRACLE_PARAMETER_FOR_TIME_DELTA( |
| 439 | GetThreadCacheDefaultPurgeIntervalValue, |
| 440 | kEnableConfigurableThreadCachePurgeInterval, |
Mingyu Lei | af2e0d9 | 2023-09-07 06:35:08 | [diff] [blame] | 441 | "ThreadCacheDefaultPurgeInterval", |
Mingyu Lei | dd8c3d5 | 2023-10-19 05:28:41 | [diff] [blame] | 442 | FromPartitionAllocTimeDelta(partition_alloc::kDefaultPurgeInterval)) |
Mingyu Lei | af2e0d9 | 2023-09-07 06:35:08 | [diff] [blame] | 443 | |
| 444 | const partition_alloc::internal::base::TimeDelta |
| 445 | GetThreadCacheMinPurgeInterval() { |
Mingyu Lei | dd8c3d5 | 2023-10-19 05:28:41 | [diff] [blame] | 446 | return ToPartitionAllocTimeDelta(GetThreadCacheMinPurgeIntervalValue()); |
Mingyu Lei | af2e0d9 | 2023-09-07 06:35:08 | [diff] [blame] | 447 | } |
| 448 | |
| 449 | const partition_alloc::internal::base::TimeDelta |
| 450 | GetThreadCacheMaxPurgeInterval() { |
Mingyu Lei | dd8c3d5 | 2023-10-19 05:28:41 | [diff] [blame] | 451 | return ToPartitionAllocTimeDelta(GetThreadCacheMaxPurgeIntervalValue()); |
Mingyu Lei | af2e0d9 | 2023-09-07 06:35:08 | [diff] [blame] | 452 | } |
| 453 | |
| 454 | const partition_alloc::internal::base::TimeDelta |
| 455 | GetThreadCacheDefaultPurgeInterval() { |
Mingyu Lei | dd8c3d5 | 2023-10-19 05:28:41 | [diff] [blame] | 456 | return ToPartitionAllocTimeDelta(GetThreadCacheDefaultPurgeIntervalValue()); |
Mingyu Lei | af2e0d9 | 2023-09-07 06:35:08 | [diff] [blame] | 457 | } |
| 458 | |
| 459 | BASE_FEATURE(kEnableConfigurableThreadCacheMinCachedMemoryForPurging, |
| 460 | "EnableConfigurableThreadCacheMinCachedMemoryForPurging", |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 461 | FEATURE_DISABLED_BY_DEFAULT); |
Mingyu Lei | af2e0d9 | 2023-09-07 06:35:08 | [diff] [blame] | 462 | |
Mingyu Lei | 597be2d | 2023-10-19 05:31:04 | [diff] [blame] | 463 | MIRACLE_PARAMETER_FOR_INT( |
| 464 | GetThreadCacheMinCachedMemoryForPurgingBytes, |
| 465 | kEnableConfigurableThreadCacheMinCachedMemoryForPurging, |
Mingyu Lei | af2e0d9 | 2023-09-07 06:35:08 | [diff] [blame] | 466 | "ThreadCacheMinCachedMemoryForPurgingBytes", |
Mingyu Lei | 597be2d | 2023-10-19 05:31:04 | [diff] [blame] | 467 | partition_alloc::kMinCachedMemoryForPurgingBytes) |
Mingyu Lei | af2e0d9 | 2023-09-07 06:35:08 | [diff] [blame] | 468 | |
Kalvin Lee | e933f3a | 2023-10-22 07:34:44 | [diff] [blame] | 469 | // An apparent quarantine leak in the buffer partition unacceptably |
| 470 | // bloats memory when MiraclePtr is enabled in the renderer process. |
| 471 | // We believe we have found and patched the leak, but out of an |
| 472 | // abundance of caution, we provide this toggle that allows us to |
| 473 | // wholly disable MiraclePtr in the buffer partition, if necessary. |
| 474 | // |
Alison Gale | 47d1537d | 2024-04-19 21:31:46 | [diff] [blame] | 475 | // TODO(crbug.com/40064499): this is unneeded once |
Kalvin Lee | e933f3a | 2023-10-22 07:34:44 | [diff] [blame] | 476 | // MiraclePtr-for-Renderer launches. |
| 477 | BASE_FEATURE(kPartitionAllocDisableBRPInBufferPartition, |
| 478 | "PartitionAllocDisableBRPInBufferPartition", |
| 479 | FEATURE_DISABLED_BY_DEFAULT); |
| 480 | |
Scott Violet | 493a946 | 2024-03-13 19:18:58 | [diff] [blame] | 481 | BASE_FEATURE(kPartitionAllocAdjustSizeWhenInForeground, |
| 482 | "PartitionAllocAdjustSizeWhenInForeground", |
François Doray | 65df3e4 | 2024-12-13 21:06:44 | [diff] [blame] | 483 | #if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) |
Scott Violet | d802f82 | 2024-06-05 16:00:19 | [diff] [blame] | 484 | FEATURE_ENABLED_BY_DEFAULT); |
| 485 | #else |
| 486 | FEATURE_DISABLED_BY_DEFAULT); |
| 487 | #endif |
Scott Violet | 493a946 | 2024-03-13 19:18:58 | [diff] [blame] | 488 | |
Takashi Sakamoto | 9f59021 | 2024-09-20 04:58:40 | [diff] [blame] | 489 | #if PA_CONFIG(ENABLE_SHADOW_METADATA) |
| 490 | BASE_FEATURE(kPartitionAllocShadowMetadata, |
| 491 | "PartitionAllocShadowMetadata", |
Takashi Sakamoto | 9994119 | 2025-05-27 23:05:30 | [diff] [blame] | 492 | #if BUILDFLAG(IS_LINUX) |
| 493 | FEATURE_ENABLED_BY_DEFAULT); |
| 494 | #else |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 495 | FEATURE_DISABLED_BY_DEFAULT); |
Takashi Sakamoto | 9994119 | 2025-05-27 23:05:30 | [diff] [blame] | 496 | #endif |
Takashi Sakamoto | 9f59021 | 2024-09-20 04:58:40 | [diff] [blame] | 497 | |
| 498 | constexpr FeatureParam<ShadowMetadataEnabledProcesses>::Option |
| 499 | kShadowMetadataEnabledProcessesOptions[] = { |
| 500 | {ShadowMetadataEnabledProcesses::kRendererOnly, kRendererOnlyStr}, |
| 501 | {ShadowMetadataEnabledProcesses::kAllChildProcesses, |
| 502 | kAllChildProcessesStr}}; |
| 503 | |
Takashi Toyoshima | cff0ce6 | 2025-01-17 14:32:12 | [diff] [blame] | 504 | // Note: Do not use the prepared macro as of no need for a local cache. |
| 505 | constinit const FeatureParam<ShadowMetadataEnabledProcesses> |
Takashi Sakamoto | 9f59021 | 2024-09-20 04:58:40 | [diff] [blame] | 506 | kShadowMetadataEnabledProcessesParam{ |
| 507 | &kPartitionAllocShadowMetadata, kPAFeatureEnabledProcessesStr, |
| 508 | ShadowMetadataEnabledProcesses::kRendererOnly, |
| 509 | &kShadowMetadataEnabledProcessesOptions}; |
| 510 | #endif // PA_CONFIG(ENABLE_SHADOW_METADATA) |
| 511 | |
Anand Ravi | 426fc83 | 2025-04-17 17:21:37 | [diff] [blame] | 512 | #if PA_BUILDFLAG(ENABLE_PARTITION_LOCK_PRIORITY_INHERITANCE) |
| 513 | BASE_FEATURE(kPartitionAllocUsePriorityInheritanceLocks, |
| 514 | "PartitionAllocUsePriorityInheritanceLocks", |
| 515 | FEATURE_DISABLED_BY_DEFAULT); |
| 516 | #endif // PA_BUILDFLAG(ENABLE_PARTITION_LOCK_PRIORITY_INHERITANCE) |
| 517 | |
Peter Kasting | 811504a7 | 2025-01-09 03:18:50 | [diff] [blame] | 518 | } // namespace base::features |