From 432f8ff4654c3cdc2f53d5f00ea3ba5b7b33bbdb Mon Sep 17 00:00:00 2001 From: Danny Lin Date: Sun, 4 Aug 2019 05:57:49 +0000 Subject: [PATCH] sched/tune: Refactor SchedTune Assist code - Return proper values when write wrappers aren't bypassed - Revise Kconfig description - Improve overall code style - Don't write colocate and sched_boost_no_override values when WALT is disabled - Mark static data as static - Improve readability of log messages - Propagate cftype struct in write wrappers - Use task_is_booster helper rather than hard-coded "init" check Signed-off-by: Danny Lin [0ctobot: Squash kdrag0n/proton_zf6@12d005c with kdrag0n/proton_zf6@eb73f2f] Signed-off-by: Adam W. Willis Signed-off-by: Yaroslav Furman --- init/Kconfig | 3 +- kernel/sched/tune.c | 85 +++++++++++++++++++++++---------------------- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/init/Kconfig b/init/Kconfig index 9e0be90b764f..93b1927e54ff 100755 --- a/init/Kconfig +++ b/init/Kconfig @@ -1151,8 +1151,7 @@ config STUNE_ASSIST depends on SCHED_TUNE depends on ANDROID help - This option enables the configuration of default SchedTune - parameters from kernel. + This option enables in-kernel overrides for SchedTune values. If unsure, say N. diff --git a/kernel/sched/tune.c b/kernel/sched/tune.c index 64c6d2e5eecd..b3ca2958404b 100755 --- a/kernel/sched/tune.c +++ b/kernel/sched/tune.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -656,48 +657,40 @@ boost_write(struct cgroup_subsys_state *css, struct cftype *cft, #ifdef CONFIG_STUNE_ASSIST #ifdef CONFIG_SCHED_WALT static int sched_boost_override_write_wrapper(struct cgroup_subsys_state *css, - struct cftype *cft, u64 override) + struct cftype *cft, u64 override) { - if (!strcmp(current->comm, "init")) + if (task_is_booster(current)) return 0; - sched_boost_override_write(css, NULL, override); - - return 0; + return sched_boost_override_write(css, cft, override); } static int sched_colocate_write_wrapper(struct cgroup_subsys_state *css, - struct cftype *cft, u64 colocate) + struct cftype *cft, u64 colocate) { - if (!strcmp(current->comm, "init")) + if (task_is_booster(current)) return 0; - sched_colocate_write(css, NULL, colocate); - - return 0; + return sched_colocate_write(css, cft, colocate); } #endif static int boost_write_wrapper(struct cgroup_subsys_state *css, - struct cftype *cft, s64 boost) + struct cftype *cft, s64 boost) { - if (!strcmp(current->comm, "init")) + if (task_is_booster(current)) return 0; - boost_write(css, NULL, boost); - - return 0; + return boost_write(css, cft, boost); } static int prefer_idle_write_wrapper(struct cgroup_subsys_state *css, - struct cftype *cft, u64 prefer_idle) + struct cftype *cft, u64 prefer_idle) { - if (!strcmp(current->comm, "init")) + if (task_is_booster(current)) return 0; - prefer_idle_write(css, NULL, prefer_idle); - - return 0; + return prefer_idle_write(css, cft, prefer_idle); } #endif @@ -748,31 +741,39 @@ schedtune_boostgroup_init(struct schedtune *st) } #ifdef CONFIG_STUNE_ASSIST +struct st_data { + char *name; + int boost; + bool prefer_idle; + bool colocate; + bool no_override; +}; + static void write_default_values(struct cgroup_subsys_state *css) { - u8 i; - struct groups_data { - char *name; - int boost; - bool prefer_idle; - bool colocate; - bool no_override; + static struct st_data st_targets[] = { + { "audio-app", 0, 0, 0, 0 }, + { "background", 0, 0, 0, 0 }, + { "foreground", 0, 1, 0, 1 }, + { "rt", 0, 0, 0, 0 }, + { "top-app", 1, 1, 0, 1 }, }; - struct groups_data groups[3] = { - { "top-app", 5, 1, 0, 1 }, - { "foreground", 1, 1, 0, 1 }, - { "background", 0, 0, 1, 0 }}; - - for (i = 0; i < ARRAY_SIZE(groups); i++) { - if (!strcmp(css->cgroup->kn->name, groups[i].name)) { - pr_info("%s: %i - %i - %i - %i\n", groups[i].name, - groups[i].boost, groups[i].prefer_idle, - groups[i].colocate, - groups[i].no_override); - boost_write(css, NULL, groups[i].boost); - prefer_idle_write(css, NULL, groups[i].prefer_idle); - sched_colocate_write(css, NULL, groups[i].colocate); - sched_boost_override_write(css, NULL, groups[i].no_override); + int i; + + for (i = 0; i < ARRAY_SIZE(st_targets); i++) { + struct st_data tgt = st_targets[i]; + + if (!strcmp(css->cgroup->kn->name, tgt.name)) { + pr_info("stune_assist: setting values for %s: boost=%d prefer_idle=%d colocate=%d no_override=%d\n", + tgt.name, tgt.boost, tgt.prefer_idle, + tgt.colocate, tgt.no_override); + + boost_write(css, NULL, tgt.boost); + prefer_idle_write(css, NULL, tgt.prefer_idle); +#ifdef CONFIG_SCHED_WALT + sched_colocate_write(css, NULL, tgt.colocate); + sched_boost_override_write(css, NULL, tgt.no_override); +#endif } } }