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

Liang Hao <[email protected]>
Newsgroups org.kernel.vger.linux-kernel
Message-ID <[email protected]>
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.

Signed-off-by: Liang Hao <[email protected]>
---
 kernel/sched/deadline.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 857dbe3519a8..c3e38d4f3365 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -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;
-- 
2.50.1 (Apple Git-155)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.