1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 22:54:57 +00:00

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.
This commit is contained in:
Andreas Kling 2021-08-08 19:03:01 +02:00
parent f3fed411d4
commit d21b8f9013

View file

@ -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()