Loading init/oneshot_on_test.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -39,11 +39,13 @@ TEST(init, oneshot_on) { // Bootanim exits quickly when the device is fully booted, so check that it goes back to the // 'restarting' state that non-oneshot services enter once they've restarted. EXPECT_TRUE(WaitForProperty("init.svc.bootanim", "restarting", 10s)); EXPECT_TRUE(WaitForProperty("init.svc.bootanim", "restarting", 10s)) << "Value is: " << GetProperty("init.svc.bootanim", ""); SetProperty("ctl.oneshot_on", "bootanim"); SetProperty("ctl.start", "bootanim"); // Now that oneshot is enabled again, bootanim should transition into the 'stopped' state. EXPECT_TRUE(WaitForProperty("init.svc.bootanim", "stopped", 10s)); EXPECT_TRUE(WaitForProperty("init.svc.bootanim", "stopped", 10s)) << "Value is: " << GetProperty("init.svc.bootanim", ""); } libprocessgroup/Android.bp +0 −6 Original line number Diff line number Diff line Loading @@ -7,7 +7,6 @@ soong_config_module_type { module_type: "cc_defaults", config_namespace: "ANDROID", bool_variables: [ "memcg_v2_force_enabled", "cgroup_v2_sys_app_isolation", ], properties: [ Loading @@ -19,11 +18,6 @@ libprocessgroup_flag_aware_cc_defaults { name: "libprocessgroup_build_flags_cc", cpp_std: "gnu++23", soong_config_variables: { memcg_v2_force_enabled: { cflags: [ "-DMEMCG_V2_FORCE_ENABLED=true", ], }, cgroup_v2_sys_app_isolation: { cflags: [ "-DCGROUP_V2_SYS_APP_ISOLATION=true", Loading libprocessgroup/build_flags.h +0 −8 Original line number Diff line number Diff line Loading @@ -16,20 +16,12 @@ #pragma once #ifndef MEMCG_V2_FORCE_ENABLED #define MEMCG_V2_FORCE_ENABLED false #endif #ifndef CGROUP_V2_SYS_APP_ISOLATION #define CGROUP_V2_SYS_APP_ISOLATION false #endif namespace android::libprocessgroup_flags { inline consteval bool force_memcg_v2() { return MEMCG_V2_FORCE_ENABLED; } inline consteval bool cgroup_v2_sys_app_isolation() { return CGROUP_V2_SYS_APP_ISOLATION; } Loading libprocessgroup/setup/cgroup_map_write.cpp +0 −47 Original line number Diff line number Diff line Loading @@ -27,9 +27,6 @@ #include <sys/types.h> #include <unistd.h> #include <optional> #include <android-base/file.h> #include <android-base/logging.h> #include <processgroup/cgroup_descriptor.h> #include <processgroup/processgroup.h> Loading Loading @@ -260,39 +257,6 @@ void CgroupDescriptor::set_mounted(bool mounted) { controller_.set_flags(flags); } static std::optional<bool> MGLRUDisabled() { const std::string file_name = "/sys/kernel/mm/lru_gen/enabled"; std::string content; if (!android::base::ReadFileToString(file_name, &content)) { PLOG(ERROR) << "Failed to read MGLRU state from " << file_name; return {}; } return content == "0x0000"; } static std::optional<bool> MEMCGDisabled(const CgroupDescriptorMap& descriptors) { std::string cgroup_v2_root = CGROUP_V2_ROOT_DEFAULT; const auto it = descriptors.find(CGROUPV2_HIERARCHY_NAME); if (it == descriptors.end()) { LOG(WARNING) << "No Cgroups2 path found in cgroups.json. Vendor has modified Android, and " << "kernel memory use will be higher than intended."; } else if (it->second.controller()->path() != cgroup_v2_root) { cgroup_v2_root = it->second.controller()->path(); } const std::string file_name = cgroup_v2_root + "/cgroup.controllers"; std::string content; if (!android::base::ReadFileToString(file_name, &content)) { PLOG(ERROR) << "Failed to read cgroup controllers from " << file_name; return {}; } // If we've forced memcg to v2 and it's not available, then it could only have been disabled // on the kernel command line (GKI sets CONFIG_MEMCG). return content.find("memory") == std::string::npos; } static bool CreateV2SubHierarchy(const std::string& path, const CgroupDescriptorMap& descriptors) { const auto cgv2_iter = descriptors.find(CGROUPV2_HIERARCHY_NAME); if (cgv2_iter == descriptors.end()) return false; Loading Loading @@ -335,17 +299,6 @@ bool CgroupSetup() { } } if (android::libprocessgroup_flags::force_memcg_v2()) { if (MGLRUDisabled().value_or(false)) { LOG(WARNING) << "Memcg forced to v2 hierarchy with MGLRU disabled! " << "Global reclaim performance will suffer."; } if (MEMCGDisabled(descriptors).value_or(false)) { LOG(WARNING) << "Memcg forced to v2 hierarchy while memcg is disabled by kernel " << "command line!"; } } // System / app isolation. // This really belongs in early-init in init.rc, but we cannot use the flag there. if (android::libprocessgroup_flags::cgroup_v2_sys_app_isolation()) { Loading libprocessgroup/util/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ package { cc_library_static { name: "libprocessgroup_util", cpp_std: "gnu++23", vendor_available: true, product_available: true, ramdisk_available: true, Loading @@ -47,7 +48,6 @@ cc_library_static { static_libs: [ "libjsoncpp", ], defaults: ["libprocessgroup_build_flags_cc"], } cc_test { Loading Loading
init/oneshot_on_test.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -39,11 +39,13 @@ TEST(init, oneshot_on) { // Bootanim exits quickly when the device is fully booted, so check that it goes back to the // 'restarting' state that non-oneshot services enter once they've restarted. EXPECT_TRUE(WaitForProperty("init.svc.bootanim", "restarting", 10s)); EXPECT_TRUE(WaitForProperty("init.svc.bootanim", "restarting", 10s)) << "Value is: " << GetProperty("init.svc.bootanim", ""); SetProperty("ctl.oneshot_on", "bootanim"); SetProperty("ctl.start", "bootanim"); // Now that oneshot is enabled again, bootanim should transition into the 'stopped' state. EXPECT_TRUE(WaitForProperty("init.svc.bootanim", "stopped", 10s)); EXPECT_TRUE(WaitForProperty("init.svc.bootanim", "stopped", 10s)) << "Value is: " << GetProperty("init.svc.bootanim", ""); }
libprocessgroup/Android.bp +0 −6 Original line number Diff line number Diff line Loading @@ -7,7 +7,6 @@ soong_config_module_type { module_type: "cc_defaults", config_namespace: "ANDROID", bool_variables: [ "memcg_v2_force_enabled", "cgroup_v2_sys_app_isolation", ], properties: [ Loading @@ -19,11 +18,6 @@ libprocessgroup_flag_aware_cc_defaults { name: "libprocessgroup_build_flags_cc", cpp_std: "gnu++23", soong_config_variables: { memcg_v2_force_enabled: { cflags: [ "-DMEMCG_V2_FORCE_ENABLED=true", ], }, cgroup_v2_sys_app_isolation: { cflags: [ "-DCGROUP_V2_SYS_APP_ISOLATION=true", Loading
libprocessgroup/build_flags.h +0 −8 Original line number Diff line number Diff line Loading @@ -16,20 +16,12 @@ #pragma once #ifndef MEMCG_V2_FORCE_ENABLED #define MEMCG_V2_FORCE_ENABLED false #endif #ifndef CGROUP_V2_SYS_APP_ISOLATION #define CGROUP_V2_SYS_APP_ISOLATION false #endif namespace android::libprocessgroup_flags { inline consteval bool force_memcg_v2() { return MEMCG_V2_FORCE_ENABLED; } inline consteval bool cgroup_v2_sys_app_isolation() { return CGROUP_V2_SYS_APP_ISOLATION; } Loading
libprocessgroup/setup/cgroup_map_write.cpp +0 −47 Original line number Diff line number Diff line Loading @@ -27,9 +27,6 @@ #include <sys/types.h> #include <unistd.h> #include <optional> #include <android-base/file.h> #include <android-base/logging.h> #include <processgroup/cgroup_descriptor.h> #include <processgroup/processgroup.h> Loading Loading @@ -260,39 +257,6 @@ void CgroupDescriptor::set_mounted(bool mounted) { controller_.set_flags(flags); } static std::optional<bool> MGLRUDisabled() { const std::string file_name = "/sys/kernel/mm/lru_gen/enabled"; std::string content; if (!android::base::ReadFileToString(file_name, &content)) { PLOG(ERROR) << "Failed to read MGLRU state from " << file_name; return {}; } return content == "0x0000"; } static std::optional<bool> MEMCGDisabled(const CgroupDescriptorMap& descriptors) { std::string cgroup_v2_root = CGROUP_V2_ROOT_DEFAULT; const auto it = descriptors.find(CGROUPV2_HIERARCHY_NAME); if (it == descriptors.end()) { LOG(WARNING) << "No Cgroups2 path found in cgroups.json. Vendor has modified Android, and " << "kernel memory use will be higher than intended."; } else if (it->second.controller()->path() != cgroup_v2_root) { cgroup_v2_root = it->second.controller()->path(); } const std::string file_name = cgroup_v2_root + "/cgroup.controllers"; std::string content; if (!android::base::ReadFileToString(file_name, &content)) { PLOG(ERROR) << "Failed to read cgroup controllers from " << file_name; return {}; } // If we've forced memcg to v2 and it's not available, then it could only have been disabled // on the kernel command line (GKI sets CONFIG_MEMCG). return content.find("memory") == std::string::npos; } static bool CreateV2SubHierarchy(const std::string& path, const CgroupDescriptorMap& descriptors) { const auto cgv2_iter = descriptors.find(CGROUPV2_HIERARCHY_NAME); if (cgv2_iter == descriptors.end()) return false; Loading Loading @@ -335,17 +299,6 @@ bool CgroupSetup() { } } if (android::libprocessgroup_flags::force_memcg_v2()) { if (MGLRUDisabled().value_or(false)) { LOG(WARNING) << "Memcg forced to v2 hierarchy with MGLRU disabled! " << "Global reclaim performance will suffer."; } if (MEMCGDisabled(descriptors).value_or(false)) { LOG(WARNING) << "Memcg forced to v2 hierarchy while memcg is disabled by kernel " << "command line!"; } } // System / app isolation. // This really belongs in early-init in init.rc, but we cannot use the flag there. if (android::libprocessgroup_flags::cgroup_v2_sys_app_isolation()) { Loading
libprocessgroup/util/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ package { cc_library_static { name: "libprocessgroup_util", cpp_std: "gnu++23", vendor_available: true, product_available: true, ramdisk_available: true, Loading @@ -47,7 +48,6 @@ cc_library_static { static_libs: [ "libjsoncpp", ], defaults: ["libprocessgroup_build_flags_cc"], } cc_test { Loading