From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Dmitry Vyukov <dvyukov@google.com>,
linux-sparse@vger.kernel.org, Christopher Li <sparse@chrisli.org>,
kbuild test robot <fengguang.wu@intel.com>,
kbuild-all@01.org, LKML <linux-kernel@vger.kernel.org>,
tipbuild@zytor.com, Ingo Molnar <mingo@kernel.org>
Subject: Re: [tip:locking/core 9/11] include/asm-generic/atomic-instrumented.h:288:24: sparse: cast truncates bits from constant value (100 becomes 0)
Date: Tue, 13 Mar 2018 21:01:21 +0100 [thread overview]
Message-ID: <20180313200119.oydccd4qd5366hfe@ltop.local> (raw)
In-Reply-To: <20180313180806.GO4043@hirez.programming.kicks-ass.net>
On Tue, Mar 13, 2018 at 07:08:06PM +0100, Peter Zijlstra wrote:
> On Tue, Mar 13, 2018 at 07:00:17PM +0100, Luc Van Oostenryck wrote:
> > The issue here is that sparse has a whole class of warnings that are
> > given very early (here at expansion of constant expressions), before
> > eliminating code from branches that are never taken (which, surprise,
> > need itself to have constant expressions already expanded).
> >
> > It's often annoying like the case here.
> > OTOH, I don't think it's always a bad thing. Sometimes we want to
> > have warnings even from code we know will not be executed (in this
> > config but maybe it will in another one).
>
> Is that really a valid concern with all the automated randconfig
> building going on today?
I don't think so, for the kernel at least. For other uses it may.
But don't take me wrongly: I don't want to defend those warnings here,
I just want to say that the situation is not totally black & white.
One easy-short-term solution that wouldn't make things ugly would be
to use a mask instead of a cast:
static __always_inline unsigned long
cmpxchg_size(volatile void *ptr, unsigned long old, unsigned long new, int size)
{
switch (size) {
case 1:
- return arch_cmpxchg((u8 *)ptr, (u8)old, (u8)new);
+ return arch_cmpxchg((u8 *)ptr, old & 0xff, new & 0xff);
case 2:
- return arch_cmpxchg((u16 *)ptr, (u16)old, (u16)new);
+ return arch_cmpxchg((u16 *)ptr, old & 0xffff, new & 0xffff);
-- Luc
prev parent reply other threads:[~2018-03-13 20:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-12 14:52 [tip:locking/core 9/11] include/asm-generic/atomic-instrumented.h:288:24: sparse: cast truncates bits from constant value (100 becomes 0) kbuild test robot
2018-03-12 15:17 ` Dmitry Vyukov
2018-03-13 8:49 ` Dmitry Vyukov
2018-03-13 10:46 ` Peter Zijlstra
2018-03-13 11:08 ` Dmitry Vyukov
2018-03-13 17:29 ` Christopher Li
2018-03-13 18:00 ` Luc Van Oostenryck
2018-03-13 18:08 ` Peter Zijlstra
2018-03-13 20:01 ` Luc Van Oostenryck [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=20180313200119.oydccd4qd5366hfe@ltop.local \
--to=luc.vanoostenryck@gmail.com \
--cc=dvyukov@google.com \
--cc=fengguang.wu@intel.com \
--cc=kbuild-all@01.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sparse@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=sparse@chrisli.org \
--cc=tipbuild@zytor.com \
/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).