diff --git a/init/Kconfig b/init/Kconfig index 2be6106f0d52..8e5089067452 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1116,12 +1116,11 @@ config SCHED_TUNE If unsure, say N. config CPUSETS_ASSIST - bool "Cpusets configuration helper" + bool "Cpuset configuration helper" depends on CPUSETS depends on ANDROID help - This option enables the configuration of default cpusets - parameters from kernel. + This option enables in-kernel overrides for cpuset values. If unsure, say N. diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 7a2138690059..f7e173bc1920 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -57,6 +57,7 @@ #include #include #include +#include #include #include @@ -137,6 +138,13 @@ struct cpuset { int relax_domain_level; }; +#ifdef CONFIG_CPUSETS_ASSIST +struct cs_target { + const char *name; + char *cpus; +}; +#endif + static inline struct cpuset *css_cs(struct cgroup_subsys_state *css) { return css ? container_of(css, struct cpuset, css) : NULL; @@ -1712,11 +1720,6 @@ 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 * resources, in which case the hotplug code asynchronously updates @@ -1771,32 +1774,37 @@ out_unlock: return retval ?: nbytes; } +static ssize_t cpuset_write_resmask_assist(struct kernfs_open_file *of, + struct cs_target tgt, size_t nbytes, + loff_t off) +{ + pr_info("cpuset_assist: setting %s to %s\n", tgt.name, tgt.cpus); + return cpuset_write_resmask(of, tgt.cpus, nbytes, off); +} + 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; + static struct cs_target cs_targets[] = { + /* Little-only cpusets go first */ + { "foreground", "0-5" }, + { "background", "0-2" }, + { "system-background", "0-3" }, + { "restricted", "0-5" }, + { "top-app", "0-7" }, + { "camera-daemon", "0-3,6-7" }, }; - 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 + struct cpuset *cs = css_cs(of_css(of)); + int i; - 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; - } + if (task_is_booster(current)) { + for (i = 0; i < ARRAY_SIZE(cs_targets); i++) { + struct cs_target tgt = cs_targets[i]; + + if (!strcmp(cs->css.cgroup->kn->name, tgt.name)) + return cpuset_write_resmask_assist(of, tgt, + nbytes, off); } } #endif