linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>
Cc: Boqun Feng <boqun.feng@gmail.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lockdep: add a hint for "INFO: trying to register non-static key." message
Date: Mon, 22 Mar 2021 13:19:11 -0400	[thread overview]
Message-ID: <9add0c6f-d75e-388f-5a34-5633f5829fc1@redhat.com> (raw)
In-Reply-To: <20210321064913.4619-1-penguin-kernel@I-love.SAKURA.ne.jp>

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


      parent reply	other threads:[~2021-03-22 17:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9add0c6f-d75e-388f-5a34-5633f5829fc1@redhat.com \
    --to=longman@redhat.com \
    --cc=boqun.feng@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=peterz@infradead.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).