Skip to contentSkip to conversation

sched/core: Always do the balancing pass from dl_sched_class

PATCH New Chengming Zhou 1 participant 1 message Sep 24, 2022 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched/core: Always do the balancing pass from dl_sched_class

The commit 67692435c411 ("sched: Rework pick_next_task() slow-path") and commit 6e2df0581f56 ("sched: Fix pick_next_task() vs 'change' pattern race") changed the original pick_next_task() loop logic a little.

Previously we always do class->pick_next_task(rq, prev, rf) from highest to lowest, and balance happened in that class->pick_next_task(), so we don't need to pull RT task if we can pick a DL task.

The current code do the balancing pass from prev->class, say prev task is a RT task to sleep, we will try balance for rt sched_class even though we have a DL task on rq.

This patch changes to always do the balancing pass from dl_sched_class, since we will check if balance is really needed in each class->balance(), we can terminate the balance pass as soon as we know there is a runnable task of @class priority or higher.

---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/core.c +1 -1
index ee28253c9ac0..ff5e7ac236bd 100644
@@ -5774,7 +5774,7 @@ static void put_prev_task_balance(struct rq *rq, struct task_struct *prev,
 	 * We can terminate the balance pass as soon as we know there is
 	 * a runnable task of @class priority or higher.
 	 */
-	for_class_range(class, prev->sched_class, &idle_sched_class) {
+	for_class_range(class, &dl_sched_class, &idle_sched_class) {
 		if (class->balance(rq, prev, rf))
 			break;
 	}
Signature · 1 line
2.37.2