Merge "Make the default cgroup, the foreground cgroup." into lmp-mr1-dev
This commit is contained in:
commit
33b335495c
2 changed files with 11 additions and 38 deletions
|
|
@ -45,8 +45,6 @@ static inline SchedPolicy _policy(SchedPolicy p)
|
||||||
|
|
||||||
#define POLICY_DEBUG 0
|
#define POLICY_DEBUG 0
|
||||||
|
|
||||||
#define CAN_SET_SP_SYSTEM 0 // non-zero means to implement set_sched_policy(tid, SP_SYSTEM)
|
|
||||||
|
|
||||||
// This prctl is only available in Android kernels.
|
// This prctl is only available in Android kernels.
|
||||||
#define PR_SET_TIMERSLACK_PID 41
|
#define PR_SET_TIMERSLACK_PID 41
|
||||||
|
|
||||||
|
|
@ -60,9 +58,6 @@ static int __sys_supports_schedgroups = -1;
|
||||||
// File descriptors open to /dev/cpuctl/../tasks, setup by initialize, or -1 on error.
|
// File descriptors open to /dev/cpuctl/../tasks, setup by initialize, or -1 on error.
|
||||||
static int bg_cgroup_fd = -1;
|
static int bg_cgroup_fd = -1;
|
||||||
static int fg_cgroup_fd = -1;
|
static int fg_cgroup_fd = -1;
|
||||||
#if CAN_SET_SP_SYSTEM
|
|
||||||
static int system_cgroup_fd = -1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Add tid to the scheduling group defined by the policy */
|
/* Add tid to the scheduling group defined by the policy */
|
||||||
static int add_tid_to_cgroup(int tid, SchedPolicy policy)
|
static int add_tid_to_cgroup(int tid, SchedPolicy policy)
|
||||||
|
|
@ -78,11 +73,6 @@ static int add_tid_to_cgroup(int tid, SchedPolicy policy)
|
||||||
case SP_AUDIO_SYS:
|
case SP_AUDIO_SYS:
|
||||||
fd = fg_cgroup_fd;
|
fd = fg_cgroup_fd;
|
||||||
break;
|
break;
|
||||||
#if CAN_SET_SP_SYSTEM
|
|
||||||
case SP_SYSTEM:
|
|
||||||
fd = system_cgroup_fd;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
default:
|
||||||
fd = -1;
|
fd = -1;
|
||||||
break;
|
break;
|
||||||
|
|
@ -123,21 +113,13 @@ static void __initialize(void) {
|
||||||
if (!access("/dev/cpuctl/tasks", F_OK)) {
|
if (!access("/dev/cpuctl/tasks", F_OK)) {
|
||||||
__sys_supports_schedgroups = 1;
|
__sys_supports_schedgroups = 1;
|
||||||
|
|
||||||
#if CAN_SET_SP_SYSTEM
|
|
||||||
filename = "/dev/cpuctl/tasks";
|
filename = "/dev/cpuctl/tasks";
|
||||||
system_cgroup_fd = open(filename, O_WRONLY | O_CLOEXEC);
|
|
||||||
if (system_cgroup_fd < 0) {
|
|
||||||
SLOGV("open of %s failed: %s\n", filename, strerror(errno));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
filename = "/dev/cpuctl/apps/tasks";
|
|
||||||
fg_cgroup_fd = open(filename, O_WRONLY | O_CLOEXEC);
|
fg_cgroup_fd = open(filename, O_WRONLY | O_CLOEXEC);
|
||||||
if (fg_cgroup_fd < 0) {
|
if (fg_cgroup_fd < 0) {
|
||||||
SLOGE("open of %s failed: %s\n", filename, strerror(errno));
|
SLOGE("open of %s failed: %s\n", filename, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
filename = "/dev/cpuctl/apps/bg_non_interactive/tasks";
|
filename = "/dev/cpuctl/bg_non_interactive/tasks";
|
||||||
bg_cgroup_fd = open(filename, O_WRONLY | O_CLOEXEC);
|
bg_cgroup_fd = open(filename, O_WRONLY | O_CLOEXEC);
|
||||||
if (bg_cgroup_fd < 0) {
|
if (bg_cgroup_fd < 0) {
|
||||||
SLOGE("open of %s failed: %s\n", filename, strerror(errno));
|
SLOGE("open of %s failed: %s\n", filename, strerror(errno));
|
||||||
|
|
@ -233,11 +215,9 @@ int get_sched_policy(int tid, SchedPolicy *policy)
|
||||||
if (getSchedulerGroup(tid, grpBuf, sizeof(grpBuf)) < 0)
|
if (getSchedulerGroup(tid, grpBuf, sizeof(grpBuf)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (grpBuf[0] == '\0') {
|
if (grpBuf[0] == '\0') {
|
||||||
*policy = SP_SYSTEM;
|
|
||||||
} else if (!strcmp(grpBuf, "apps/bg_non_interactive")) {
|
|
||||||
*policy = SP_BACKGROUND;
|
|
||||||
} else if (!strcmp(grpBuf, "apps")) {
|
|
||||||
*policy = SP_FOREGROUND;
|
*policy = SP_FOREGROUND;
|
||||||
|
} else if (!strcmp(grpBuf, "bg_non_interactive")) {
|
||||||
|
*policy = SP_BACKGROUND;
|
||||||
} else {
|
} else {
|
||||||
errno = ERANGE;
|
errno = ERANGE;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
|
|
@ -119,25 +119,18 @@ on init
|
||||||
mount cgroup none /dev/cpuctl cpu
|
mount cgroup none /dev/cpuctl cpu
|
||||||
chown system system /dev/cpuctl
|
chown system system /dev/cpuctl
|
||||||
chown system system /dev/cpuctl/tasks
|
chown system system /dev/cpuctl/tasks
|
||||||
chmod 0660 /dev/cpuctl/tasks
|
chmod 0666 /dev/cpuctl/tasks
|
||||||
write /dev/cpuctl/cpu.shares 1024
|
write /dev/cpuctl/cpu.shares 1024
|
||||||
write /dev/cpuctl/cpu.rt_runtime_us 950000
|
write /dev/cpuctl/cpu.rt_runtime_us 800000
|
||||||
write /dev/cpuctl/cpu.rt_period_us 1000000
|
write /dev/cpuctl/cpu.rt_period_us 1000000
|
||||||
|
|
||||||
mkdir /dev/cpuctl/apps
|
mkdir /dev/cpuctl/bg_non_interactive
|
||||||
chown system system /dev/cpuctl/apps/tasks
|
chown system system /dev/cpuctl/bg_non_interactive/tasks
|
||||||
chmod 0666 /dev/cpuctl/apps/tasks
|
chmod 0666 /dev/cpuctl/bg_non_interactive/tasks
|
||||||
write /dev/cpuctl/apps/cpu.shares 1024
|
|
||||||
write /dev/cpuctl/apps/cpu.rt_runtime_us 800000
|
|
||||||
write /dev/cpuctl/apps/cpu.rt_period_us 1000000
|
|
||||||
|
|
||||||
mkdir /dev/cpuctl/apps/bg_non_interactive
|
|
||||||
chown system system /dev/cpuctl/apps/bg_non_interactive/tasks
|
|
||||||
chmod 0666 /dev/cpuctl/apps/bg_non_interactive/tasks
|
|
||||||
# 5.0 %
|
# 5.0 %
|
||||||
write /dev/cpuctl/apps/bg_non_interactive/cpu.shares 52
|
write /dev/cpuctl/bg_non_interactive/cpu.shares 52
|
||||||
write /dev/cpuctl/apps/bg_non_interactive/cpu.rt_runtime_us 700000
|
write /dev/cpuctl/bg_non_interactive/cpu.rt_runtime_us 700000
|
||||||
write /dev/cpuctl/apps/bg_non_interactive/cpu.rt_period_us 1000000
|
write /dev/cpuctl/bg_non_interactive/cpu.rt_period_us 1000000
|
||||||
|
|
||||||
# qtaguid will limit access to specific data based on group memberships.
|
# qtaguid will limit access to specific data based on group memberships.
|
||||||
# net_bw_acct grants impersonation of socket owners.
|
# net_bw_acct grants impersonation of socket owners.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue