Re: [PATCH] spinlock: clarify doc for raw_spin_unlock_wait()

From: Manfred Spraul
Date: Wed Apr 29 2015 - 13:34:12 EST

On 04/28/2015 06:44 PM, Chris Metcalf wrote:
The intent of the function is to wait for the current locker.
Thus, we don't have to worry about potential later lockers,
but we also have to ensure that the arch implementation
doesn't return a false positive for the current locker.

Signed-off-by: Chris Metcalf <cmetcalf@xxxxxxxxxx>
sysvsem depends on this definition, i.e. a false early return can cause a corrupted semaphore state.

Acked-by: Manfred Spraul <manfred@xxxxxxxxxxxxxxxx>
On 04/28/2015 12:24 PM, Peter Zijlstra wrote:
I think it must not return before the lock holder that is current at the
time of calling releases. Anything thereafter is indeed fair game as per
your logic above.
Great, that seems like a workable definition. How does this modified
language seem? With this definition I can actually modify the
implementation of tile's arch_raw_spin_unlock_wait() to just read
current_ticket once and just wait until it changes (assuming the
lock is, in fact, locked).

Not sure whose tree this should go through; any takers?

include/linux/spinlock.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index 3e18379dfa6f..36de5fc86647 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -141,7 +141,8 @@ do { \
- * raw_spin_unlock_wait - wait until the spinlock gets unlocked
+ * raw_spin_unlock_wait - wait until the lock holder that is current at the
+ * time of calling releases the lock (or return immediately if unlocked).
* @lock: the spinlock in question.
#define raw_spin_unlock_wait(lock) arch_spin_unlock_wait(&(lock)->raw_lock)

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at