Commit b106bcf0 authored by David Laight's avatar David Laight Committed by Linus Torvalds

locking/osq_lock: Clarify osq_wait_next()

Directly return NULL or 'next' instead of breaking out of the loop.
Signed-off-by: default avatarDavid Laight <david.laight@aculab.com>
[ Split original patch into two independent parts  - Linus ]
Link: https://lore.kernel.org/lkml/7c8828aec72e42eeb841ca0ee3397e9a@AcuMS.aculab.com/Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 563adbfc
...@@ -55,7 +55,6 @@ osq_wait_next(struct optimistic_spin_queue *lock, ...@@ -55,7 +55,6 @@ osq_wait_next(struct optimistic_spin_queue *lock,
struct optimistic_spin_node *node, struct optimistic_spin_node *node,
int old_cpu) int old_cpu)
{ {
struct optimistic_spin_node *next = NULL;
int curr = encode_cpu(smp_processor_id()); int curr = encode_cpu(smp_processor_id());
for (;;) { for (;;) {
...@@ -66,7 +65,7 @@ osq_wait_next(struct optimistic_spin_queue *lock, ...@@ -66,7 +65,7 @@ osq_wait_next(struct optimistic_spin_queue *lock,
* will now observe @lock and will complete its * will now observe @lock and will complete its
* unlock()/unqueue(). * unlock()/unqueue().
*/ */
break; return NULL;
} }
/* /*
...@@ -80,15 +79,15 @@ osq_wait_next(struct optimistic_spin_queue *lock, ...@@ -80,15 +79,15 @@ osq_wait_next(struct optimistic_spin_queue *lock,
* wait for a new @node->next from its Step-C. * wait for a new @node->next from its Step-C.
*/ */
if (node->next) { if (node->next) {
struct optimistic_spin_node *next;
next = xchg(&node->next, NULL); next = xchg(&node->next, NULL);
if (next) if (next)
break; return next;
} }
cpu_relax(); cpu_relax();
} }
return next;
} }
bool osq_lock(struct optimistic_spin_queue *lock) bool osq_lock(struct optimistic_spin_queue *lock)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment