From: Vlastimil Babka <vbabka@suse.cz>
To: Vincent Mailhol <mailhol@kernel.org>,
Shakeel Butt <shakeel.butt@linux.dev>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Alexei Starovoitov <ast@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
Waiman Long <longman@redhat.com>,
Boqun Feng <boqun.feng@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] locking/local_lock: s/l/__l/ and s/tl/__tl/ to reduce risk of shadowing
Date: Mon, 29 Sep 2025 09:16:47 +0200 [thread overview]
Message-ID: <e9fa7e27-d622-4a1e-96c9-c819f5486619@suse.cz> (raw)
In-Reply-To: <5f7821d5-0b48-4600-ab99-d76a52361fc1@kernel.org>
On 9/27/25 05:04, Vincent Mailhol wrote:
> On 9/26/25 11:16 PM, Vlastimil Babka wrote:
>> +CC LOCKING PRIMITIVES maintainers. Looks like local_lock files were never
>> added to the section, should we?
>>
>> On 9/24/25 20:03, Vincent Mailhol wrote:
>>> The Linux kernel coding style [1] advises to avoid common variable
>>> names in function-like macros to reduce the risk of collisions.
>>
>> I think it would be better if the tools like sparse could recognize if the
>> shadowing happens inside a macro only and thus really unlikely to cause a
>> misuse due to confusion (code thinks it's manipulating an outer instance but
>> instead it's the inner one), because macros in their definition would never
>> intend to manipulate a possible outer instance, right? Or are there any
>> other problems due to shadowing besides this risk?
>
> Thank would mean:
>
> - rewriting the shadowing check in sparse
> - removing the -Wshadow from the W=2 list
> - modifying the kernel coding style
>
> I am not against this. But I am not unhappy with the current status quo either.
>
> So far, I kept sending patches whenever I saw such shadow warning in header
> files. And over the last five years, this resulted in only three occurrences:
>
> - commit 146034fed6ee ("x86/asm/bitops: Use __builtin_ffs() to evaluate
> constant expressions")
> Link: https://git.kernel.org/torvalds/c/146034fed6ee
>
>
> - commit 9ce02f0fc683 ("x86/bug: Prevent shadowing in __WARN_FLAGS")
> Link: https://git.kernel.org/torvalds/c/9ce02f0fc683
>
> - this patch
>
> Between sending one patch every couple year or enrolling to a quest to modify
> the tooling, my choice is already made. If someone else want to do this change,
> I would be supportive, but that person will not be me.
Thanks for that perspective, with that it seems now clear to me that a rare
fixup of some macro is indeed much easier.
> On a side note, I want to highlight that it is not that I am reluctant to modify
> the tooling. For example, I sent contributed this commit to sparse last week:
>
> commit 366ad4b2fa3e ("Warn about "unsigned value that used to be signed against
> zero"")
>
> Link:
> https://git.kernel.org/pub/scm/devel/sparse/sparse-dev.git/commit/?id=366ad4b2fa3e
next prev parent reply other threads:[~2025-09-29 7:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-24 18:03 Vincent Mailhol
2025-09-26 14:16 ` Vlastimil Babka
2025-09-26 14:20 ` Sebastian Andrzej Siewior
2025-09-26 14:29 ` Vlastimil Babka
2025-09-26 14:30 ` Sebastian Andrzej Siewior
2025-09-27 3:04 ` Vincent Mailhol
2025-09-29 7:16 ` Vlastimil Babka [this message]
2025-09-29 8:50 ` Vincent Mailhol
2025-09-30 6:41 ` Sebastian Andrzej Siewior
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=e9fa7e27-d622-4a1e-96c9-c819f5486619@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=ast@kernel.org \
--cc=bigeasy@linutronix.de \
--cc=boqun.feng@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mailhol@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=shakeel.butt@linux.dev \
--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
all inboxes | Powered by JetHome®