mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Joel Fernandes <joelagnelf@nvidia.com>
Cc: linux-kernel@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrea Righi <arighi@nvidia.com>,
	"Paul E . McKenney" <paulmck@kernel.org>,
	Frederic Weisbecker <frederic@kernel.org>,
	rcu@vger.kernel.org
Subject: Re: [PATCH v2] smp: Document preemption and stop_machine() mutual exclusion
Date: Mon, 7 Jul 2025 09:50:50 +0200	[thread overview]
Message-ID: <20250707075050.GB1613200@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20250705172328.4114289-1-joelagnelf@nvidia.com>

On Sat, Jul 05, 2025 at 01:23:27PM -0400, Joel Fernandes wrote:
> Recently while revising RCU's cpu online checks, there was some discussion
> around how IPIs synchronize with hotplug.
> 
> Add comments explaining how preemption disable creates mutual exclusion with
> CPU hotplug's stop_machine mechanism. The key insight is that stop_machine()
> atomically updates CPU masks and flushes IPIs with interrupts disabled, and
> cannot proceed while any CPU (including the IPI sender) has preemption
> disabled.

I'm very conflicted on this. While the added comments aren't wrong,
they're not quite accurate either. Stop_machine doesn't wait for people
to enable preemption as such.

Fundamentally there seems to be a misconception around what stop machine
is and how it works, and I don't feel these comments make things better.

Basically, stop-machine (and stop_one_cpu(), stop_two_cpus()) use the
stopper task, a task running at the ultimate priority; if it is
runnable, it will run.

Stop-machine simply wakes all the stopper tasks and co-ordinates them to
literally stop the machine. All CPUs have the stopper task scheduled and
then they go sit in a spin-loop driven state machine with IRQs disabled.

There really isn't anything magical about any of this.



  parent reply	other threads:[~2025-07-07  7:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-05 17:23 Joel Fernandes
2025-07-06 17:01 ` Paul E. McKenney
2025-07-07  7:50 ` Peter Zijlstra [this message]
2025-07-07 14:19   ` Joel Fernandes
2025-07-08  7:21     ` Peter Zijlstra
2025-07-08 14:00       ` Joel Fernandes
2025-07-07 15:56   ` Paul E. McKenney
2025-07-08  7:23     ` Peter Zijlstra
2025-07-08 22:52       ` Paul E. McKenney
2025-07-14 17:20         ` Paul E. McKenney

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=20250707075050.GB1613200@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=arighi@nvidia.com \
    --cc=frederic@kernel.org \
    --cc=joelagnelf@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@kernel.org \
    --cc=rcu@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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®