From f4b0ef33a4f6609720a130d95f4247b5076d7d3c Mon Sep 17 00:00:00 2001 From: Ankit Sharma Date: Wed, 28 Dec 2022 19:05:13 +0530 Subject: [PATCH] sched: fixes sched_boost_disable Everytime a boost level is disabled, if its refcount is zero, its exit routine and the entry routine of the next boost level are called. This causes an issue when the previous boost level and the next boost level are same as it increments the boost count of the next boost level.This is fixed by not calling the entry and exit routines, when the previous and the next boost levels are same. Change-Id: I482d0ee70c082bc647768958ffa5fcd6f5ee8e5b Signed-off-by: Ankit Sharma --- kernel/sched/boost.c | 9 +++++---- kernel/sched/core_ctl.c | 5 ++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/kernel/sched/boost.c b/kernel/sched/boost.c index bfdf8c237365..14eb8d10a1fe 100644 --- a/kernel/sched/boost.c +++ b/kernel/sched/boost.c @@ -146,7 +146,7 @@ static int sched_effective_boost(void) static void sched_boost_disable(int type) { struct sched_boost_data *sb = &sched_boosts[type]; - int next_boost; + int next_boost, prev_boost = sched_boost_type; if (sb->refcount <= 0) return; @@ -156,14 +156,15 @@ static void sched_boost_disable(int type) if (sb->refcount) return; + next_boost = sched_effective_boost(); + if (next_boost == prev_boost) + return; /* * This boost's refcount becomes zero, so it must * be disabled. Disable it first and then apply * the next boost. */ - sb->exit(); - - next_boost = sched_effective_boost(); + sched_boosts[prev_boost].exit(); sched_boosts[next_boost].enter(); } diff --git a/kernel/sched/core_ctl.c b/kernel/sched/core_ctl.c index dc695b0db063..dc65337d2dbf 100644 --- a/kernel/sched/core_ctl.c +++ b/kernel/sched/core_ctl.c @@ -883,10 +883,9 @@ int core_ctl_set_boost(bool boost) if (!cluster->boost) { ret = -EINVAL; break; - } else { - --cluster->boost; - boost_state_changed = !cluster->boost; } + --cluster->boost; + boost_state_changed = !cluster->boost; } } spin_unlock_irqrestore(&state_lock, flags);