mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sched/rt: use smp_wmb in rt_clear_overload
@ 2024-11-14 21:31 Jon Kohler
  2024-11-15 10:03 ` Peter Zijlstra
  0 siblings, 1 reply; 3+ messages in thread
From: Jon Kohler @ 2024-11-14 21:31 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	Valentin Schneider, linux-kernel
  Cc: Jon Kohler

Add smp_wmb in rt_clear_overload, which ensures that the cleared
cpumask bit is visible to properly iterate over any remaining
overloaded CPU(s).

The smp_wmb pairs with the smp_rmb in pull_rt_task(), ensuring that a
thread will observe rto_count and the correct cpumask.

This visibility is important for NO_RT_PUSH_IPI use cases where a
thread may iterate over an outdated view of rto_mask where target CPUs
are no longer overloaded.

Signed-off-by: Jon Kohler <jon@nutanix.com>
---
 kernel/sched/rt.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 172c588de542..f68a454bb0e3 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -354,9 +354,13 @@ static inline void rt_clear_overload(struct rq *rq)
 	if (!rq->online)
 		return;
 
-	/* the order here really doesn't matter */
 	atomic_dec(&rq->rd->rto_count);
 	cpumask_clear_cpu(rq->cpu, rq->rd->rto_mask);
+	/*
+	 * Barrier pairs with pull_rt_task(), such that threads will
+	 * observe the correct cpu mask for any remaining overloaded CPU(s).
+	 */
+	smp_wmb();
 }
 
 static inline int has_pushable_tasks(struct rq *rq)
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-15 15:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-14 21:31 [PATCH] sched/rt: use smp_wmb in rt_clear_overload Jon Kohler
2024-11-15 10:03 ` Peter Zijlstra
2024-11-15 15:47   ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®