Merge changes I13c9660a,I41745e7b,I0e6722b8

* changes:
  init.rc: correct the obsolete comment
  Add system-background cpu group
  init.rc: create camera-deamon stune cgroup
This commit is contained in:
Wei Wang 2020-12-03 18:57:25 +00:00 committed by Gerrit Code Review
commit 673b6d47bc
4 changed files with 37 additions and 5 deletions

View file

@ -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,

View file

@ -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" ]

View file

@ -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;

View file

@ -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,12 +208,22 @@ 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/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
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
@ -341,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