From 6a28572648bb5573c44a2a33f735ad86a8deb374 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Mon, 30 Nov 2020 10:56:29 -0800 Subject: [PATCH 1/3] init.rc: create camera-deamon stune cgroup camera-daemon is referred in task-profiles.json so the hierarchy should be created in aosp's init.rc. Bug: 170507876 Bug: 171740453 Test: boot and check cgroup Change-Id: I0e6722b88922abf4ccae3b19623d8b889a6e3cb6 --- rootdir/init.rc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/rootdir/init.rc b/rootdir/init.rc index 25ff5ff2f..6d497d1cf 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc @@ -204,12 +204,20 @@ on init write /dev/cpuctl/rt/cpu.rt_period_us 1000000 write /dev/cpuctl/system/cpu.rt_runtime_us 100000 write /dev/cpuctl/system/cpu.rt_period_us 1000000 - write /dev/cpuctl/nnapi-hal/cpu.rt_runtime_us 100000 + write /dev/cpuctl/nnapi-hal/cpu.rt_runtime_us 50000 write /dev/cpuctl/nnapi-hal/cpu.rt_period_us 1000000 + write /dev/cpuctl/camera-daemon/cpu.rt_runtime_us 50000 + write /dev/cpuctl/camera-daemon/cpu.rt_period_us 1000000 # Migrate root group to system subgroup copy_per_line /dev/cpuctl/tasks /dev/cpuctl/system/tasks + # Create an stune group for camera-specific processes + mkdir /dev/stune/camera-daemon + chown system system /dev/stune/camera-daemon + chown system system /dev/stune/camera-daemon/tasks + chmod 0664 /dev/stune/camera-daemon/tasks + # Create an stune group for NNAPI HAL processes mkdir /dev/stune/nnapi-hal chown system system /dev/stune/nnapi-hal From ab87979a006cedd067b988d1dfd6c617270302d5 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Tue, 24 Nov 2020 00:26:40 -0800 Subject: [PATCH 2/3] Add system-background cpu group Add system-background cgroup hierarchy for uclamp and cpu bandwidth tuning. Bug: 170507876 Bug: 171740453 Test: boot and check cgroup Change-Id: I41745e7b3ac5c1d7ea7dd77f5db39c6895047446 --- .../include/processgroup/sched_policy.h | 2 +- libprocessgroup/profiles/task_profiles.json | 17 +++++++++++++++++ libprocessgroup/sched_policy.cpp | 4 +++- rootdir/init.rc | 8 +++++++- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/libprocessgroup/include/processgroup/sched_policy.h b/libprocessgroup/include/processgroup/sched_policy.h index 945d90ce3..a18847ee7 100644 --- a/libprocessgroup/include/processgroup/sched_policy.h +++ b/libprocessgroup/include/processgroup/sched_policy.h @@ -42,7 +42,7 @@ typedef enum { SP_DEFAULT = -1, SP_BACKGROUND = 0, SP_FOREGROUND = 1, - SP_SYSTEM = 2, // can't be used with set_sched_policy() + SP_SYSTEM = 2, SP_AUDIO_APP = 3, SP_AUDIO_SYS = 4, SP_TOP_APP = 5, diff --git a/libprocessgroup/profiles/task_profiles.json b/libprocessgroup/profiles/task_profiles.json index b528fa5f8..5b57bdd12 100644 --- a/libprocessgroup/profiles/task_profiles.json +++ b/libprocessgroup/profiles/task_profiles.json @@ -105,6 +105,19 @@ } ] }, + { + "Name": "ServicePerformance", + "Actions": [ + { + "Name": "JoinCgroup", + "Params": + { + "Controller": "cpu", + "Path": "system-background" + } + } + ] + }, { "Name": "HighPerformance", "Actions": [ @@ -590,6 +603,10 @@ "Name": "SCHED_SP_TOP_APP", "Profiles": [ "MaxPerformance", "MaxIoPriority", "TimerSlackNormal" ] }, + { + "Name": "SCHED_SP_SYSTEM", + "Profiles": [ "ServicePerformance", "LowIoPriority", "TimerSlackNormal" ] + }, { "Name": "SCHED_SP_RT_APP", "Profiles": [ "RealtimePerformance", "MaxIoPriority", "TimerSlackNormal" ] diff --git a/libprocessgroup/sched_policy.cpp b/libprocessgroup/sched_policy.cpp index 698e74d40..c51ee6189 100644 --- a/libprocessgroup/sched_policy.cpp +++ b/libprocessgroup/sched_policy.cpp @@ -124,6 +124,8 @@ int set_sched_policy(int tid, SchedPolicy policy) { return SetTaskProfiles(tid, {"SCHED_SP_FOREGROUND"}, true) ? 0 : -1; case SP_TOP_APP: return SetTaskProfiles(tid, {"SCHED_SP_TOP_APP"}, true) ? 0 : -1; + case SP_SYSTEM: + return SetTaskProfiles(tid, {"SCHED_SP_SYSTEM"}, true) ? 0 : -1; case SP_RT_APP: return SetTaskProfiles(tid, {"SCHED_SP_RT_APP"}, true) ? 0 : -1; default: @@ -258,7 +260,7 @@ const char* get_sched_policy_profile_name(SchedPolicy policy) { */ static constexpr const char* kSchedProfiles[SP_CNT + 1] = { "SCHED_SP_DEFAULT", "SCHED_SP_BACKGROUND", "SCHED_SP_FOREGROUND", - "SCHED_SP_DEFAULT", "SCHED_SP_FOREGROUND", "SCHED_SP_FOREGROUND", + "SCHED_SP_SYSTEM", "SCHED_SP_FOREGROUND", "SCHED_SP_FOREGROUND", "SCHED_SP_TOP_APP", "SCHED_SP_RT_APP", "SCHED_SP_DEFAULT"}; if (policy < SP_DEFAULT || policy >= SP_CNT) { return nullptr; diff --git a/rootdir/init.rc b/rootdir/init.rc index 6d497d1cf..9e1b6af2f 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc @@ -154,24 +154,28 @@ on init mkdir /dev/cpuctl/top-app mkdir /dev/cpuctl/rt mkdir /dev/cpuctl/system + mkdir /dev/cpuctl/system-background chown system system /dev/cpuctl chown system system /dev/cpuctl/foreground chown system system /dev/cpuctl/background chown system system /dev/cpuctl/top-app chown system system /dev/cpuctl/rt chown system system /dev/cpuctl/system + chown system system /dev/cpuctl/system-background chown system system /dev/cpuctl/tasks chown system system /dev/cpuctl/foreground/tasks chown system system /dev/cpuctl/background/tasks chown system system /dev/cpuctl/top-app/tasks chown system system /dev/cpuctl/rt/tasks chown system system /dev/cpuctl/system/tasks + chown system system /dev/cpuctl/system-background/tasks chmod 0664 /dev/cpuctl/tasks chmod 0664 /dev/cpuctl/foreground/tasks chmod 0664 /dev/cpuctl/background/tasks chmod 0664 /dev/cpuctl/top-app/tasks chmod 0664 /dev/cpuctl/rt/tasks chmod 0664 /dev/cpuctl/system/tasks + chmod 0664 /dev/cpuctl/system-background/tasks # Create a cpu group for NNAPI HAL processes mkdir /dev/cpuctl/nnapi-hal @@ -196,7 +200,7 @@ on init # Surfaceflinger is in FG group so giving it a bit more write /dev/cpuctl/foreground/cpu.rt_runtime_us 450000 write /dev/cpuctl/foreground/cpu.rt_period_us 1000000 - write /dev/cpuctl/background/cpu.rt_runtime_us 100000 + write /dev/cpuctl/background/cpu.rt_runtime_us 50000 write /dev/cpuctl/background/cpu.rt_period_us 1000000 write /dev/cpuctl/top-app/cpu.rt_runtime_us 100000 write /dev/cpuctl/top-app/cpu.rt_period_us 1000000 @@ -204,6 +208,8 @@ on init write /dev/cpuctl/rt/cpu.rt_period_us 1000000 write /dev/cpuctl/system/cpu.rt_runtime_us 100000 write /dev/cpuctl/system/cpu.rt_period_us 1000000 + write /dev/cpuctl/system-background/cpu.rt_runtime_us 50000 + write /dev/cpuctl/system-background/cpu.rt_period_us 1000000 write /dev/cpuctl/nnapi-hal/cpu.rt_runtime_us 50000 write /dev/cpuctl/nnapi-hal/cpu.rt_period_us 1000000 write /dev/cpuctl/camera-daemon/cpu.rt_runtime_us 50000 From aed52ef138ce1927f0884ae1b401ba68e9eeac8f Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Mon, 30 Nov 2020 11:44:23 -0800 Subject: [PATCH 3/3] init.rc: correct the obsolete comment system-background cpuset is mapped in tasks_profiles.json. Bug: 170507876 Test: Build Change-Id: I13c9660a1288e22382ced4dd31f079f31bf7c8dc --- rootdir/init.rc | 1 - 1 file changed, 1 deletion(-) diff --git a/rootdir/init.rc b/rootdir/init.rc index 9e1b6af2f..b71a98e81 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc @@ -355,7 +355,6 @@ on init # system-background is for system tasks that should only run on # little cores, not on bigs - # to be used only by init, so don't change system-bg permissions mkdir /dev/cpuset/system-background copy /dev/cpuset/cpus /dev/cpuset/system-background/cpus copy /dev/cpuset/mems /dev/cpuset/system-background/mems