Loading fs_mgr/fs_mgr_overlayfs.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -715,7 +715,7 @@ bool fs_mgr_overlayfs_create_scratch(const Fstab& fstab, std::string* scratch_de } if (changed || partition_create) { if (!CreateLogicalPartition(super_device, slot_number, partition_name, true, 0s, if (!CreateLogicalPartition(super_device, slot_number, partition_name, true, 10s, scratch_device)) return false; Loading Loading @@ -940,7 +940,7 @@ bool fs_mgr_overlayfs_teardown(const char* mount_point, bool* change) { auto slot_number = fs_mgr_overlayfs_slot_number(); auto super_device = fs_mgr_overlayfs_super_device(slot_number); const auto partition_name = android::base::Basename(kScratchMountPoint); CreateLogicalPartition(super_device, slot_number, partition_name, true, 0s, CreateLogicalPartition(super_device, slot_number, partition_name, true, 10s, &scratch_device); } mount_scratch = fs_mgr_overlayfs_mount_scratch(scratch_device, Loading init/Android.mk +5 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,11 @@ LOCAL_FORCE_STATIC_EXECUTABLE := true LOCAL_MODULE_PATH := $(TARGET_RAMDISK_OUT) LOCAL_UNSTRIPPED_PATH := $(TARGET_RAMDISK_OUT_UNSTRIPPED) # Install adb_debug.prop into debug ramdisk. # This allows adb root on a user build, when debug ramdisk is used. LOCAL_REQUIRED_MODULES := \ adb_debug.prop \ # Set up the same mount points on the ramdisk that system-as-root contains. LOCAL_POST_INSTALL_CMD := mkdir -p \ $(TARGET_RAMDISK_OUT)/apex \ Loading libprocessgroup/include/processgroup/processgroup.h +10 −4 Original line number Diff line number Diff line Loading @@ -24,16 +24,20 @@ __BEGIN_DECLS static constexpr const char* CGROUPV2_CONTROLLER_NAME = "cgroup2"; static constexpr const char* CGROUPS_RC_PATH = "/dev/cgroup_info/cgroup.rc"; bool CgroupGetControllerPath(const std::string& cgroup_name, std::string* path); bool CgroupGetAttributePath(const std::string& attr_name, std::string* path); bool CgroupGetAttributePathForTask(const std::string& attr_name, int tid, std::string* path); bool UsePerAppMemcg(); bool SetTaskProfiles(int tid, const std::vector<std::string>& profiles, bool use_fd_cache = false); bool SetProcessProfiles(uid_t uid, pid_t pid, const std::vector<std::string>& profiles, bool use_fd_cache = false); bool SetTaskProfiles(int tid, const std::vector<std::string>& profiles); bool SetProcessProfiles(uid_t uid, pid_t pid, const std::vector<std::string>& profiles); #ifndef __ANDROID_VNDK__ static constexpr const char* CGROUPS_RC_PATH = "/dev/cgroup_info/cgroup.rc"; bool UsePerAppMemcg(); // Return 0 and removes the cgroup if there are no longer any processes in it. // Returns -1 in the case of an error occurring or if there are processes still running Loading @@ -54,4 +58,6 @@ bool setProcessGroupLimit(uid_t uid, int initialPid, int64_t limitInBytes); void removeAllProcessGroups(void); #endif // __ANDROID_VNDK__ __END_DECLS libprocessgroup/processgroup.cpp +11 −4 Original line number Diff line number Diff line Loading @@ -112,12 +112,16 @@ static bool isMemoryCgroupSupported() { return memcg_supported; } bool SetProcessProfiles(uid_t uid, pid_t pid, const std::vector<std::string>& profiles) { bool SetProcessProfiles(uid_t uid, pid_t pid, const std::vector<std::string>& profiles, bool use_fd_cache) { const TaskProfiles& tp = TaskProfiles::GetInstance(); for (const auto& name : profiles) { const TaskProfile* profile = tp.GetProfile(name); TaskProfile* profile = tp.GetProfile(name); if (profile != nullptr) { if (use_fd_cache) { profile->EnableResourceCaching(); } if (!profile->ExecuteForProcess(uid, pid)) { PLOG(WARNING) << "Failed to apply " << name << " process profile"; } Loading @@ -129,12 +133,15 @@ bool SetProcessProfiles(uid_t uid, pid_t pid, const std::vector<std::string>& pr return true; } bool SetTaskProfiles(int tid, const std::vector<std::string>& profiles) { bool SetTaskProfiles(int tid, const std::vector<std::string>& profiles, bool use_fd_cache) { const TaskProfiles& tp = TaskProfiles::GetInstance(); for (const auto& name : profiles) { const TaskProfile* profile = tp.GetProfile(name); TaskProfile* profile = tp.GetProfile(name); if (profile != nullptr) { if (use_fd_cache) { profile->EnableResourceCaching(); } if (!profile->ExecuteForTask(tid)) { PLOG(WARNING) << "Failed to apply " << name << " task profile"; } Loading libprocessgroup/sched_policy.cpp +21 −13 Original line number Diff line number Diff line Loading @@ -46,26 +46,34 @@ int set_cpuset_policy(int tid, SchedPolicy policy) { switch (policy) { case SP_BACKGROUND: return SetTaskProfiles(tid, {"HighEnergySaving", "ProcessCapacityLow", "LowIoPriority", "TimerSlackHigh"}) return SetTaskProfiles(tid, {"HighEnergySaving", "ProcessCapacityLow", "LowIoPriority", "TimerSlackHigh"}, true) ? 0 : -1; case SP_FOREGROUND: case SP_AUDIO_APP: case SP_AUDIO_SYS: return SetTaskProfiles(tid, {"HighPerformance", "ProcessCapacityHigh", "HighIoPriority", "TimerSlackNormal"}) return SetTaskProfiles(tid, {"HighPerformance", "ProcessCapacityHigh", "HighIoPriority", "TimerSlackNormal"}, true) ? 0 : -1; case SP_TOP_APP: return SetTaskProfiles(tid, {"MaxPerformance", "ProcessCapacityMax", "MaxIoPriority", "TimerSlackNormal"}) return SetTaskProfiles(tid, {"MaxPerformance", "ProcessCapacityMax", "MaxIoPriority", "TimerSlackNormal"}, true) ? 0 : -1; case SP_SYSTEM: return SetTaskProfiles(tid, {"ServiceCapacityLow", "TimerSlackNormal"}) ? 0 : -1; return SetTaskProfiles(tid, {"ServiceCapacityLow", "TimerSlackNormal"}, true) ? 0 : -1; case SP_RESTRICTED: return SetTaskProfiles(tid, {"ServiceCapacityRestricted", "TimerSlackNormal"}) ? 0 : -1; return SetTaskProfiles(tid, {"ServiceCapacityRestricted", "TimerSlackNormal"}, true) ? 0 : -1; default: break; } Loading Loading @@ -126,17 +134,17 @@ int set_sched_policy(int tid, SchedPolicy policy) { switch (policy) { case SP_BACKGROUND: return SetTaskProfiles(tid, {"HighEnergySaving", "TimerSlackHigh"}) ? 0 : -1; return SetTaskProfiles(tid, {"HighEnergySaving", "TimerSlackHigh"}, true) ? 0 : -1; case SP_FOREGROUND: case SP_AUDIO_APP: case SP_AUDIO_SYS: return SetTaskProfiles(tid, {"HighPerformance", "TimerSlackNormal"}) ? 0 : -1; return SetTaskProfiles(tid, {"HighPerformance", "TimerSlackNormal"}, true) ? 0 : -1; case SP_TOP_APP: return SetTaskProfiles(tid, {"MaxPerformance", "TimerSlackNormal"}) ? 0 : -1; return SetTaskProfiles(tid, {"MaxPerformance", "TimerSlackNormal"}, true) ? 0 : -1; case SP_RT_APP: return SetTaskProfiles(tid, {"RealtimePerformance", "TimerSlackNormal"}) ? 0 : -1; return SetTaskProfiles(tid, {"RealtimePerformance", "TimerSlackNormal"}, true) ? 0 : -1; default: return SetTaskProfiles(tid, {"TimerSlackNormal"}) ? 0 : -1; return SetTaskProfiles(tid, {"TimerSlackNormal"}, true) ? 0 : -1; } return 0; Loading Loading
fs_mgr/fs_mgr_overlayfs.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -715,7 +715,7 @@ bool fs_mgr_overlayfs_create_scratch(const Fstab& fstab, std::string* scratch_de } if (changed || partition_create) { if (!CreateLogicalPartition(super_device, slot_number, partition_name, true, 0s, if (!CreateLogicalPartition(super_device, slot_number, partition_name, true, 10s, scratch_device)) return false; Loading Loading @@ -940,7 +940,7 @@ bool fs_mgr_overlayfs_teardown(const char* mount_point, bool* change) { auto slot_number = fs_mgr_overlayfs_slot_number(); auto super_device = fs_mgr_overlayfs_super_device(slot_number); const auto partition_name = android::base::Basename(kScratchMountPoint); CreateLogicalPartition(super_device, slot_number, partition_name, true, 0s, CreateLogicalPartition(super_device, slot_number, partition_name, true, 10s, &scratch_device); } mount_scratch = fs_mgr_overlayfs_mount_scratch(scratch_device, Loading
init/Android.mk +5 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,11 @@ LOCAL_FORCE_STATIC_EXECUTABLE := true LOCAL_MODULE_PATH := $(TARGET_RAMDISK_OUT) LOCAL_UNSTRIPPED_PATH := $(TARGET_RAMDISK_OUT_UNSTRIPPED) # Install adb_debug.prop into debug ramdisk. # This allows adb root on a user build, when debug ramdisk is used. LOCAL_REQUIRED_MODULES := \ adb_debug.prop \ # Set up the same mount points on the ramdisk that system-as-root contains. LOCAL_POST_INSTALL_CMD := mkdir -p \ $(TARGET_RAMDISK_OUT)/apex \ Loading
libprocessgroup/include/processgroup/processgroup.h +10 −4 Original line number Diff line number Diff line Loading @@ -24,16 +24,20 @@ __BEGIN_DECLS static constexpr const char* CGROUPV2_CONTROLLER_NAME = "cgroup2"; static constexpr const char* CGROUPS_RC_PATH = "/dev/cgroup_info/cgroup.rc"; bool CgroupGetControllerPath(const std::string& cgroup_name, std::string* path); bool CgroupGetAttributePath(const std::string& attr_name, std::string* path); bool CgroupGetAttributePathForTask(const std::string& attr_name, int tid, std::string* path); bool UsePerAppMemcg(); bool SetTaskProfiles(int tid, const std::vector<std::string>& profiles, bool use_fd_cache = false); bool SetProcessProfiles(uid_t uid, pid_t pid, const std::vector<std::string>& profiles, bool use_fd_cache = false); bool SetTaskProfiles(int tid, const std::vector<std::string>& profiles); bool SetProcessProfiles(uid_t uid, pid_t pid, const std::vector<std::string>& profiles); #ifndef __ANDROID_VNDK__ static constexpr const char* CGROUPS_RC_PATH = "/dev/cgroup_info/cgroup.rc"; bool UsePerAppMemcg(); // Return 0 and removes the cgroup if there are no longer any processes in it. // Returns -1 in the case of an error occurring or if there are processes still running Loading @@ -54,4 +58,6 @@ bool setProcessGroupLimit(uid_t uid, int initialPid, int64_t limitInBytes); void removeAllProcessGroups(void); #endif // __ANDROID_VNDK__ __END_DECLS
libprocessgroup/processgroup.cpp +11 −4 Original line number Diff line number Diff line Loading @@ -112,12 +112,16 @@ static bool isMemoryCgroupSupported() { return memcg_supported; } bool SetProcessProfiles(uid_t uid, pid_t pid, const std::vector<std::string>& profiles) { bool SetProcessProfiles(uid_t uid, pid_t pid, const std::vector<std::string>& profiles, bool use_fd_cache) { const TaskProfiles& tp = TaskProfiles::GetInstance(); for (const auto& name : profiles) { const TaskProfile* profile = tp.GetProfile(name); TaskProfile* profile = tp.GetProfile(name); if (profile != nullptr) { if (use_fd_cache) { profile->EnableResourceCaching(); } if (!profile->ExecuteForProcess(uid, pid)) { PLOG(WARNING) << "Failed to apply " << name << " process profile"; } Loading @@ -129,12 +133,15 @@ bool SetProcessProfiles(uid_t uid, pid_t pid, const std::vector<std::string>& pr return true; } bool SetTaskProfiles(int tid, const std::vector<std::string>& profiles) { bool SetTaskProfiles(int tid, const std::vector<std::string>& profiles, bool use_fd_cache) { const TaskProfiles& tp = TaskProfiles::GetInstance(); for (const auto& name : profiles) { const TaskProfile* profile = tp.GetProfile(name); TaskProfile* profile = tp.GetProfile(name); if (profile != nullptr) { if (use_fd_cache) { profile->EnableResourceCaching(); } if (!profile->ExecuteForTask(tid)) { PLOG(WARNING) << "Failed to apply " << name << " task profile"; } Loading
libprocessgroup/sched_policy.cpp +21 −13 Original line number Diff line number Diff line Loading @@ -46,26 +46,34 @@ int set_cpuset_policy(int tid, SchedPolicy policy) { switch (policy) { case SP_BACKGROUND: return SetTaskProfiles(tid, {"HighEnergySaving", "ProcessCapacityLow", "LowIoPriority", "TimerSlackHigh"}) return SetTaskProfiles(tid, {"HighEnergySaving", "ProcessCapacityLow", "LowIoPriority", "TimerSlackHigh"}, true) ? 0 : -1; case SP_FOREGROUND: case SP_AUDIO_APP: case SP_AUDIO_SYS: return SetTaskProfiles(tid, {"HighPerformance", "ProcessCapacityHigh", "HighIoPriority", "TimerSlackNormal"}) return SetTaskProfiles(tid, {"HighPerformance", "ProcessCapacityHigh", "HighIoPriority", "TimerSlackNormal"}, true) ? 0 : -1; case SP_TOP_APP: return SetTaskProfiles(tid, {"MaxPerformance", "ProcessCapacityMax", "MaxIoPriority", "TimerSlackNormal"}) return SetTaskProfiles(tid, {"MaxPerformance", "ProcessCapacityMax", "MaxIoPriority", "TimerSlackNormal"}, true) ? 0 : -1; case SP_SYSTEM: return SetTaskProfiles(tid, {"ServiceCapacityLow", "TimerSlackNormal"}) ? 0 : -1; return SetTaskProfiles(tid, {"ServiceCapacityLow", "TimerSlackNormal"}, true) ? 0 : -1; case SP_RESTRICTED: return SetTaskProfiles(tid, {"ServiceCapacityRestricted", "TimerSlackNormal"}) ? 0 : -1; return SetTaskProfiles(tid, {"ServiceCapacityRestricted", "TimerSlackNormal"}, true) ? 0 : -1; default: break; } Loading Loading @@ -126,17 +134,17 @@ int set_sched_policy(int tid, SchedPolicy policy) { switch (policy) { case SP_BACKGROUND: return SetTaskProfiles(tid, {"HighEnergySaving", "TimerSlackHigh"}) ? 0 : -1; return SetTaskProfiles(tid, {"HighEnergySaving", "TimerSlackHigh"}, true) ? 0 : -1; case SP_FOREGROUND: case SP_AUDIO_APP: case SP_AUDIO_SYS: return SetTaskProfiles(tid, {"HighPerformance", "TimerSlackNormal"}) ? 0 : -1; return SetTaskProfiles(tid, {"HighPerformance", "TimerSlackNormal"}, true) ? 0 : -1; case SP_TOP_APP: return SetTaskProfiles(tid, {"MaxPerformance", "TimerSlackNormal"}) ? 0 : -1; return SetTaskProfiles(tid, {"MaxPerformance", "TimerSlackNormal"}, true) ? 0 : -1; case SP_RT_APP: return SetTaskProfiles(tid, {"RealtimePerformance", "TimerSlackNormal"}) ? 0 : -1; return SetTaskProfiles(tid, {"RealtimePerformance", "TimerSlackNormal"}, true) ? 0 : -1; default: return SetTaskProfiles(tid, {"TimerSlackNormal"}) ? 0 : -1; return SetTaskProfiles(tid, {"TimerSlackNormal"}, true) ? 0 : -1; } return 0; Loading