summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland Levillain <rpl@google.com>2023-12-06 18:38:36 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-12-08 13:35:13 +0000
commitbadea1db5e66421ccff9e0cca02e76fcb3fc0f32 (patch)
treec98684bb56b9d320e4b15106f5e7e6e95b7e2a49
parent3b072364164657d70436cbec60d1892a64ea73ad (diff)
downloadart-badea1db5e66421ccff9e0cca02e76fcb3fc0f32.tar.gz
Enable `userfaultfd`-based CMC GC by default on Android S and above.
Before this change, the Concurrent Mark-Compact Garbage Collector (CMC GC) was enabled by default (provided the kernel supports `userfaultfd`) on Android T and above. Extend this behavior to Android S and above. This reverts commit a9102c122084ced4a5369d2c2174ea1b83b4e1c9. (cherry picked from https://android-review.googlesource.com/q/commit:854cb7d94594f027cf0f056d6cd023e7a00df0cd) Test: atest art_standalone_odrefresh_tests Test: atest odsign_e2e_tests odsign_e2e_tests_full Test: Build bundled module on main with OVERRIDE_ENABLE_UFFD_GC=false, check that odrefresh runs on boot, and check that logcat shows "Using CollectorTypeCMC GC." Test: Build module on Mainline branch, install on device running S, check that odrefresh runs on reboot, and check that logcat shows "Using CollectorTypeCMC GC." Reboot again, and check that odrefresh does not run and that logcat shows "Using CollectorTypeCMC GC." Test: Same as above on a device running T, and then: adb root adb shell device_config set_sync_disabled_for_tests persistent adb shell setprop persist.device_config.runtime_native_boot.force_disable_uffd_gc true adb reboot Check that odrefresh runs on reboot, and check that logcat shows "Using CollectorTypeCC GC." Reboot again, and check that odrefresh does not run and that logcat shows "Using CollectorTypeCC GC." Bug: 251150519 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:d3445d7bfa2a6fff119ecb9f2d4d9e348a514d39) Merged-In: I378fe28b657704031501c669beddec4afa4838c4 Change-Id: I378fe28b657704031501c669beddec4afa4838c4
-rw-r--r--odrefresh/odr_common.cc6
-rw-r--r--odrefresh/odr_common.h4
-rw-r--r--odrefresh/odr_common_test.cc16
-rw-r--r--odrefresh/odr_config.h4
-rw-r--r--odrefresh/odrefresh.cc9
-rw-r--r--runtime/Android.bp1
-rw-r--r--runtime/gc/collector/mark_compact.cc8
7 files changed, 11 insertions, 37 deletions
diff --git a/odrefresh/odr_common.cc b/odrefresh/odr_common.cc
index 191defc125..16a6af5778 100644
--- a/odrefresh/odr_common.cc
+++ b/odrefresh/odr_common.cc
@@ -88,10 +88,8 @@ void SystemPropertyForeach(std::function<void(const char* name, const char* valu
&action);
}
-bool CheckBuildUserfaultFdGc(bool build_enable_uffd_gc,
- bool is_at_least_t,
- bool kernel_supports_uffd) {
- bool runtime_uses_uffd_gc = (build_enable_uffd_gc || is_at_least_t) && kernel_supports_uffd;
+bool CheckBuildUserfaultFdGc(bool build_enable_uffd_gc, bool kernel_supports_uffd) {
+ bool runtime_uses_uffd_gc = kernel_supports_uffd;
return build_enable_uffd_gc == runtime_uses_uffd_gc;
}
diff --git a/odrefresh/odr_common.h b/odrefresh/odr_common.h
index d887bf0449..2421e41017 100644
--- a/odrefresh/odr_common.h
+++ b/odrefresh/odr_common.h
@@ -45,9 +45,7 @@ bool ShouldDisableRefresh(const std::string& sdk_version_str);
void SystemPropertyForeach(std::function<void(const char* name, const char* value)> action);
// Returns true if the build-time UFFD GC matches the runtime's choice.
-bool CheckBuildUserfaultFdGc(bool build_enable_uffd_gc,
- bool is_at_least_t,
- bool kernel_supports_uffd);
+bool CheckBuildUserfaultFdGc(bool build_enable_uffd_gc, bool kernel_supports_uffd);
} // namespace odrefresh
} // namespace art
diff --git a/odrefresh/odr_common_test.cc b/odrefresh/odr_common_test.cc
index 204c04bc53..77becad0a2 100644
--- a/odrefresh/odr_common_test.cc
+++ b/odrefresh/odr_common_test.cc
@@ -57,21 +57,13 @@ TEST(OdrCommonTest, ShouldDisableRefresh) {
TEST(OdrCommonTest, CheckBuildUserfaultFdGc) {
EXPECT_TRUE(CheckBuildUserfaultFdGc(
- /*build_enable_uffd_gc=*/false, /*is_at_least_t=*/false, /*kernel_supports_uffd=*/false));
+ /*build_enable_uffd_gc=*/false, /*kernel_supports_uffd=*/false));
EXPECT_FALSE(CheckBuildUserfaultFdGc(
- /*build_enable_uffd_gc=*/true, /*is_at_least_t=*/false, /*kernel_supports_uffd=*/false));
- EXPECT_TRUE(CheckBuildUserfaultFdGc(
- /*build_enable_uffd_gc=*/false, /*is_at_least_t=*/true, /*kernel_supports_uffd=*/false));
- EXPECT_FALSE(CheckBuildUserfaultFdGc(
- /*build_enable_uffd_gc=*/true, /*is_at_least_t=*/true, /*kernel_supports_uffd=*/false));
- EXPECT_TRUE(CheckBuildUserfaultFdGc(
- /*build_enable_uffd_gc=*/false, /*is_at_least_t=*/false, /*kernel_supports_uffd=*/true));
- EXPECT_TRUE(CheckBuildUserfaultFdGc(
- /*build_enable_uffd_gc=*/true, /*is_at_least_t=*/false, /*kernel_supports_uffd=*/true));
+ /*build_enable_uffd_gc=*/true, /*kernel_supports_uffd=*/false));
EXPECT_FALSE(CheckBuildUserfaultFdGc(
- /*build_enable_uffd_gc=*/false, /*is_at_least_t=*/true, /*kernel_supports_uffd=*/true));
+ /*build_enable_uffd_gc=*/false, /*kernel_supports_uffd=*/true));
EXPECT_TRUE(CheckBuildUserfaultFdGc(
- /*build_enable_uffd_gc=*/true, /*is_at_least_t=*/true, /*kernel_supports_uffd=*/true));
+ /*build_enable_uffd_gc=*/true, /*kernel_supports_uffd=*/true));
}
} // namespace odrefresh
diff --git a/odrefresh/odr_config.h b/odrefresh/odr_config.h
index 2a42a5e4e0..78af97c9a0 100644
--- a/odrefresh/odr_config.h
+++ b/odrefresh/odr_config.h
@@ -72,9 +72,7 @@ struct SystemPropertyConfig {
// default value should not trigger re-compilation. This is to comply with the phenotype flag
// requirement (go/platform-experiments-flags#pre-requisites).
const android::base::NoDestructor<std::vector<SystemPropertyConfig>> kSystemProperties{
- {SystemPropertyConfig{.name = "persist.device_config.runtime_native_boot.enable_uffd_gc_2",
- .default_value = "false"},
- SystemPropertyConfig{.name = "persist.device_config.runtime_native_boot.force_disable_uffd_gc",
+ {SystemPropertyConfig{.name = "persist.device_config.runtime_native_boot.force_disable_uffd_gc",
.default_value = "false"},
SystemPropertyConfig{.name = kPhDisableCompactDex, .default_value = "false"},
SystemPropertyConfig{.name = kSystemPropertySystemServerCompilerFilterOverride,
diff --git a/odrefresh/odrefresh.cc b/odrefresh/odrefresh.cc
index 7ff6aa4272..85fc9d1f32 100644
--- a/odrefresh/odrefresh.cc
+++ b/odrefresh/odrefresh.cc
@@ -106,7 +106,6 @@ using ::android::base::Split;
using ::android::base::StartsWith;
using ::android::base::StringPrintf;
using ::android::base::Timer;
-using ::android::modules::sdklevel::IsAtLeastT;
using ::android::modules::sdklevel::IsAtLeastU;
using ::art::tools::CmdlineBuilder;
@@ -1093,19 +1092,15 @@ WARN_UNUSED bool OnDeviceRefresh::CheckSystemPropertiesHaveNotChanged(
WARN_UNUSED bool OnDeviceRefresh::CheckBuildUserfaultFdGc() const {
bool build_enable_uffd_gc =
config_.GetSystemProperties().GetBool("ro.dalvik.vm.enable_uffd_gc", /*default_value=*/false);
- bool is_at_least_t = IsAtLeastT();
bool kernel_supports_uffd = KernelSupportsUffd();
- if (!art::odrefresh::CheckBuildUserfaultFdGc(
- build_enable_uffd_gc, is_at_least_t, kernel_supports_uffd)) {
+ if (!art::odrefresh::CheckBuildUserfaultFdGc(build_enable_uffd_gc, kernel_supports_uffd)) {
// Assuming the system property reflects how the dexpreopted boot image was
// compiled, and it doesn't agree with runtime support, we need to recompile
// it. This happens if we're running on S, T or U, or if the system image
// was built with a wrong PRODUCT_ENABLE_UFFD_GC flag.
LOG(INFO) << ART_FORMAT(
- "Userfaultfd GC check failed (build_enable_uffd_gc: {}, is_at_least_t: {}, "
- "kernel_supports_uffd: {}).",
+ "Userfaultfd GC check failed (build_enable_uffd_gc: {}, kernel_supports_uffd: {}).",
build_enable_uffd_gc,
- is_at_least_t,
kernel_supports_uffd);
return false;
}
diff --git a/runtime/Android.bp b/runtime/Android.bp
index 3c3b9f8681..1c4b8714e1 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -449,7 +449,6 @@ libart_cc_defaults {
"heapprofd_client_api",
],
static_libs: [
- "libmodules-utils-build",
"libstatslog_art",
],
generated_sources: [
diff --git a/runtime/gc/collector/mark_compact.cc b/runtime/gc/collector/mark_compact.cc
index 8cd92a71f2..a7252a1036 100644
--- a/runtime/gc/collector/mark_compact.cc
+++ b/runtime/gc/collector/mark_compact.cc
@@ -58,7 +58,6 @@
#include "thread_list.h"
#ifdef ART_TARGET_ANDROID
-#include "android-modules-utils/sdk_level.h"
#include "com_android_art.h"
#endif
@@ -90,7 +89,6 @@ namespace {
using ::android::base::GetBoolProperty;
using ::android::base::ParseBool;
using ::android::base::ParseBoolResult;
-using ::android::modules::sdklevel::IsAtLeastT;
} // namespace
#endif
@@ -262,12 +260,8 @@ static bool SysPropSaysUffdGc() {
// The phenotype flag can change at time time after boot, but it shouldn't take effect until a
// reboot. Therefore, we read the phenotype flag from the cache info, which is generated on boot.
std::unordered_map<std::string, std::string> cached_properties = GetCachedProperties();
- bool phenotype_enable = GetCachedBoolProperty(
- cached_properties, "persist.device_config.runtime_native_boot.enable_uffd_gc_2", false);
- bool phenotype_force_disable = GetCachedBoolProperty(
+ return !GetCachedBoolProperty(
cached_properties, "persist.device_config.runtime_native_boot.force_disable_uffd_gc", false);
- bool build_enable = GetBoolProperty("ro.dalvik.vm.enable_uffd_gc", false);
- return (phenotype_enable || build_enable || IsAtLeastT()) && !phenotype_force_disable;
}
#else
// Never called.