All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lockdep: report name and key when look_up_lock_class() got confused
@ 2022-09-18 15:01 Tetsuo Handa
  2022-09-18 18:31 ` Boqun Feng
  0 siblings, 1 reply; 6+ messages in thread
From: Tetsuo Handa @ 2022-09-18 15:01 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Will Deacon, Waiman Long, Boqun Feng; +Cc: LKML

Printing this information will be helpful.

  ------------[ cut here ]------------
  class->name=slock-AF_INET6 lock->name=l2tp_sock lock->key=l2tp_socket_class
  WARNING: CPU: 2 PID: 9237 at kernel/locking/lockdep.c:940 look_up_lock_class+0xcc/0x140
  Modules linked in:
  CPU: 2 PID: 9237 Comm: a.out Not tainted 6.0.0-rc5-00094-ga335366bad13-dirty #860
  Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
  RIP: 0010:look_up_lock_class+0xcc/0x140

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
 kernel/locking/lockdep.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 64a13eb56078..a22469dbeeee 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -934,8 +934,10 @@ look_up_lock_class(const struct lockdep_map *lock, unsigned int subclass)
 			 * Huh! same key, different name? Did someone trample
 			 * on some memory? We're most confused.
 			 */
-			WARN_ON_ONCE(class->name != lock->name &&
-				     lock->key != &__lockdep_no_validate__);
+			WARN_ONCE(class->name != lock->name &&
+				  lock->key != &__lockdep_no_validate__,
+				  "class->name=%s lock->name=%s lock->key=%ps\n",
+				  class->name, lock->name, lock->key);
 			return class;
 		}
 	}
-- 
2.34.1


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

* Re: [PATCH] lockdep: report name and key when look_up_lock_class() got confused
  2022-09-18 15:01 [PATCH] lockdep: report name and key when look_up_lock_class() got confused Tetsuo Handa
@ 2022-09-18 18:31 ` Boqun Feng
  2022-09-19  0:52   ` [PATCH v2] " Tetsuo Handa
  0 siblings, 1 reply; 6+ messages in thread
From: Boqun Feng @ 2022-09-18 18:31 UTC (permalink / raw)
  To: Tetsuo Handa; +Cc: Peter Zijlstra, Ingo Molnar, Will Deacon, Waiman Long, LKML

On Mon, Sep 19, 2022 at 12:01:30AM +0900, Tetsuo Handa wrote:
> Printing this information will be helpful.
> 
>   ------------[ cut here ]------------
>   class->name=slock-AF_INET6 lock->name=l2tp_sock lock->key=l2tp_socket_class
>   WARNING: CPU: 2 PID: 9237 at kernel/locking/lockdep.c:940 look_up_lock_class+0xcc/0x140
>   Modules linked in:
>   CPU: 2 PID: 9237 Comm: a.out Not tainted 6.0.0-rc5-00094-ga335366bad13-dirty #860
>   Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
>   RIP: 0010:look_up_lock_class+0xcc/0x140
> 
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> ---
>  kernel/locking/lockdep.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index 64a13eb56078..a22469dbeeee 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -934,8 +934,10 @@ look_up_lock_class(const struct lockdep_map *lock, unsigned int subclass)
>  			 * Huh! same key, different name? Did someone trample
>  			 * on some memory? We're most confused.
>  			 */
> -			WARN_ON_ONCE(class->name != lock->name &&
> -				     lock->key != &__lockdep_no_validate__);
> +			WARN_ONCE(class->name != lock->name &&
> +				  lock->key != &__lockdep_no_validate__,
> +				  "class->name=%s lock->name=%s lock->key=%ps\n",
> +				  class->name, lock->name, lock->key);

Maybe more human readable information like:

	  "Looking for class \"%s\" with key %ps, but found a different class \"%s\" with the same key\n"
	  lock->name, lock->key, class->name);

?

Regards,
Boqun

>  			return class;
>  		}
>  	}
> -- 
> 2.34.1
> 

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

* [PATCH v2] lockdep: report name and key when look_up_lock_class() got confused
  2022-09-18 18:31 ` Boqun Feng
