LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* Re: [PATCH v2] locking/ww_mutex: Initialize waiter.ww_ctx properly
@ 2021-08-20  4:40 Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2021-08-20  4:40 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: Peter Zijlstra, Thomas Gleixner, LKML, Ingo Molnar, Juri Lelli,
	Steven Rostedt, Daniel Bristot de Oliveira, Will Deacon,
	Waiman Long, Boqun Feng, Davidlohr Bueso, Mike Galbraith

On Thu, Aug 19, 2021 at 09:30:30PM +0200, Sebastian Andrzej Siewior wrote:
> The gathering of the debug code for the ww-mutex initialized moved the
> POISON initialiation into one spot and only set waiter.ww_ctx if the
> ww_ctx was non-NULL thus keeping the POISON value in ww-mutex case.
> 
> For ww-mutex without a context it is expected to set the context to
> NULL, the poison value was intended only for the regular mutex.
> 
> Always initialized waiter.ww_ctx to ww_ctx in the ww-mutex case.
> 
> Fixes: c0afb0ffc06e6 ("locking/ww_mutex: Gather mutex_waiter initialization")
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Suggested-by: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

Tested-by: Guenter Roeck <linux@roeck-us.net>

> ---
> v1…v2: Use PeterZ' approach.
> 
>  kernel/locking/mutex.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
> index 05b68931622d1..2c70213934cd4 100644
> --- a/kernel/locking/mutex.c
> +++ b/kernel/locking/mutex.c
> @@ -614,7 +614,7 @@ __mutex_lock_common(struct mutex *lock, unsigned int state, unsigned int subclas
>  
>  	debug_mutex_lock_common(lock, &waiter);
>  	waiter.task = current;
> -	if (ww_ctx)
> +	if (use_ww_ctx)
>  		waiter.ww_ctx = ww_ctx;
>  
>  	lock_contended(&lock->dep_map, ip);
> -- 
> 2.33.0
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH v2] locking/ww_mutex: Initialize waiter.ww_ctx properly
  2021-08-19 18:17     ` Peter Zijlstra
@ 2021-08-19 19:30       ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Andrzej Siewior @ 2021-08-19 19:30 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Thomas Gleixner, LKML, Ingo Molnar, Juri Lelli, Steven Rostedt,
	Daniel Bristot de Oliveira, Will Deacon, Waiman Long, Boqun Feng,
	Davidlohr Bueso, Mike Galbraith, Guenter Roeck

The gathering of the debug code for the ww-mutex initialized moved the
POISON initialiation into one spot and only set waiter.ww_ctx if the
ww_ctx was non-NULL thus keeping the POISON value in ww-mutex case.

For ww-mutex without a context it is expected to set the context to
NULL, the poison value was intended only for the regular mutex.

Always initialized waiter.ww_ctx to ww_ctx in the ww-mutex case.

Fixes: c0afb0ffc06e6 ("locking/ww_mutex: Gather mutex_waiter initialization")
Reported-by: Guenter Roeck <linux@roeck-us.net>
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
v1…v2: Use PeterZ' approach.

 kernel/locking/mutex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
index 05b68931622d1..2c70213934cd4 100644
--- a/kernel/locking/mutex.c
+++ b/kernel/locking/mutex.c
@@ -614,7 +614,7 @@ __mutex_lock_common(struct mutex *lock, unsigned int state, unsigned int subclas
 
 	debug_mutex_lock_common(lock, &waiter);
 	waiter.task = current;
-	if (ww_ctx)
+	if (use_ww_ctx)
 		waiter.ww_ctx = ww_ctx;
 
 	lock_contended(&lock->dep_map, ip);
-- 
2.33.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-20  4:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-20  4:40 [PATCH v2] locking/ww_mutex: Initialize waiter.ww_ctx properly Guenter Roeck
  -- strict thread matches above, loose matches on Subject: below --
2021-08-15 21:27 [patch V5 00/72] locking, sched: The PREEMPT-RT locking infrastructure Thomas Gleixner
2021-08-15 21:28 ` [patch V5 41/72] locking/ww_mutex: Gather mutex_waiter initialization Thomas Gleixner
2021-08-19 17:51   ` Sebastian Andrzej Siewior
2021-08-19 18:17     ` Peter Zijlstra
2021-08-19 19:30       ` [PATCH v2] locking/ww_mutex: Initialize waiter.ww_ctx properly Sebastian Andrzej Siewior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).