[DragonFlyBSD - Bug #3476] (New) x86_64: restart_cpus() doesn't wait for the cpus and can spin forever

tuxillo bugtracker-admin at leaf.dragonflybsd.org
Sun Nov 22 04:08:34 PST 2026


Issue #3476 has been reported by tuxillo.

----------------------------------------
Bug #3476: x86_64: restart_cpus() doesn't wait for the cpus and can spin forever
http://bugs.dragonflybsd.org/issues/3476

* Author: tuxillo
* Status: New
* Priority: Normal
* Target version: 6.6
* Start date: 2026-11-22
----------------------------------------
As of master e2619a112f, restart_cpus() on x86_64 returns before the cpus it restarts have left Xcpustop, and if one of them is quick it never returns at all. It is called by ddb's continue and by dump_reactivate_cpus(), which the dm_crypt dump path uses.

restart_cpus() sets started_cpus and then waits with @while (CPUMASK_CMPMASKNEQ(stopped_cpus, map))@. Both callers pass stopped_cpus itself as map, so the loop only checks whether stopped_cpus has changed since the call. If no cpu has cleared its bit yet, the loop ends at once. If a cpu clears its bit before the first test, stopped_cpus never equals map again, since bits are only cleared from then on, and the caller spins in cpu_pause() for good. The window is a few instructions, wider when the caller takes an interrupt there or, in a VM, when its vCPU is descheduled.

The loop came in with c07315c47f (2014), the cpumask_t conversion. Before that it was @while ((stopped_cpus & map) != 0)@.

The attached patch restores that test, on the cpus that were signalled: @while (CPUMASK_TESTMASK(stopped_cpus, mask))@.

---Files--------------------------------
restartwait.c (3.86 KB)
0001-x86_64-make-restart_cpus-wait-for-the-cpus-to-restar.patch (1.5 KB)


-- 
You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://bugs.dragonflybsd.org/my/account


More information about the Bugs mailing list