From: "Toke Høiland-Jørgensen" <toke@redhat.com> To: Luc Van Oostenryck <luc.vanoostenryck@gmail.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> Subject: Re: kernel/bpf/devmap.c:1030:40: sparse: sparse: cast removes address space '__rcu' of expression Date: Wed, 01 Jun 2022 12:26:27 +0200 [thread overview] Message-ID: <87h7547k8c.fsf@toke.dk> (raw) In-Reply-To: <20220601003834.ilvx2pik672yxuxt@mail> 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: diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c index 980f8928e977..3b6dc6d34177 100644 --- a/kernel/bpf/devmap.c +++ b/kernel/bpf/devmap.c @@ -1098,7 +1098,7 @@ static int dev_map_notification(struct notifier_block *notifier, dev = rcu_dereference(dtab->netdev_map[i]); if (!dev || netdev != dev->dev) continue; - odev = unrcu_pointer(cmpxchg(&dtab->netdev_map[i], RCU_INITIALIZER(dev), NULL)); + odev = cmpxchg(unrcu_pointer(&dtab->netdev_map[i]), dev, NULL); if (dev == odev) call_rcu(&dev->rcu, __dev_map_entry_free); But that seems to confuse sparse because these are ptr-to-ptr constructs: kernel/bpf/devmap.c:1101:40: error: incompatible types in comparison expression (different address spaces): kernel/bpf/devmap.c:1101:40: struct bpf_dtab_netdev [noderef] __rcu *[noderef] __rcu * kernel/bpf/devmap.c:1101:40: struct bpf_dtab_netdev [noderef] __rcu ** kernel/bpf/devmap.c:1101:40: error: incompatible types in comparison expression (different address spaces): kernel/bpf/devmap.c:1101:40: struct bpf_dtab_netdev [noderef] __rcu *[noderef] __rcu * kernel/bpf/devmap.c:1101:40: struct bpf_dtab_netdev [noderef] __rcu ** which I'm not sure how to fix. And not really sure if it's the semantically right thing to do either in this case... -Toke
WARNING: multiple messages have this Message-ID (diff)
From: Toke Høiland-Jørgensen <toke@redhat.com> To: kbuild-all@lists.01.org Subject: Re: kernel/bpf/devmap.c:1030:40: sparse: sparse: cast removes address space '__rcu' of expression Date: Wed, 01 Jun 2022 12:26:27 +0200 [thread overview] Message-ID: <87h7547k8c.fsf@toke.dk> (raw) In-Reply-To: <20220601003834.ilvx2pik672yxuxt@mail> [-- Attachment #1: Type: text/plain, Size: 2643 bytes --] 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(a)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: diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c index 980f8928e977..3b6dc6d34177 100644 --- a/kernel/bpf/devmap.c +++ b/kernel/bpf/devmap.c @@ -1098,7 +1098,7 @@ static int dev_map_notification(struct notifier_block *notifier, dev = rcu_dereference(dtab->netdev_map[i]); if (!dev || netdev != dev->dev) continue; - odev = unrcu_pointer(cmpxchg(&dtab->netdev_map[i], RCU_INITIALIZER(dev), NULL)); + odev = cmpxchg(unrcu_pointer(&dtab->netdev_map[i]), dev, NULL); if (dev == odev) call_rcu(&dev->rcu, __dev_map_entry_free); But that seems to confuse sparse because these are ptr-to-ptr constructs: kernel/bpf/devmap.c:1101:40: error: incompatible types in comparison expression (different address spaces): kernel/bpf/devmap.c:1101:40: struct bpf_dtab_netdev [noderef] __rcu *[noderef] __rcu * kernel/bpf/devmap.c:1101:40: struct bpf_dtab_netdev [noderef] __rcu ** kernel/bpf/devmap.c:1101:40: error: incompatible types in comparison expression (different address spaces): kernel/bpf/devmap.c:1101:40: struct bpf_dtab_netdev [noderef] __rcu *[noderef] __rcu * kernel/bpf/devmap.c:1101:40: struct bpf_dtab_netdev [noderef] __rcu ** which I'm not sure how to fix. And not really sure if it's the semantically right thing to do either in this case... -Toke
next prev parent reply other threads:[~2022-06-01 10:26 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-05-22 12:30 kernel/bpf/devmap.c:1030:40: sparse: sparse: cast removes address space '__rcu' of expression kernel test robot 2022-05-23 10:30 ` Toke Høiland-Jørgensen 2022-05-23 10:30 ` Toke Høiland-Jørgensen 2022-05-24 20:51 ` Paul E. McKenney 2022-05-24 20:51 ` Paul E. McKenney 2022-06-01 0:38 ` Luc Van Oostenryck 2022-06-01 0:38 ` Luc Van Oostenryck 2022-06-01 10:26 ` Toke Høiland-Jørgensen [this message] 2022-06-01 10:26 ` Toke Høiland-Jørgensen 2022-06-01 11:59 ` Luc Van Oostenryck 2022-06-01 12:00 ` Luc Van Oostenryck 2022-06-01 12:00 ` Luc Van Oostenryck 2022-06-05 16:07 ` [PATCH] ia64: fix sparse warnings with cmpxchg() & xchg() Luc Van Oostenryck 2022-06-05 16:07 ` Luc Van Oostenryck 2022-06-05 19:58 ` Paul E. McKenney 2022-06-05 19:58 ` Paul E. McKenney 2022-06-06 7:53 ` Toke Høiland-Jørgensen 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 2021-11-20 1:45 ` 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=87h7547k8c.fsf@toke.dk \ --to=toke@redhat.com \ --cc=daniel@iogearbox.net \ --cc=kbuild-all@lists.01.org \ --cc=linux-kernel@vger.kernel.org \ --cc=lkp@intel.com \ --cc=luc.vanoostenryck@gmail.com \ --cc=paulmck@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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.