From 81a49d211b218a9048c0cb837900beeebad20618 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Tue, 20 Jan 2026 13:58:31 -0700 Subject: [PATCH] Fix potential preempt guard deadlock --- src/context/switch.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/context/switch.rs b/src/context/switch.rs index c26caf2c2c..5cfe8ab67c 100644 --- a/src/context/switch.rs +++ b/src/context/switch.rs @@ -166,7 +166,11 @@ pub fn switch(token: &mut CleanLockToken) -> SwitchResult { let prev_context_guard = unsafe { prev_context_lock.write_arc() }; if !prev_context_guard.is_preemptable() { - return SwitchResult::AllContextsIdle; + // Unset global lock + arch::CONTEXT_SWITCH_LOCK.store(false, Ordering::SeqCst); + + // Pretend to have finished switching, so CPU is not idled + return SwitchResult::Switched; } let idle_context = percpu.switch_internals.idle_context();