From e31212e4d7b5e2f623e2295fe64d5c9b07d0c55d Mon Sep 17 00:00:00 2001 From: Pawel Dziepak Date: Tue, 25 Feb 2014 03:37:03 +0100 Subject: [PATCH] kernel: Fix acquire_read_spinlock() acquire checks If the initial attempt to acquire read spinlock fails we use more relaxed loop (which doesn't require CPU to lock the bus). However, check in that loop, incorrectly, didn't allow a lock to be acquired when there was at least one other reader. --- src/system/kernel/smp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/system/kernel/smp.cpp b/src/system/kernel/smp.cpp index 4c4b357f68..a5a4b26e9f 100644 --- a/src/system/kernel/smp.cpp +++ b/src/system/kernel/smp.cpp @@ -637,7 +637,7 @@ acquire_read_spinlock(rw_spinlock* lock) if (try_acquire_read_spinlock(lock)) break; - while (atomic_get(&lock->lock) != 0) { + while ((atomic_get(&lock->lock) & (1u << 31)) != 0) { if (++count == SPINLOCK_DEADLOCK_COUNT) { panic("acquire_read_spinlock(): Failed to acquire spinlock %p " "for a long time!", lock);