From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: "Toke Høiland-Jørgensen" <toke@redhat.com>
Cc: kernel test robot <lkp@intel.com>,
kbuild-all@lists.01.org, linux-kernel@vger.kernel.org,
Daniel Borkmann <daniel@iogearbox.net>,
"Paul E . McKenney" <paulmck@kernel.org>,
linux-ia64@vger.kernel.org
Subject: Re: kernel/bpf/devmap.c:1030:40: sparse: sparse: cast removes address space '__rcu' of expression
Date: Wed, 1 Jun 2022 14:00:13 +0200 [thread overview]
Message-ID: <20220601120013.bq5a3ynbkc3hngm5@mail> (raw)
In-Reply-To: <87h7547k8c.fsf@toke.dk>
On Wed, Jun 01, 2022 at 12:26:27PM +0200, Toke Høiland-Jørgensen wrote:
> Luc Van Oostenryck <luc.vanoostenryck@gmail.com> writes:
>
> > On Mon, May 23, 2022 at 12:30:14PM +0200, Toke Høiland-Jørgensen wrote:
> >> kernel test robot <lkp@intel.com> writes:
> >>
> >> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> >> > head: eaea45fc0e7b6ae439526b4a41d91230c8517336
> >> > commit: 782347b6bcad07ddb574422e01e22c92e05928c8 xdp: Add proper __rcu annotations to redirect map entries
> >> > date: 11 months ago
> >> > config: ia64-randconfig-s031-20220522 (https://download.01.org/0day-ci/archive/20220522/202205222029.xpW3PM1y-lkp@intel.com/config)
> >> > compiler: ia64-linux-gcc (GCC) 11.3.0
> >>
> >> Hmm, so this is ia64-only? Some kind of macro breakage? Paul, any ideas?
> >
> > Hi,
> >
> > It's surely IA64's cmpxchg() which contains lines like:
> > _r_ = ia64_cmpxchg8_##sem((__u64 *) ptr, new, _o_);
>
> Oh, right. Hmm, well, if the cmpxchg does an internal cast that
> complicates things a bit. My immediate thought was to move the
> unrcu_pointer() inside the calls to cmpxchg(), like:
> But that seems to confuse sparse because these are ptr-to-ptr
> constructs:
Yes, that can't work because it applies on the wrong level (same difference as
between "int const ** ptr" and "int * const * ptr").
I've taken a quick look and the problem is really to be solved in IA64's
macros for cmpxchg() and friends. Two things need to be done:
1) avoid casts like the "(__u64 *) ptr" here above (ideally no cast would
be needed but a "(__u64 __force *) ptr" would be pefectly acceptable in
such macros.
2) the value returned by these macros must match the type of the pointer
and the old/new values. For example, on x86 such macros are written as:
({
__typeof__ (*(ptr)) __ret = (arg);
switch (sizeof(*(ptr))) {
case ...
... use ptr without dropping the address space ..
__ret;
)}
See, for example, arch/x86/include/asm/cmpxchg.h
-- Luc
next prev parent reply other threads:[~2022-06-01 12:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-22 12:30 kernel test robot
2022-05-23 10:30 ` Toke Høiland-Jørgensen
2022-05-24 20:51 ` Paul E. McKenney
2022-06-01 0:38 ` Luc Van Oostenryck
2022-06-01 10:26 ` Toke Høiland-Jørgensen
2022-06-01 12:00 ` Luc Van Oostenryck [this message]
2022-06-05 16:07 ` [PATCH] ia64: fix sparse warnings with cmpxchg() & xchg() Luc Van Oostenryck
2022-06-05 19:58 ` Paul E. McKenney
2022-06-06 7:53 ` Toke Høiland-Jørgensen
-- strict thread matches above, loose matches on Subject: below --
2021-11-20 1:45 kernel/bpf/devmap.c:1030:40: sparse: sparse: cast removes address space '__rcu' of expression kernel test robot
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=20220601120013.bq5a3ynbkc3hngm5@mail \
--to=luc.vanoostenryck@gmail.com \
--cc=daniel@iogearbox.net \
--cc=kbuild-all@lists.01.org \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=paulmck@kernel.org \
--cc=toke@redhat.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
all inboxes | Powered by JetHome®