Ver Fonte

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 há 3 anos atrás
pai
commit
d21b8f9013
1 ficheiros alterados com 5 adições e 2 exclusões
  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()