lkml.org 
[lkml]   [2022]   [Jun]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRe: kernel/bpf/devmap.c:1030:40: sparse: sparse: cast removes address space '__rcu' of expression
Date
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

\
 
 \ /
  Last update: 2022-06-01 12:28    [W:0.762 / U:0.592 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site