mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 12:35:14 +00:00
Kernel: Fix race condition waiting for IPI while other CPU requested halt
It's possible that we broadcast an IPI message right at the same time another processor requests a halt. Rather than spinning forever waiting for that message to be handled, check if we should halt while waiting.
This commit is contained in:
parent
fe615e601a
commit
b8ad4932a9
Notes:
sideshowbarker
2024-07-19 01:43:27 +09:00
Author: https://github.com/tomuta Commit: https://github.com/SerenityOS/serenity/commit/b8ad4932a99 Pull-request: https://github.com/SerenityOS/serenity/pull/3856
1 changed files with 6 additions and 0 deletions
|
@ -1870,6 +1870,12 @@ void Processor::smp_broadcast_message(ProcessorMessage& msg, bool async)
|
|||
// to the pool. Otherwise, the last processor to complete it will return it
|
||||
while (atomic_load(&msg.refs, AK::MemoryOrder::memory_order_consume) != 0) {
|
||||
// TODO: pause for a bit?
|
||||
|
||||
// We need to check here if another processor may have requested
|
||||
// us to halt before this message could be delivered. Otherwise
|
||||
// we're just spinning the CPU because msg.refs will never drop to 0.
|
||||
if (cur_proc.m_halt_requested)
|
||||
halt_this();
|
||||
}
|
||||
|
||||
smp_cleanup_message(msg);
|
||||
|
|
Loading…
Add table
Reference in a new issue