cutils: add restricted cpuset
Bug 78197570 Test: CTS Exempt-From-Owner-Approval: owner OOO, build cop says it's fine Change-Id: I6df972950b75a839caa463ae282ad000b959e8ae
This commit is contained in:
parent
e58d713e47
commit
658ae90f69
3 changed files with 27 additions and 15 deletions
|
|
@ -40,16 +40,17 @@ extern bool schedboost_enabled();
|
||||||
|
|
||||||
/* Keep in sync with THREAD_GROUP_* in frameworks/base/core/java/android/os/Process.java */
|
/* Keep in sync with THREAD_GROUP_* in frameworks/base/core/java/android/os/Process.java */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SP_DEFAULT = -1,
|
SP_DEFAULT = -1,
|
||||||
SP_BACKGROUND = 0,
|
SP_BACKGROUND = 0,
|
||||||
SP_FOREGROUND = 1,
|
SP_FOREGROUND = 1,
|
||||||
SP_SYSTEM = 2, // can't be used with set_sched_policy()
|
SP_SYSTEM = 2, // can't be used with set_sched_policy()
|
||||||
SP_AUDIO_APP = 3,
|
SP_AUDIO_APP = 3,
|
||||||
SP_AUDIO_SYS = 4,
|
SP_AUDIO_SYS = 4,
|
||||||
SP_TOP_APP = 5,
|
SP_TOP_APP = 5,
|
||||||
SP_RT_APP = 6,
|
SP_RT_APP = 6,
|
||||||
|
SP_RESTRICTED = 7,
|
||||||
SP_CNT,
|
SP_CNT,
|
||||||
SP_MAX = SP_CNT - 1,
|
SP_MAX = SP_CNT - 1,
|
||||||
SP_SYSTEM_DEFAULT = SP_FOREGROUND,
|
SP_SYSTEM_DEFAULT = SP_FOREGROUND,
|
||||||
} SchedPolicy;
|
} SchedPolicy;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ static int system_bg_cpuset_fd = -1;
|
||||||
static int bg_cpuset_fd = -1;
|
static int bg_cpuset_fd = -1;
|
||||||
static int fg_cpuset_fd = -1;
|
static int fg_cpuset_fd = -1;
|
||||||
static int ta_cpuset_fd = -1; // special cpuset for top app
|
static int ta_cpuset_fd = -1; // special cpuset for top app
|
||||||
|
static int rs_cpuset_fd = -1; // special cpuset for screen off restrictions
|
||||||
|
|
||||||
// File descriptors open to /dev/stune/../tasks, setup by initialize, or -1 on error
|
// File descriptors open to /dev/stune/../tasks, setup by initialize, or -1 on error
|
||||||
static int bg_schedboost_fd = -1;
|
static int bg_schedboost_fd = -1;
|
||||||
|
|
@ -151,6 +152,8 @@ static void __initialize() {
|
||||||
system_bg_cpuset_fd = open(filename, O_WRONLY | O_CLOEXEC);
|
system_bg_cpuset_fd = open(filename, O_WRONLY | O_CLOEXEC);
|
||||||
filename = "/dev/cpuset/top-app/tasks";
|
filename = "/dev/cpuset/top-app/tasks";
|
||||||
ta_cpuset_fd = open(filename, O_WRONLY | O_CLOEXEC);
|
ta_cpuset_fd = open(filename, O_WRONLY | O_CLOEXEC);
|
||||||
|
filename = "/dev/cpuset/restricted/tasks";
|
||||||
|
rs_cpuset_fd = open(filename, O_WRONLY | O_CLOEXEC);
|
||||||
|
|
||||||
if (schedboost_enabled()) {
|
if (schedboost_enabled()) {
|
||||||
filename = "/dev/stune/top-app/tasks";
|
filename = "/dev/stune/top-app/tasks";
|
||||||
|
|
@ -308,6 +311,9 @@ int set_cpuset_policy(int tid, SchedPolicy policy)
|
||||||
case SP_SYSTEM:
|
case SP_SYSTEM:
|
||||||
fd = system_bg_cpuset_fd;
|
fd = system_bg_cpuset_fd;
|
||||||
break;
|
break;
|
||||||
|
case SP_RESTRICTED:
|
||||||
|
fd = rs_cpuset_fd;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
boost_fd = fd = -1;
|
boost_fd = fd = -1;
|
||||||
break;
|
break;
|
||||||
|
|
@ -457,14 +463,10 @@ int get_sched_policy(int /*tid*/, SchedPolicy* policy) {
|
||||||
const char *get_sched_policy_name(SchedPolicy policy)
|
const char *get_sched_policy_name(SchedPolicy policy)
|
||||||
{
|
{
|
||||||
policy = _policy(policy);
|
policy = _policy(policy);
|
||||||
static const char * const strings[SP_CNT] = {
|
static const char* const strings[SP_CNT] = {
|
||||||
[SP_BACKGROUND] = "bg",
|
[SP_BACKGROUND] = "bg", [SP_FOREGROUND] = "fg", [SP_SYSTEM] = " ",
|
||||||
[SP_FOREGROUND] = "fg",
|
[SP_AUDIO_APP] = "aa", [SP_AUDIO_SYS] = "as", [SP_TOP_APP] = "ta",
|
||||||
[SP_SYSTEM] = " ",
|
[SP_RT_APP] = "rt", [SP_RESTRICTED] = "rs",
|
||||||
[SP_AUDIO_APP] = "aa",
|
|
||||||
[SP_AUDIO_SYS] = "as",
|
|
||||||
[SP_TOP_APP] = "ta",
|
|
||||||
[SP_RT_APP] = "rt",
|
|
||||||
};
|
};
|
||||||
if ((policy < SP_CNT) && (strings[policy] != NULL))
|
if ((policy < SP_CNT) && (strings[policy] != NULL))
|
||||||
return strings[policy];
|
return strings[policy];
|
||||||
|
|
|
||||||
|
|
@ -176,6 +176,12 @@ on init
|
||||||
copy /dev/cpuset/cpus /dev/cpuset/system-background/cpus
|
copy /dev/cpuset/cpus /dev/cpuset/system-background/cpus
|
||||||
copy /dev/cpuset/mems /dev/cpuset/system-background/mems
|
copy /dev/cpuset/mems /dev/cpuset/system-background/mems
|
||||||
|
|
||||||
|
# restricted is for system tasks that are being throttled
|
||||||
|
# due to screen off.
|
||||||
|
mkdir /dev/cpuset/restricted
|
||||||
|
copy /dev/cpuset/cpus /dev/cpuset/restricted/cpus
|
||||||
|
copy /dev/cpuset/mems /dev/cpuset/restricted/mems
|
||||||
|
|
||||||
mkdir /dev/cpuset/top-app
|
mkdir /dev/cpuset/top-app
|
||||||
copy /dev/cpuset/cpus /dev/cpuset/top-app/cpus
|
copy /dev/cpuset/cpus /dev/cpuset/top-app/cpus
|
||||||
copy /dev/cpuset/mems /dev/cpuset/top-app/mems
|
copy /dev/cpuset/mems /dev/cpuset/top-app/mems
|
||||||
|
|
@ -186,11 +192,13 @@ on init
|
||||||
chown system system /dev/cpuset/background
|
chown system system /dev/cpuset/background
|
||||||
chown system system /dev/cpuset/system-background
|
chown system system /dev/cpuset/system-background
|
||||||
chown system system /dev/cpuset/top-app
|
chown system system /dev/cpuset/top-app
|
||||||
|
chown system system /dev/cpuset/restricted
|
||||||
chown system system /dev/cpuset/tasks
|
chown system system /dev/cpuset/tasks
|
||||||
chown system system /dev/cpuset/foreground/tasks
|
chown system system /dev/cpuset/foreground/tasks
|
||||||
chown system system /dev/cpuset/background/tasks
|
chown system system /dev/cpuset/background/tasks
|
||||||
chown system system /dev/cpuset/system-background/tasks
|
chown system system /dev/cpuset/system-background/tasks
|
||||||
chown system system /dev/cpuset/top-app/tasks
|
chown system system /dev/cpuset/top-app/tasks
|
||||||
|
chown system system /dev/cpuset/restricted/tasks
|
||||||
|
|
||||||
# set system-background to 0775 so SurfaceFlinger can touch it
|
# set system-background to 0775 so SurfaceFlinger can touch it
|
||||||
chmod 0775 /dev/cpuset/system-background
|
chmod 0775 /dev/cpuset/system-background
|
||||||
|
|
@ -199,6 +207,7 @@ on init
|
||||||
chmod 0664 /dev/cpuset/background/tasks
|
chmod 0664 /dev/cpuset/background/tasks
|
||||||
chmod 0664 /dev/cpuset/system-background/tasks
|
chmod 0664 /dev/cpuset/system-background/tasks
|
||||||
chmod 0664 /dev/cpuset/top-app/tasks
|
chmod 0664 /dev/cpuset/top-app/tasks
|
||||||
|
chmod 0664 /dev/cpuset/restricted/tasks
|
||||||
chmod 0664 /dev/cpuset/tasks
|
chmod 0664 /dev/cpuset/tasks
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue