From: Vlastimil Babka <vbabka@suse.cz>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: kernel test robot <lkp@intel.com>,
Alexei Starovoitov <ast@kernel.org>,
Harry Yoo <harry.yoo@oracle.com>,
clang-built-linux <llvm@lists.linux.dev>,
oe-kbuild-all@lists.linux.dev, linux-mm <linux-mm@kvack.org>
Subject: Re: [vbabka-slab:slab/for-6.18/kmalloc_nolock 14/14] mm/slub.c:3866:2: warning: variable 'flags' is used uninitialized whenever '&&' condition is false
Date: Sat, 13 Sep 2025 22:46:46 +0200 [thread overview]
Message-ID: <b1628e73-92d6-4b2a-b0a0-0f7e26f8c3a1@suse.cz> (raw)
In-Reply-To: <CAADnVQJWXk+Zzsf_oVTaJkpm4nO3iq34bGcUDQRarOVSX+tLbA@mail.gmail.com>
On 9/12/25 18:39, Alexei Starovoitov wrote:
> On Fri, Sep 12, 2025 at 6:23 AM Vlastimil Babka <vbabka@suse.cz> wrote:
>>
>> --- a/mm/slub.c
>> +++ b/mm/slub.c
>> @@ -3772,8 +3772,11 @@ static void deactivate_slab(struct kmem_cache *s, struct slab *slab,
>> #define local_lock_cpu_slab(s, flags) \
>> local_lock_irqsave(&(s)->cpu_slab->lock, flags)
>> #else
>> -#define local_lock_cpu_slab(s, flags) \
>> - lockdep_assert(local_trylock_irqsave(&(s)->cpu_slab->lock, flags))
>> +#define gg(s, flags) \
>> + do { \
>> + bool __l = local_trylock_irqsave(&(s)->cpu_slab->lock, flags); \
>> + lockdep_assert(__l);
>
> That works, but would raise questions for anyone looking at
> these two lines as-is, since it's an implementation
> detail of lockdep_assert() and combination of .config flags.
TBH when I see some code with a side-effect wrapped in a WARN or assert that
can be configured off, it already raises a question if that gets executed
when configured off. There are examples where it does, and where it doesn't.
> what clang warning suggested is imo cleaner:
That silences the warning about flags, however it means that when lockdep
gets disabled on runtime, the locks stop locking (but not unlocking). While
debug_locks_off() only seems to get called in a serious situations
currently, we should not make things even worse then.
> diff --git a/mm/slub.c b/mm/slub.c
> index 4079abb5d0e1..a6b50cd1d95f 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -3865,7 +3865,7 @@ static void put_cpu_partial(struct kmem_cache
> *s, struct slab *slab, int drain)
> {
> struct slab *oldslab;
> struct slab *slab_to_put = NULL;
> - unsigned long flags;
> + unsigned long flags = 0;
> int slabs = 0;
>
> Could you fold one of them in?
And so I've folded in mine.
prev parent reply other threads:[~2025-09-13 20:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-12 10:25 kernel test robot
2025-09-12 13:23 ` Vlastimil Babka
2025-09-12 16:39 ` Alexei Starovoitov
2025-09-13 20:46 ` Vlastimil Babka [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=b1628e73-92d6-4b2a-b0a0-0f7e26f8c3a1@suse.cz \
--to=vbabka@suse.cz \
--cc=alexei.starovoitov@gmail.com \
--cc=ast@kernel.org \
--cc=harry.yoo@oracle.com \
--cc=linux-mm@kvack.org \
--cc=lkp@intel.com \
--cc=llvm@lists.linux.dev \
--cc=oe-kbuild-all@lists.linux.dev \
/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