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.



Reply via email to