linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Charlemagne Lasse <charlemagnelasse@gmail.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@kernel.org>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	Muchun Song <muchun.song@linux.dev>,
	Andrew Morton <akpm@linux-foundation.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Clark Williams <clrkwllms@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Jakub Kicinski <kuba@kernel.org>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	Davidlohr Bueso <dave@stgolabs.net>,
	LKML <linux-kernel@vger.kernel.org>,
	cgroups@vger.kernel.org, linux-mm@kvack.org,
	linux-rt-devel@lists.linux.dev
Subject: Re: locking/local_lock, mm: sparse warnings about shadowed variable
Date: Wed, 11 Jun 2025 19:57:45 +0200	[thread overview]
Message-ID: <68c0649d-d9b3-44f4-9a92-7f72c51a5013@suse.cz> (raw)
In-Reply-To: <CAFGhKbwVyxCwYSNrPaQ-GkuP008+uvDg-wNA5syWLLzODCfpcA@mail.gmail.com>

On 6/11/25 19:37, Charlemagne Lasse wrote:
> HI,
> 
> when I run `make C=2 mm/mlock.o CHECK="sparse -Wshadow"`, I get a lot of
> 
> ./include/linux/local_lock.h:88:1: warning: symbol 'l' shadows an earlier one
> ./include/linux/local_lock.h:88:1: originally declared here
> 
> after commit
> 
> 51339d99c0131bc0d16d378e9b05bc498d2967e2 is the first bad commit
> commit 51339d99c0131bc0d16d378e9b05bc498d2967e2
> Author: Alexei Starovoitov <ast@kernel.org>
> Date:   2025-04-02 19:55:14 -0700
> 
>    locking/local_lock, mm: replace localtry_ helpers with local_trylock_t type

Looks like __DEFINE_LOCK_GUARD_1() has "_type *l" and __local_lock_acquire()
has "local_lock_t *l;". It can be fixed e.g. like this, although it's
harmless? The _release() part is not necessary, just for symmetry.

diff --git a/include/linux/local_lock_internal.h b/include/linux/local_lock_internal.h
index 8d5ac16a9b17..075338f270d0 100644
--- a/include/linux/local_lock_internal.h
+++ b/include/linux/local_lock_internal.h
@@ -97,17 +97,17 @@ do {                                                                \
 #define __local_lock_acquire(lock)                                     \
        do {                                                            \
                local_trylock_t *tl;                                    \
-               local_lock_t *l;                                        \
+               local_lock_t *ll;                                       \
                                                                        \
-               l = (local_lock_t *)this_cpu_ptr(lock);                 \
-               tl = (local_trylock_t *)l;                              \
+               ll = (local_lock_t *)this_cpu_ptr(lock);                \
+               tl = (local_trylock_t *)ll;                             \
                _Generic((lock),                                        \
                        __percpu local_trylock_t *: ({                  \
                                lockdep_assert(tl->acquired == 0);      \
                                WRITE_ONCE(tl->acquired, 1);            \
                        }),                                             \
                        __percpu local_lock_t *: (void)0);              \
-               local_lock_acquire(l);                                  \
+               local_lock_acquire(ll);                                 \
        } while (0)
 
 #define __local_lock(lock)                                     \
@@ -165,11 +165,11 @@ do {                                                              \
 #define __local_lock_release(lock)                                     \
        do {                                                            \
                local_trylock_t *tl;                                    \
-               local_lock_t *l;                                        \
+               local_lock_t *ll;                                       \
                                                                        \
-               l = (local_lock_t *)this_cpu_ptr(lock);                 \
-               tl = (local_trylock_t *)l;                              \
-               local_lock_release(l);                                  \
+               ll = (local_lock_t *)this_cpu_ptr(lock);                \
+               tl = (local_trylock_t *)ll;                             \
+               local_lock_release(ll);                                 \
                _Generic((lock),                                        \
                        __percpu local_trylock_t *: ({                  \
                                lockdep_assert(tl->acquired == 1);      \



  reply	other threads:[~2025-06-11 17:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-11 17:37 Charlemagne Lasse
2025-06-11 17:57 ` Vlastimil Babka [this message]
2025-06-11 18:20   ` Alexei Starovoitov
2025-06-11 22:33     ` Andrew Morton
2025-06-12  7:03     ` Charlemagne Lasse

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=68c0649d-d9b3-44f4-9a92-7f72c51a5013@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=ast@kernel.org \
    --cc=bigeasy@linutronix.de \
    --cc=cgroups@vger.kernel.org \
    --cc=charlemagnelasse@gmail.com \
    --cc=clrkwllms@kernel.org \
    --cc=dave@stgolabs.net \
    --cc=hannes@cmpxchg.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=mhocko@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=peterz@infradead.org \
    --cc=roman.gushchin@linux.dev \
    --cc=rostedt@goodmis.org \
    --cc=shakeel.butt@linux.dev \
    --cc=tglx@linutronix.de \
    /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