Skip to content

Commit 766bf5c

Browse files
committed
Kernel: Don't take thread lock for signal dispatch
Signal dispatch is already protected by the global scheduler lock, but in some cases we also took Thread::m_lock for some reason. This led to a number of different deadlocks that started showing up with 4+ CPU's attached to the system. As a first step towards solving this, simply don't take the thread lock and let the scheduler lock cover it. Eventually, we should work in the other direction and break the scheduler lock into much finer-grained locks, but let's get out of the deadlock swamp first.
1 parent a1a1462 commit 766bf5c

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

Kernel/Thread.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,6 @@ void Thread::check_dispatch_pending_signal()
686686
{
687687
SpinlockLocker scheduler_lock(g_scheduler_lock);
688688
if (pending_signals_for_state() != 0) {
689-
SpinlockLocker lock(m_lock);
690689
result = dispatch_one_pending_signal();
691690
}
692691
}
@@ -739,7 +738,6 @@ void Thread::send_signal(u8 signal, [[maybe_unused]] Process* sender)
739738
return;
740739

741740
if (m_state == Thread::State::Stopped) {
742-
SpinlockLocker lock(m_lock);
743741
if (pending_signals_for_state() != 0) {
744742
dbgln_if(SIGNAL_DEBUG, "Signal: Resuming stopped {} to deliver signal {}", *this, signal);
745743
resume_from_stopped();
@@ -814,7 +812,7 @@ void Thread::send_urgent_signal_to_self(u8 signal)
814812

815813
DispatchSignalResult Thread::dispatch_one_pending_signal()
816814
{
817-
VERIFY(m_lock.is_locked_by_current_processor());
815+
VERIFY(g_scheduler_lock.is_locked_by_current_processor());
818816
u32 signal_candidates = pending_signals_for_state() & ~m_signal_mask;
819817
if (signal_candidates == 0)
820818
return DispatchSignalResult::Continue;
@@ -832,7 +830,6 @@ DispatchSignalResult Thread::try_dispatch_one_pending_signal(u8 signal)
832830
{
833831
VERIFY(signal != 0);
834832
SpinlockLocker scheduler_lock(g_scheduler_lock);
835-
SpinlockLocker lock(m_lock);
836833
u32 signal_candidates = pending_signals_for_state() & ~m_signal_mask;
837834
if ((signal_candidates & (1 << (signal - 1))) == 0)
838835
return DispatchSignalResult::Continue;
@@ -1272,7 +1269,6 @@ void Thread::set_state(State new_state, u8 stop_signal)
12721269
return;
12731270

12741271
{
1275-
SpinlockLocker thread_lock(m_lock);
12761272
previous_state = m_state;
12771273
if (previous_state == Thread::State::Invalid) {
12781274
// If we were *just* created, we may have already pending signals

0 commit comments

Comments
 (0)