linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lockdep: add a hint for "INFO: trying to register non-static key." message
@ 2021-03-21  6:49 Tetsuo Handa
  2021-03-21 11:05 ` [tip: perf/urgent] lockdep: Add a missing initialization hint to the "INFO: Trying to register non-static key" message tip-bot2 for Tetsuo Handa
  2021-03-22 17:19 ` [PATCH] lockdep: add a hint for "INFO: trying to register non-static key." message Waiman Long
  0 siblings, 2 replies; 3+ messages in thread
From: Tetsuo Handa @ 2021-03-21  6:49 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Will Deacon
  Cc: Waiman Long, Boqun Feng, linux-kernel, Tetsuo Handa

Since this message is printed when dynamically allocated spinlocks (e.g.
kzalloc()) are used without initialization (e.g. spin_lock_init()),
suggest developers to check whether initialization functions for objects
are called, before making developers wonder what annotation is missing.

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

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index c6d0c1dc6253..44c549f5c061 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -931,6 +931,7 @@ static bool assign_lock_key(struct lockdep_map *lock)
 		debug_locks_off();
 		pr_err("INFO: trying to register non-static key.\n");
 		pr_err("the code is fine but needs lockdep annotation.\n");
+		pr_err("maybe you didn't initialize this object before you use?\n");
 		pr_err("turning off the locking correctness validator.\n");
 		dump_stack();
 		return false;
-- 
2.18.4


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

* [tip: perf/urgent] lockdep: Add a missing initialization hint to the "INFO: Trying to register non-static key" message
  2021-03-21  6:49 [PATCH] lockdep: add a hint for "INFO: trying to register non-static key." message Tetsuo Handa
@ 2021-03-21 11:05 ` tip-bot2 for Tetsuo Handa
  2021-03-22 17:19 ` [PATCH] lockdep: add a hint for "INFO: trying to register non-static key." message Waiman Long
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Tetsuo Handa @ 2021-03-21 11:05 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Tetsuo Handa, Ingo Molnar, x86, linux-kernel

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     3a85969e9d912d5dd85362ee37b5f81266e00e77
Gitweb:        https://git.kernel.org/tip/3a85969e9d912d5dd85362ee37b5f81266e00e77
Author:        Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
AuthorDate:    Sun, 21 Mar 2021 15:49:13 +09:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Sun, 21 Mar 2021 11:59:57 +01:00

lockdep: Add a missing initialization hint to the "INFO: Trying to register non-static key" message

Since this message is printed when dynamically allocated spinlocks (e.g.
kzalloc()) are used without initialization (e.g. spin_lock_init()),
suggest to developers to check whether initialization functions for objects
were called, before making developers wonder what annotation is missing.

[ mingo: Minor tweaks to the message. ]

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/20210321064913.4619-1-penguin-kernel@I-love.SAKURA.ne.jp
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/locking/lockdep.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index c6d0c1d..c30eb88 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -930,7 +930,8 @@ static bool assign_lock_key(struct lockdep_map *lock)
 		/* Debug-check: all keys must be persistent! */
 		debug_locks_off();
 		pr_err("INFO: trying to register non-static key.\n");
-		pr_err("the code is fine but needs lockdep annotation.\n");
+		pr_err("The code is fine but needs lockdep annotation, or maybe\n");
+		pr_err("you didn't initialize this object before use?\n");
 		pr_err("turning off the locking correctness validator.\n");
 		dump_stack();
 		return false;

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

* Re: [PATCH] lockdep: add a hint for "INFO: trying to register non-static key." message
  2021-03-21  6:49 [PATCH] lockdep: add a hint for "INFO: trying to register non-static key." message Tetsuo Handa
  2021-03-21 11:05 ` [tip: perf/urgent] lockdep: Add a missing initialization hint to the "INFO: Trying to register non-static key" message tip-bot2 for Tetsuo Handa
@ 2021-03-22 17:19 ` Waiman Long
  1 sibling, 0 replies; 3+ messages in thread
From: Waiman Long @ 2021-03-22 17:19 UTC (permalink / raw)
  To: Tetsuo Handa, Peter Zijlstra, Ingo Molnar, Will Deacon
  Cc: Boqun Feng, linux-kernel

On 3/21/21 2:49 AM, Tetsuo Handa wrote:
> Since this message is printed when dynamically allocated spinlocks (e.g.
> kzalloc()) are used without initialization (e.g. spin_lock_init()),
> suggest developers to check whether initialization functions for objects
> are called, before making developers wonder what annotation is missing.
>
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> ---
>   kernel/locking/lockdep.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index c6d0c1dc6253..44c549f5c061 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -931,6 +931,7 @@ static bool assign_lock_key(struct lockdep_map *lock)
>   		debug_locks_off();
>   		pr_err("INFO: trying to register non-static key.\n");
>   		pr_err("the code is fine but needs lockdep annotation.\n");
> +		pr_err("maybe you didn't initialize this object before you use?\n");
>   		pr_err("turning off the locking correctness validator.\n");
>   		dump_stack();
>   		return false;

The only way this message is written is when the appropriate lock init 
function isn't called for locks in dynamically allocated objects. I 
think you can just say so without the word "maybe". Like "the code is 
fine but needs lockdep annotation by calling appropriate lock 
initialization function.".

Cheers,
Longman


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

end of thread, other threads:[~2021-03-22 17:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-21  6:49 [PATCH] lockdep: add a hint for "INFO: trying to register non-static key." message Tetsuo Handa
2021-03-21 11:05 ` [tip: perf/urgent] lockdep: Add a missing initialization hint to the "INFO: Trying to register non-static key" message tip-bot2 for Tetsuo Handa
2021-03-22 17:19 ` [PATCH] lockdep: add a hint for "INFO: trying to register non-static key." message Waiman Long

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).