mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jon Kohler <jon@nutanix.com>
To: Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Valentin Schneider <vschneid@redhat.com>,
	linux-kernel@vger.kernel.org
Cc: Jon Kohler <jon@nutanix.com>
Subject: [PATCH] sched/rt: use smp_wmb in rt_clear_overload
Date: Thu, 14 Nov 2024 14:31:56 -0700	[thread overview]
Message-ID: <20241114213156.1839644-1-jon@nutanix.com> (raw)

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


             reply	other threads:[~2024-11-14 21:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-14 21:31 Jon Kohler [this message]
2024-11-15 10:03 ` Peter Zijlstra
2024-11-15 15:47   ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241114213156.1839644-1-jon@nutanix.com \
    --to=jon@nutanix.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®