From e280a059986f9185bdcfde732fcf65edac321d47 Mon Sep 17 00:00:00 2001 From: Connor O'Brien Date: Fri, 19 May 2017 12:36:17 -0700 Subject: sched/tune: allow negative cpu boosts schedtune sets 0 as the floor for calculating CPU max boost, so negative schedtune.boost values do not affect CPU frequency decisions. Remove this restriction to allow userspace to apply negative boosts when appropriate. Also change treatment of the root boost group to match the other groups, so it only affects the CPU boost if it has runnable tasks on the CPU. Test: set all boosts negative; sched_boost_cpu trace events show negative CPU margins. Change-Id: I89f3470299aef96a18797c105f02ebc8f367b5e1 Signed-off-by: Connor O'Brien --- kernel/sched/tune.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/kernel/sched/tune.c b/kernel/sched/tune.c index 62d7a0f93cef..f8c4e29763d3 100644 --- a/kernel/sched/tune.c +++ b/kernel/sched/tune.c @@ -392,14 +392,12 @@ static void schedtune_cpu_update(int cpu) { struct boost_groups *bg; - int boost_max; + int boost_max = INT_MIN; int idx; bg = &per_cpu(cpu_boost_groups, cpu); - /* The root boost group is always active */ - boost_max = bg->group[0].boost; - for (idx = 1; idx < BOOSTGROUPS_COUNT; ++idx) { + for (idx = 0; idx < BOOSTGROUPS_COUNT; ++idx) { /* * A boost group affects a CPU only if it has * RUNNABLE tasks on that CPU @@ -409,10 +407,10 @@ schedtune_cpu_update(int cpu) boost_max = max(boost_max, bg->group[idx].boost); } - /* Ensures boost_max is non-negative when all cgroup boost values - * are neagtive. Avoids under-accounting of cpu capacity which may cause - * task stacking and frequency spikes.*/ - boost_max = max(boost_max, 0); + + /* If there are no active boost groups on the CPU, set no boost */ + if (boost_max == INT_MIN) + boost_max = 0; bg->boost_max = boost_max; } -- cgit v1.2.3