Skip to content

Commit b106bcf

Browse files
david-laighttorvalds
authored andcommitted
locking/osq_lock: Clarify osq_wait_next()
Directly return NULL or 'next' instead of breaking out of the loop. Signed-off-by: David 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: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 563adbf commit b106bcf

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

kernel/locking/osq_lock.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ osq_wait_next(struct optimistic_spin_queue *lock,
5555
struct optimistic_spin_node *node,
5656
int old_cpu)
5757
{
58-
struct optimistic_spin_node *next = NULL;
5958
int curr = encode_cpu(smp_processor_id());
6059

6160
for (;;) {
@@ -66,7 +65,7 @@ osq_wait_next(struct optimistic_spin_queue *lock,
6665
* will now observe @lock and will complete its
6766
* unlock()/unqueue().
6867
*/
69-
break;
68+
return NULL;
7069
}
7170

7271
/*
@@ -80,15 +79,15 @@ osq_wait_next(struct optimistic_spin_queue *lock,
8079
* wait for a new @node->next from its Step-C.
8180
*/
8281
if (node->next) {
82+
struct optimistic_spin_node *next;
83+
8384
next = xchg(&node->next, NULL);
8485
if (next)
85-
break;
86+
return next;
8687
}
8788

8889
cpu_relax();
8990
}
90-
91-
return next;
9291
}
9392

9493
bool osq_lock(struct optimistic_spin_queue *lock)

0 commit comments

Comments
 (0)