[PATCH] sched/fair: Preserve newidle cost decay across domains

lirongqing posted 1 patch 2 weeks, 2 days ago
kernel/sched/fair.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] sched/fair: Preserve newidle cost decay across domains
Posted by lirongqing 2 weeks, 2 days ago
From: Li RongQing <lirongqing@baidu.com>

In sched_balance_domains(), the result of update_newidle_cost() is
currently assigned directly to need_decay for each scheduling domain.
As a result, a decay reported by an earlier domain can be overwritten
by a later domain that does not require decay.

For example, if an earlier domain reports a decay and the last domain
does not, need_decay will be cleared before the loop exits. This causes
the rq-wide max_idle_balance_cost update to be skipped even though one
of the visited domains has decayed its newidle cost.

Accumulate the result of update_newidle_cost() in need_decay so that a
decay reported by any visited domain is preserved.

This restores the aggregate semantics of need_decay and ensures that
rq->max_idle_balance_cost is updated when any visited domain requires
decay.

This restores the aggregate semantics of need_decay that existed
before e60b56e46b38 and ensures that rq->max_idle_balance_cost is
updated when any visited domain requires decay.

Fixes: e60b56e46b38 ("sched/fair: Wait before decaying max_newidle_lb_cost")
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index ade1eceb..8c1008a 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -13982,7 +13982,7 @@ static void sched_balance_domains(struct rq *rq, enum cpu_idle_type idle)
 		 * Decay the newidle max times here because this is a regular
 		 * visit to all the domains.
 		 */
-		need_decay = update_newidle_cost(sd, 0, 0);
+		need_decay  |= update_newidle_cost(sd, 0, 0);
 		max_cost += sd->max_newidle_lb_cost;
 
 		/*
-- 
2.9.4