summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Murray <timmurray@google.com>2016-02-02 02:13:31 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-02-02 02:13:31 +0000
commit88185f9ee8e15afdf69ca9374ff2608ab81a59ba (patch)
tree29a43b40e1f35c046d674c49da6de54b6244d7fc
parente7b92201d46d99bf8501a605860a7f0e1856798f (diff)
parent6647bb51301ea101b73e7431888f70bb35a4fabb (diff)
Merge "Enable top-app cpuset support."
-rw-r--r--include/cutils/sched_policy.h1
-rw-r--r--libcutils/sched_policy.c10
-rw-r--r--rootdir/init.rc7
3 files changed, 18 insertions, 0 deletions
diff --git a/include/cutils/sched_policy.h b/include/cutils/sched_policy.h
index 6a8d570b2..591bd4478 100644
--- a/include/cutils/sched_policy.h
+++ b/include/cutils/sched_policy.h
@@ -29,6 +29,7 @@ typedef enum {
SP_SYSTEM = 2, // can't be used with set_sched_policy()
SP_AUDIO_APP = 3,
SP_AUDIO_SYS = 4,
+ SP_TOP_APP = 5,
SP_CNT,
SP_MAX = SP_CNT - 1,
SP_SYSTEM_DEFAULT = SP_FOREGROUND,
diff --git a/libcutils/sched_policy.c b/libcutils/sched_policy.c
index 280a0834b..54d112290 100644
--- a/libcutils/sched_policy.c
+++ b/libcutils/sched_policy.c
@@ -65,6 +65,7 @@ static int fg_cgroup_fd = -1;
static int system_bg_cpuset_fd = -1;
static int bg_cpuset_fd = -1;
static int fg_cpuset_fd = -1;
+static int ta_cpuset_fd = -1; // special cpuset for top app
static int bg_schedboost_fd = -1;
static int fg_schedboost_fd = -1;
#endif
@@ -133,6 +134,8 @@ static void __initialize(void) {
bg_cpuset_fd = open(filename, O_WRONLY | O_CLOEXEC);
filename = "/dev/cpuset/system-background/tasks";
system_bg_cpuset_fd = open(filename, O_WRONLY | O_CLOEXEC);
+ filename = "/dev/cpuset/top-app/tasks";
+ ta_cpuset_fd = open(filename, O_WRONLY | O_CLOEXEC);
#ifdef USE_SCHEDBOOST
filename = "/sys/fs/cgroup/stune/foreground/tasks";
@@ -276,6 +279,10 @@ int set_cpuset_policy(int tid, SchedPolicy policy)
fd = fg_cpuset_fd;
boost_fd = fg_schedboost_fd;
break;
+ case SP_TOP_APP :
+ fd = ta_cpuset_fd;
+ boost_fd = fg_schedboost_fd;
+ break;
case SP_SYSTEM:
fd = system_bg_cpuset_fd;
boost_fd = bg_schedboost_fd;
@@ -337,6 +344,7 @@ int set_sched_policy(int tid, SchedPolicy policy)
case SP_FOREGROUND:
case SP_AUDIO_APP:
case SP_AUDIO_SYS:
+ case SP_TOP_APP:
SLOGD("^^^ tid %d (%s)", tid, thread_name);
break;
case SP_SYSTEM:
@@ -357,6 +365,7 @@ int set_sched_policy(int tid, SchedPolicy policy)
case SP_FOREGROUND:
case SP_AUDIO_APP:
case SP_AUDIO_SYS:
+ case SP_TOP_APP:
fd = fg_cgroup_fd;
break;
default:
@@ -411,6 +420,7 @@ const char *get_sched_policy_name(SchedPolicy policy)
[SP_SYSTEM] = " ",
[SP_AUDIO_APP] = "aa",
[SP_AUDIO_SYS] = "as",
+ [SP_TOP_APP] = "ta",
};
if ((policy < SP_CNT) && (strings[policy] != NULL))
return strings[policy];
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 438fe59ff..ee216faf6 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -173,17 +173,23 @@ on init
write /dev/cpuset/system-background/cpus 0
write /dev/cpuset/system-background/mems 0
+ mkdir /dev/cpuset/top-app
+ write /dev/cpuset/top-app/cpus 0
+ write /dev/cpuset/top-app/mems 0
+
# change permissions for all cpusets we'll touch at runtime
chown system system /dev/cpuset
chown system system /dev/cpuset/foreground
chown system system /dev/cpuset/foreground/boost
chown system system /dev/cpuset/background
chown system system /dev/cpuset/system-background
+ chown system system /dev/cpuset/top-app
chown system system /dev/cpuset/tasks
chown system system /dev/cpuset/foreground/tasks
chown system system /dev/cpuset/foreground/boost/tasks
chown system system /dev/cpuset/background/tasks
chown system system /dev/cpuset/system-background/tasks
+ chown system system /dev/cpuset/top-app/tasks
# set system-background to 0775 so SurfaceFlinger can touch it
chmod 0775 /dev/cpuset/system-background
@@ -192,6 +198,7 @@ on init
chmod 0664 /dev/cpuset/foreground/boost/tasks
chmod 0664 /dev/cpuset/background/tasks
chmod 0664 /dev/cpuset/system-background/tasks
+ chmod 0664 /dev/cpuset/top-app/tasks
chmod 0664 /dev/cpuset/tasks