[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87h7547k8c.fsf@toke.dk>
Date: Wed, 01 Jun 2022 12:26:27 +0200
From: Toke Høiland-Jørgensen <toke@...hat.com>
To: Luc Van Oostenryck <luc.vanoostenryck@...il.com>
Cc: kernel test robot <lkp@...el.com>, kbuild-all@...ts.01.org,
linux-kernel@...r.kernel.org,
Daniel Borkmann <daniel@...earbox.net>,
"Paul E . McKenney" <paulmck@...nel.org>
Subject: Re: kernel/bpf/devmap.c:1030:40: sparse: sparse: cast removes
address space '__rcu' of expression
Luc Van Oostenryck <luc.vanoostenryck@...il.com> writes:
> On Mon, May 23, 2022 at 12:30:14PM +0200, Toke Høiland-Jørgensen wrote:
>> kernel test robot <lkp@...el.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
Powered by blists - more mailing lists