From 45d0881f7444307955b51db5be88c5f890647c5e Mon Sep 17 00:00:00 2001 From: Jiakai Zhang Date: Wed, 4 May 2022 14:34:01 +0100 Subject: Re-compile on userfaultfd phenotype flag change. After this change, odrefresh re-compiles everything when the phenotype flag `runtime_native_boot.enable_uffd_gc` changes. It writes the value of the flag to cache-info.xml for change detection. According to go/platform-experiment-namespaces#namespace-types, the phenotype flag is back by a persistent system property. Therefore, we can directly read the flag from the system property instead of depending on the `server_configurable_flags` library. This behavior is consistent with the existing ART code (particularly, `art::Flag`), which reads other phenotype flags. Bug: 231298279 Test: atest odsign_e2e_tests_full Ignore-AOSP-First: Merge conflict. Will cherry-pick later. Change-Id: I02b70569ecd96d4ded6d2d3be22c34b2c6a4c5b4 --- odrefresh/odr_config.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'odrefresh/odr_config.h') diff --git a/odrefresh/odr_config.h b/odrefresh/odr_config.h index ec0290ccfe..c3f3c8010a 100644 --- a/odrefresh/odr_config.h +++ b/odrefresh/odr_config.h @@ -19,9 +19,11 @@ #include #include +#include #include #include "android-base/file.h" +#include "android-base/no_destructor.h" #include "arch/instruction_set.h" #include "base/file_utils.h" #include "base/globals.h" @@ -32,6 +34,17 @@ namespace art { namespace odrefresh { +struct SystemPropertyConfig { + const char* name; + const char* default_value; +}; + +// The system properties that odrefresh keeps track of. Odrefresh will recompile everything if any +// property changes. +const android::base::NoDestructor> kSystemProperties{ + {SystemPropertyConfig{.name = "persist.device_config.runtime_native_boot.enable_uffd_gc", + .default_value = "false"}}}; + // An enumeration of the possible zygote configurations on Android. enum class ZygoteKind : uint8_t { // 32-bit primary zygote, no secondary zygote. @@ -66,6 +79,9 @@ class OdrConfig final { bool compilation_os_mode_ = false; bool minimal_ = false; + // The current values of system properties listed in `kSystemProperties`. + std::unordered_map system_properties_; + // Staging directory for artifacts. The directory must exist and will be automatically removed // after compilation. If empty, use the default directory. std::string staging_dir_; @@ -148,6 +164,9 @@ class OdrConfig final { } bool GetCompilationOsMode() const { return compilation_os_mode_; } bool GetMinimal() const { return minimal_; } + const std::unordered_map& GetSystemProperties() const { + return system_properties_; + } void SetApexInfoListFile(const std::string& file_path) { apex_info_list_file_ = file_path; } void SetArtBinDir(const std::string& art_bin_dir) { art_bin_dir_ = art_bin_dir; } @@ -199,6 +218,10 @@ class OdrConfig final { void SetMinimal(bool value) { minimal_ = value; } + std::unordered_map* MutableSystemProperties() { + return &system_properties_; + } + private: // Returns a pair for the possible instruction sets for the configured instruction set // architecture. The first item is the 32-bit architecture and the second item is the 64-bit -- cgit v1.2.3-59-g8ed1b