Recursive locks know their current owner, and since we use the function
solely to determine whether a particular lock is being held by the
current CPU (which so far has been an imprecise check), make actually
check the owner for recusrively acquired locks.

Signed-off-by: Jan Beulich <[email protected]>

--- a/xen/common/spinlock.c
+++ b/xen/common/spinlock.c
@@ -188,7 +188,9 @@ void _spin_unlock_irqrestore(spinlock_t
 int _spin_is_locked(spinlock_t *lock)
 {
     check_lock(&lock->debug);
-    return lock->tickets.head != lock->tickets.tail;
+    return lock->recurse_cpu == SPINLOCK_NO_CPU
+           ? lock->tickets.head != lock->tickets.tail
+           : lock->recurse_cpu == smp_processor_id();
 }
 
 int _spin_trylock(spinlock_t *lock)



spinlock: improve spin_is_locked() for recursive locks

Recursive locks know their current owner, and since we use the function
solely to determine whether a particular lock is being held by the
current CPU (which so far has been an imprecise check), make actually
check the owner for recusrively acquired locks.

Signed-off-by: Jan Beulich <[email protected]>

--- a/xen/common/spinlock.c
+++ b/xen/common/spinlock.c
@@ -188,7 +188,9 @@ void _spin_unlock_irqrestore(spinlock_t
 int _spin_is_locked(spinlock_t *lock)
 {
     check_lock(&lock->debug);
-    return lock->tickets.head != lock->tickets.tail;
+    return lock->recurse_cpu == SPINLOCK_NO_CPU
+           ? lock->tickets.head != lock->tickets.tail
+           : lock->recurse_cpu == smp_processor_id();
 }
 
 int _spin_trylock(spinlock_t *lock)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Reply via email to