瀏覽代碼

Kernel/SMP: Fix ProcessorMessage deallocation bug

Due to a boolean mistake in smp_return_to_pool(), we didn't retry
pushing the message onto the freelist after a failed attempt.

This caused the message pool to eventually become completely empty
after enough contentious access attempts.

This patch also adds a pause hint to the CPU in the failed attempt
code path.
Andreas Kling 3 年之前
父節點
當前提交
d21b8f9013
共有 1 個文件被更改,包括 5 次插入2 次删除
  1. 5 2
      Kernel/Arch/x86/common/Processor.cpp

+ 5 - 2
Kernel/Arch/x86/common/Processor.cpp

@@ -668,9 +668,12 @@ void Processor::flush_tlb(Memory::PageDirectory const* page_directory, VirtualAd
 void Processor::smp_return_to_pool(ProcessorMessage& msg)
 {
     ProcessorMessage* next = nullptr;
-    do {
+    for (;;) {
         msg.next = next;
-    } while (s_message_pool.compare_exchange_strong(next, &msg, AK::MemoryOrder::memory_order_acq_rel));
+        if (s_message_pool.compare_exchange_strong(next, &msg, AK::MemoryOrder::memory_order_acq_rel))
+            break;
+        Processor::pause();
+    }
 }
 
 ProcessorMessage& Processor::smp_get_from_pool()