Skip to contentSkip to conversation

sched/deadline: Do not pull when the local CPU is the only overloaded one

PATCH New Liang Hao 1 participant 1 message Aug 7 Scheduler

lore
Share & tools
lore

Liang Hao

author
#0 lore raw

PATCH 1/1 sched/deadline: Do not pull when the local CPU is the only overloaded one

Mirror the short-circuit added to pull_rt_task() by commit f73c52a5bcd1 ("sched/rt: Do not pull from current CPU if only one CPU to pull"):
when dlo_count == 1 and the local CPU owns the sole dlo_mask bit, the for_each_cpu() loop skips this_cpu on every iteration and does nothing. Return early instead.

pull_dl_task() shares the same overload-tracking design as the RT side -- dl_set_overload() mirrors rt_set_overload(), incrementing rd->dlo_count after an smp_wmb() that pairs with the smp_rmb() in the pull path -- but never got the matching check. DEADLINE has no RT_PUSH_IPI path, so this is the symmetric short-circuit only.

No functional change.

---
 kernel/sched/deadline.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
kernel/sched/deadline.c +7 -1
index 857dbe3519a8..c3e38d4f3365 100644
@@ -3222,8 +3222,9 @@ static void pull_dl_task(struct rq *this_rq)
 	bool resched = false;
 	struct rq *src_rq;
 	u64 dmin = LONG_MAX;
+	int dl_overload_count = dl_overloaded(this_rq);
 
-	if (likely(!dl_overloaded(this_rq)))
+	if (likely(!dl_overload_count))
 		return;
 
 	/*
@@ -3232,6 +3233,11 @@ static void pull_dl_task(struct rq *this_rq)
 	 */
 	smp_rmb();
 
+	/* If we are the only overloaded CPU do nothing */
+	if (dl_overload_count == 1 &&
+	    cpumask_test_cpu(this_rq->cpu, this_rq->rd->dlo_mask))
+		return;
+
 	for_each_cpu(cpu, this_rq->rd->dlo_mask) {
 		if (this_cpu == cpu)
 			continue;
Signature · 1 line
2.50.1 (Apple Git-155)