@ 2022-09-19  0:52   ` Tetsuo Handa
  2022-09-19 10:48     ` Peter Zijlstra
  2022-09-21  8:01     ` [tip: locking/core] locking/lockdep: Print more debug information - " tip-bot2 for Tetsuo Handa
  0 siblings, 2 replies; 6+ messages in thread
From: Tetsuo Handa @ 2022-09-19  0:52 UTC (permalink / raw)
  To: Boqun Feng, Peter Zijlstra, Ingo Molnar, Will Deacon, Waiman Long; +Cc: LKML

Printing this information will be helpful.

  ------------[ cut here ]------------
  Looking for class "l2tp_sock" with key l2tp_socket_class, but found a different class "slock-AF_INET6" with the same key
  WARNING: CPU: 1 PID: 14195 at kernel/locking/lockdep.c:940 look_up_lock_class+0xcc/0x140
  Modules linked in:
  CPU: 1 PID: 14195 Comm: a.out Not tainted 6.0.0-rc6-dirty #863
  Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
  RIP: 0010:look_up_lock_class+0xcc/0x140

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
Changes in v2:
  Make message more human readable, suggested by Boqun Feng <boqun.feng@gmail.com>.

 kernel/locking/lockdep.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 64a13eb56078..e3375bc40dad 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -934,8 +934,10 @@ look_up_lock_class(const struct lockdep_map *lock, unsigned int subclass)
 			 * Huh! same key, different name? Did someone trample
 			 * on some memory? We're most confused.
 			 */
-			WARN_ON_ONCE(class->name != lock->name &&
-				     lock->key != &__lockdep_no_validate__);
+			WARN_ONCE(class->name != lock->name &&
+				  lock->key != &__lockdep_no_validate__,
+				  "Looking for class \"%s\" with key %ps, but found a different class \"%s\" with the same key\n",
+				  lock->name, lock->key, class->name);
 			return class;
 		}
 	}
-- 
2.34.1


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

* Re: [PATCH v2] lockdep: report name and key when look_up_lock_class() got confused
  2022-09-19  0:52   ` [PATCH v2] " Tetsuo Handa
@ 2022-09-19 10:48     ` Peter Zijlstra
  2022-09-19 13:44       ` Tetsuo Handa
  2022-09-21  8:01     ` [tip: locking/core] locking/lockdep: Print more debug information - " tip-bot2 for Tetsuo Handa
  1 sibling, 1 reply; 6+ messages in thread
From: Peter Zijlstra @ 2022-09-19 10:48 UTC (permalink / raw)
  To: Tetsuo Handa; +Cc: Boqun Feng, Ingo Molnar, Will Deacon, Waiman Long, LKML

On Mon, Sep 19, 2022 at 09:52:13AM +0900, Tetsuo Handa wrote:
> Printing this information will be helpful.
> 
>   ------------[ cut here ]------------
>   Looking for class "l2tp_sock" with key l2tp_socket_class, but found a different class "slock-AF_INET6" with the same key
>   WARNING: CPU: 1 PID: 14195 at kernel/locking/lockdep.c:940 look_up_lock_class+0xcc/0x140
>   Modules linked in:
>   CPU: 1 PID: 14195 Comm: a.out Not tainted 6.0.0-rc6-dirty #863
>   Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
>   RIP: 0010:look_up_lock_class+0xcc/0x140
> 
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>

Urgh, you hitting that WARN enough times to want to improve it seems to
suggest your machine is quite sick.

Anyway, patch is ok I suppose.

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

* Re: [PATCH v2] lockdep: report name and key when look_up_lock_class() got confused
  2022-09-19 10:48     ` Peter Zijlstra
