[PATCH next v2 1/5] locking/osq_lock: Defer clearing node->locked until the slow osq_lock() path.

David Laight posted 5 patches 1 year, 11 months ago
[PATCH next v2 1/5] locking/osq_lock: Defer clearing node->locked until the slow osq_lock() path.
Posted by David Laight 1 year, 11 months ago
Since node->locked cannot be set before the assignment to prev->next
it is save to clear it in the slow path.

Signed-off-by: David Laight <david.laight@aculab.com>
---
 kernel/locking/osq_lock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/locking/osq_lock.c b/kernel/locking/osq_lock.c
index 75a6f6133866..e0bc74d85a76 100644
--- a/kernel/locking/osq_lock.c
+++ b/kernel/locking/osq_lock.c
@@ -97,7 +97,6 @@ bool osq_lock(struct optimistic_spin_queue *lock)
 	int curr = encode_cpu(smp_processor_id());
 	int old;
 
-	node->locked = 0;
 	node->next = NULL;
 	node->cpu = curr;
 
@@ -111,6 +110,7 @@ bool osq_lock(struct optimistic_spin_queue *lock)
 	if (old == OSQ_UNLOCKED_VAL)
 		return true;
 
+	node->locked = 0;
 	prev = decode_cpu(old);
 	node->prev = prev;
 
-- 
2.17.1

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Re: [PATCH next v2 1/5] locking/osq_lock: Defer clearing node->locked until the slow osq_lock() path.
Posted by Ingo Molnar 1 year, 11 months ago
Also, please don't put periods into titles:

 s/[PATCH next v2 1/5] locking/osq_lock: Defer clearing node->locked until the slow osq_lock() path.
  /[PATCH next v2 1/5] locking/osq_lock: Defer clearing node->locked until the slow osq_lock() path

Usually maintainers remove them manually, but there's no reason to be 
inconsistent: half of your series had a period. It just unnecessarily 
distracts from review.

This rule applies to this series and to all future patches.

Thanks,

	Ingo
Re: [PATCH next v2 1/5] locking/osq_lock: Defer clearing node->locked until the slow osq_lock() path.
Posted by Ingo Molnar 1 year, 11 months ago
* David Laight <David.Laight@ACULAB.COM> wrote:

> Since node->locked cannot be set before the assignment to prev->next
> it is save to clear it in the slow path.

s/save
 /safe

Thanks,

	Ingo
Re: [PATCH next v2 1/5] locking/osq_lock: Defer clearing node->locked until the slow osq_lock() path.
Posted by Waiman Long 1 year, 12 months ago
On 12/31/23 16:51, David Laight wrote:
> Since node->locked cannot be set before the assignment to prev->next
> it is save to clear it in the slow path.
>
> Signed-off-by: David Laight <david.laight@aculab.com>
> ---
>   kernel/locking/osq_lock.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/locking/osq_lock.c b/kernel/locking/osq_lock.c
> index 75a6f6133866..e0bc74d85a76 100644
> --- a/kernel/locking/osq_lock.c
> +++ b/kernel/locking/osq_lock.c
> @@ -97,7 +97,6 @@ bool osq_lock(struct optimistic_spin_queue *lock)
>   	int curr = encode_cpu(smp_processor_id());
>   	int old;
>   
> -	node->locked = 0;
>   	node->next = NULL;
>   	node->cpu = curr;
>   
> @@ -111,6 +110,7 @@ bool osq_lock(struct optimistic_spin_queue *lock)
>   	if (old == OSQ_UNLOCKED_VAL)
>   		return true;
>   
> +	node->locked = 0;
>   	prev = decode_cpu(old);
>   	node->prev = prev;
>   

Reviewed-by: Waiman Long <longman@redhat.com>