summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor O'Brien <connoro@google.com>2017-05-19 12:36:17 -0700
committerGeorg Veichtlbauer <georg@vware.at>2023-07-26 21:01:08 +0200
commite280a059986f9185bdcfde732fcf65edac321d47 (patch)
treec5d98637902c7a6f3de4fea2d7c5ed8fd4859bd3
parentf39d0b496aa4e13cbcf23bdf3c22d356bd783b9e (diff)
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 <connoro@google.com>
-rw-r--r--kernel/sched/tune.c14
1 files 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;
}