Skip to content

Commit

Permalink
locking/osq_lock: Clarify osq_wait_next()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David Laight authored and Linus Torvalds committed Dec 30, 2023
1 parent 563adbf commit b106bcf
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions kernel/locking/osq_lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ osq_wait_next(struct optimistic_spin_queue *lock,
struct optimistic_spin_node *node,
int old_cpu)
{
struct optimistic_spin_node *next = NULL;
int curr = encode_cpu(smp_processor_id());

for (;;) {
Expand All @@ -66,7 +65,7 @@ osq_wait_next(struct optimistic_spin_queue *lock,
* will now observe @lock and will complete its
* unlock()/unqueue().
*/
break;
return NULL;
}

/*
Expand All @@ -80,15 +79,15 @@ osq_wait_next(struct optimistic_spin_queue *lock,
* wait for a new @node->next from its Step-C.
*/
if (node->next) {
struct optimistic_spin_node *next;

next = xchg(&node->next, NULL);
if (next)
break;
return next;
}

cpu_relax();
}

return next;
}

bool osq_lock(struct optimistic_spin_queue *lock)
Expand Down

0 comments on commit b106bcf

Please sign in to comment.