kernel: introduce CPUSets Assist

Same concept as in stune assist:
A kernel-side helper to write default cpusets values
and forbid init from adjusting them.

Default values are set for Snapdragon 675 (6+2)

Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
[kdrag0n: Fixed typo in commit message]
Signed-off-by: Danny Lin <danny@kdrag0n.dev>
Signed-off-by: UtsavBalar1231 <utsavbalar1231@gmail.com>
This commit is contained in:
Yaroslav Furman
2019-06-11 23:03:11 +03:00
committed by UtsavBalar1231
parent 9e18f0f556
commit c45e65572c
2 changed files with 49 additions and 1 deletions

View File

@@ -1115,6 +1115,16 @@ config SCHED_TUNE
If unsure, say N.
config CPUSETS_ASSIST
bool "Cpusets configuration helper"
depends on CPUSETS
depends on ANDROID
help
This option enables the configuration of default cpusets
parameters from kernel.
If unsure, say N.
config DEFAULT_USE_ENERGY_AWARE
bool "Default to enabling the Energy Aware Scheduler feature"
default n

View File

@@ -1712,7 +1712,10 @@ static ssize_t cpuset_write_resmask(struct kernfs_open_file *of,
struct cpuset *trialcs;
int retval = -ENODEV;
#ifndef CONFIG_CPUSETS_ASSIST
/* Don't call strstrip here because buf is read-only */
buf = strstrip(buf);
#endif
/*
* CPU or memory hotunplug may leave @cs w/o any execution
@@ -1768,6 +1771,41 @@ out_unlock:
return retval ?: nbytes;
}
static ssize_t cpuset_write_resmask_wrapper(struct kernfs_open_file *of,
char *buf, size_t nbytes, loff_t off)
{
#ifdef CONFIG_CPUSETS_ASSIST
int i;
struct cpuset *cs = css_cs(of_css(of));
struct c_data {
char *c_name;
char *c_cpus;
};
struct c_data c_targets[6] = {
/* Silver only cpusets go first */
{ "foreground", "0-5"},//0-2,4-7
{ "background", "0-2"},//0-1
{ "system-background", "0-3"},//0-2
{ "restricted", "0-5"},//0-7
{ "top-app", "0-7"},//0-7
{ "camera-daemon", "0-3,6-7"}};//0-7
if (!strcmp(current->comm, "init")) {
for (i = 0; i < ARRAY_SIZE(c_targets); i++) {
if (!strcmp(cs->css.cgroup->kn->name, c_targets[i].c_name)) {
strcpy(buf, c_targets[i].c_cpus);
pr_info("%s: setting to %s\n", c_targets[i].c_name, buf);
break;
}
}
}
#endif
buf = strstrip(buf);
return cpuset_write_resmask(of, buf, nbytes, off);
}
/*
* These ascii lists should be read in a single call, by using a user
* buffer large enough to hold the entire map. If read in smaller
@@ -1860,7 +1898,7 @@ static struct cftype files[] = {
{
.name = "cpus",
.seq_show = cpuset_common_seq_show,
.write = cpuset_write_resmask,
.write = cpuset_write_resmask_wrapper,
.max_write_len = (100U + 6 * NR_CPUS),
.private = FILE_CPULIST,
},