Skip to contentSkip to conversation

sched/fair: Preserve newidle cost decay across domains

PATCH New lirongqing 1 participant 1 message Sep 9 Scheduler

lore
Share & tools
lore

lirongqing

author
#0 lore raw

PATCH 1/1 sched/fair: Preserve newidle cost decay across domains

From: Li RongQing <[email protected]>

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")
---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
index ade1eceb..8c1008a 100644
@@ -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;
 
 		/*
Signature · 1 line
2.9.4