Repository navigation
sched/fair: Never pick the misfit task as its own rotation partner - #927
Merged
RyanTheTide merged 1 commit intoNov 5, 2026
Conversation
misfit_rotate_work() checks that p is still on src_cpu, then scans the bigger CPUs' rq->curr without locks. Load balancing can pull the misfit task p onto an idle bigger CPU in between, so the scan can return p itself. migrate_swap(p, p) then runs migrate_swap_stop() on dst_cpu, which takes double_raw_spinlock(&p->pi_lock, &p->pi_lock) with IRQs off and spins forever, while src_cpu spins in multi_cpu_stop(). Seen on m4.120: CPU 5 stopped answering IPIs and the NMI backtrace, RCU stalled, the misfit_rotate_mutex owner sat in stop_two_cpus(), and the desktop froze until a hard reboot. Skip p when scanning for a partner. Fixes: 2d24fbc ("sched/fair: Rotate misfit tasks with tasks on busy bigger CPUs") Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com> Assisted-by: LLM
Contributor
|
Merge train (MTL, 06/11). Gates passed on test tree 0412501 (integration/aurora 2661d71 + this batch):
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a hard hang in the misfit rotation from #690 (
2d24fbce39a3).misfit_rotate_work()checks that the misfit taskpis still onsrc_cpu, then reads the bigger CPUs'rq->currwithout taking their locks. If load balancing pullsponto a bigger CPU in that window, the scan can returnpitself.migrate_swap(p, p)then runsmigrate_swap_stop(), which takesp->pi_locktwice throughguard(double_raw_spinlock)with IRQs off. That CPU never comes back, and the other CPU sits inmulti_cpu_stop().The fix skips
pduring the scan, which is howtask_numa_compare()already handles the same case (cur == env->p).Seen on the J616s (M4 Pro)
The machine hung hard with every core busy (a FEX build next to a game under emulation):
misfit_rotate_mutexowner was stuck instop_two_cpus().It needed a hard reset. Setting
NO_MISFIT_ROTATEin/sys/kernel/debug/sched/featuresavoids the hang until this fix is in.Testing
kernel/sched, has run on our daily J616s kernel since 2026-11-03 21:27 withMISFIT_ROTATEon, through the same all-core loads (game, FEX builds, kernel builds). No hang or RCU stall since.I have no deterministic reproducer: the window is a lockless read racing load balancing.
🤖 Generated with Claude Code