diff options
| -rw-r--r-- | odrefresh/odr_common.cc | 6 | ||||
| -rw-r--r-- | odrefresh/odr_common.h | 4 | ||||
| -rw-r--r-- | odrefresh/odr_common_test.cc | 16 | ||||
| -rw-r--r-- | odrefresh/odr_config.h | 4 | ||||
| -rw-r--r-- | odrefresh/odrefresh.cc | 16 | ||||
| -rw-r--r-- | runtime/Android.bp | 1 | ||||
| -rw-r--r-- | runtime/gc/collector/mark_compact.cc | 10 |
7 files changed, 17 insertions, 40 deletions
diff --git a/odrefresh/odr_common.cc b/odrefresh/odr_common.cc index d7cc4d1203..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_u, - bool kernel_supports_uffd) { - bool runtime_uses_uffd_gc = (build_enable_uffd_gc || is_at_least_u) && 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 79babd296c..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_u, - 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 63fcfd6e82..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_u=*/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_u=*/false, /*kernel_supports_uffd=*/false)); - EXPECT_TRUE(CheckBuildUserfaultFdGc( - /*build_enable_uffd_gc=*/false, /*is_at_least_u=*/true, /*kernel_supports_uffd=*/false)); - EXPECT_FALSE(CheckBuildUserfaultFdGc( - /*build_enable_uffd_gc=*/true, /*is_at_least_u=*/true, /*kernel_supports_uffd=*/false)); - EXPECT_TRUE(CheckBuildUserfaultFdGc( - /*build_enable_uffd_gc=*/false, /*is_at_least_u=*/false, /*kernel_supports_uffd=*/true)); - EXPECT_TRUE(CheckBuildUserfaultFdGc( - /*build_enable_uffd_gc=*/true, /*is_at_least_u=*/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_u=*/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_u=*/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 ae7bf0c3e2..12ce681ddd 100644 --- a/odrefresh/odrefresh.cc +++ b/odrefresh/odrefresh.cc @@ -1099,17 +1099,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_u = IsAtLeastU(); bool kernel_supports_uffd = KernelSupportsUffd(); - if (!art::odrefresh::CheckBuildUserfaultFdGc( - build_enable_uffd_gc, is_at_least_u, kernel_supports_uffd)) { - // Normally, this should not happen. If this happens, the system image was probably built with a - // wrong PRODUCT_ENABLE_UFFD_GC flag. - LOG(WARNING) << ART_FORMAT( - "Userfaultfd GC check failed (build_enable_uffd_gc: {}, is_at_least_u: {}, " - "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: {}, kernel_supports_uffd: {}).", build_enable_uffd_gc, - is_at_least_u, kernel_supports_uffd); return false; } diff --git a/runtime/Android.bp b/runtime/Android.bp index a786c74fe2..4d16378c58 100644 --- a/runtime/Android.bp +++ b/runtime/Android.bp @@ -118,7 +118,6 @@ cc_defaults { "heapprofd_client_api", ], static_libs: [ - "libmodules-utils-build", "libstatslog_art", ], }, diff --git a/runtime/gc/collector/mark_compact.cc b/runtime/gc/collector/mark_compact.cc index f49c8cba7a..56ce5d27f6 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::IsAtLeastU; } // namespace #endif @@ -258,16 +256,12 @@ 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 || IsAtLeastU()) && !phenotype_force_disable; } #else // Never called. -static bool SysPropSaysUffdGc() { return false; } +static bool SysPropSaysUffdGc() { return true; } #endif static bool ShouldUseUserfaultfd() { |