@ 2022-09-19 13:44       ` Tetsuo Handa
  0 siblings, 0 replies; 6+ messages in thread
From: Tetsuo Handa @ 2022-09-19 13:44 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: Boqun Feng, Ingo Molnar, Will Deacon, Waiman Long, LKML

On 2022/09/19 19:48, Peter Zijlstra wrote:
> On Mon, Sep 19, 2022 at 09:52:13AM +0900, Tetsuo Handa wrote:
>> Printing this information will be helpful.
>>
>>   ------------[ cut here ]------------
>>   Looking for class "l2tp_sock" with key l2tp_socket_class, but found a different class "slock-AF_INET6" with the same key
>>   WARNING: CPU: 1 PID: 14195 at kernel/locking/lockdep.c:940 look_up_lock_class+0xcc/0x140
>>   Modules linked in:
>>   CPU: 1 PID: 14195 Comm: a.out Not tainted 6.0.0-rc6-dirty #863
>>   Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
>>   RIP: 0010:look_up_lock_class+0xcc/0x140
>>
>> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> 
> Urgh, you hitting that WARN enough times to want to improve it seems to
> suggest your machine is quite sick.

My machine is not sick at all. I just wanted this hint for debugging
https://syzkaller.appspot.com/bug?extid=94cc2a66fc228b23f360 .

In a world of debugging without vmcore, printing as much hint as possible is
important. Therefore, WARN_ONCE() is more appreciated than WARN_ON_ONCE().

> 
> Anyway, patch is ok I suppose.

Thank you. Please send this patch and
https://lkml.kernel.org/r/9f42e8a5-f809-3f2c-0fda-b7657bc94eb3@I-love.SAKURA.ne.jp
via your tree.


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

* [tip: locking/core] locking/lockdep: Print more debug information - report name and key when look_up_lock_class() got confused
  2022-09-19  0:52   ` [PATCH v2] " Tetsuo Handa
  2022-09-19 10:48     ` Peter Zijlstra
@ 2022-09-21  8:01     ` tip-bot2 for Tetsuo Handa
  1 sibling, 0 replies; 6+ messages in thread
From: tip-bot2 for Tetsuo Handa @ 2022-09-21  8:01 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Tetsuo Handa, Ingo Molnar, x86, linux-kernel

The following commit has been merged into the locking/core branch of tip:

Commit-ID:     76e64c73db9542ff4bae8a60f4f32e38f3799b95
Gitweb:        https://git.kernel.org/tip/76e64c73db9542ff4bae8a60f4f32e38f3799b95
Author:        Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
AuthorDate:    Mon, 19 Sep 2022 09:52:13 +09:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Wed, 21 Sep 2022 09:58:21 +02:00

locking/lockdep: Print more debug information - report name and key when look_up_lock_class() got confused

Printing this information will be helpful:

  ------------[ cut here ]------------
  Looking for class "l2tp_sock" with key l2tp_socket_class, but found a different class "slock-AF_INET6" with the same key
  WARNING: CPU: 1 PID: 14195 at kernel/locking/lockdep.c:940 look_up_lock_class+0xcc/0x140
  Modules linked in:
  CPU: 1 PID: 14195 Comm: a.out Not tainted 6.0.0-rc6-dirty #863
  Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
  RIP: 0010:look_up_lock_class+0xcc/0x140

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/bd99391e-f787-efe9-5ec6-3c6dc4c587b0@I-love.SAKURA.ne.jp
---
 kernel/locking/lockdep.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 64a13eb..e3375bc 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -934,8 +934,10 @@ look_up_lock_class(const struct lockdep_map *lock, unsigned int subclass)
 			 * Huh! same key, different name? Did someone trample
 			 * on some memory? We're most confused.
 			 */
-			WARN_ON_ONCE(class->name != lock->name &&
-				     lock->key != &__lockdep_no_validate__);
+			WARN_ONCE(class->name != lock->name &&
+				  lock->key != &__lockdep_no_validate__,
+				  "Looking for class \"%s\" with key %ps, but found a different class \"%s\" with the same key\n",
+				  lock->name, lock->key, class->name);
 			return class;
 		}
 	}

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

end of thread, other threads:[~2022-09-21  8:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-18 15:01 [PATCH] lockdep: report name and key when look_up_lock_class() got confused Tetsuo Handa
2022-09-18 18:31 ` Boqun Feng
2022-09-19  0:52   ` [PATCH v2] " Tetsuo Handa
2022-09-19 10:48     ` Peter Zijlstra
2022-09-19 13:44       ` Tetsuo Handa
2022-09-21  8:01     ` [tip: locking/core] locking/lockdep: Print more debug information - " tip-bot2 for Tetsuo Handa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.