bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpf/devmap: convert remaining READ_ONCE() to rcu_dereference()
@ 2021-06-28 23:00 Toke Høiland-Jørgensen
  2021-06-28 23:05 ` Paul E. McKenney
  2021-06-28 23:55 ` Martin KaFai Lau
  0 siblings, 2 replies; 4+ messages in thread
From: Toke Høiland-Jørgensen @ 2021-06-28 23:00 UTC (permalink / raw)
  To: bpf, netdev
  Cc: Martin KaFai Lau, Hangbin Liu, Jesper Dangaard Brouer,
	Magnus Karlsson, Paul E . McKenney, Jakub Kicinski,
	Toke Høiland-Jørgensen, kernel test robot

There were a couple of READ_ONCE()-invocations left-over by the devmap RCU
conversion. Convert these to rcu_dereference() as well to avoid complaints
from sparse.

Fixes: 782347b6bcad ("xdp: Add proper __rcu annotations to redirect map entries")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
---
 kernel/bpf/devmap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index 2f6bd75cd682..7a0c008f751b 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -558,7 +558,7 @@ int dev_map_enqueue_multi(struct xdp_buff *xdp, struct net_device *dev_rx,
 
 	if (map->map_type == BPF_MAP_TYPE_DEVMAP) {
 		for (i = 0; i < map->max_entries; i++) {
-			dst = READ_ONCE(dtab->netdev_map[i]);
+			dst = rcu_dereference(dtab->netdev_map[i]);
 			if (!is_valid_dst(dst, xdp, exclude_ifindex))
 				continue;
 
@@ -654,7 +654,7 @@ int dev_map_redirect_multi(struct net_device *dev, struct sk_buff *skb,
 
 	if (map->map_type == BPF_MAP_TYPE_DEVMAP) {
 		for (i = 0; i < map->max_entries; i++) {
-			dst = READ_ONCE(dtab->netdev_map[i]);
+			dst = rcu_dereference(dtab->netdev_map[i]);
 			if (!dst || dst->dev->ifindex == exclude_ifindex)
 				continue;
 
-- 
2.32.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next] bpf/devmap: convert remaining READ_ONCE() to rcu_dereference()
  2021-06-28 23:00 [PATCH bpf-next] bpf/devmap: convert remaining READ_ONCE() to rcu_dereference() Toke Høiland-Jørgensen
@ 2021-06-28 23:05 ` Paul E. McKenney
  2021-06-28 23:55 ` Martin KaFai Lau
  1 sibling, 0 replies; 4+ messages in thread
From: Paul E. McKenney @ 2021-06-28 23:05 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen
  Cc: bpf, netdev, Martin KaFai Lau, Hangbin Liu,
	Jesper Dangaard Brouer, Magnus Karlsson, Jakub Kicinski,
	kernel test robot

On Tue, Jun 29, 2021 at 01:00:51AM +0200, Toke Høiland-Jørgensen wrote:
> There were a couple of READ_ONCE()-invocations left-over by the devmap RCU
> conversion. Convert these to rcu_dereference() as well to avoid complaints
> from sparse.
> 
> Fixes: 782347b6bcad ("xdp: Add proper __rcu annotations to redirect map entries")
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>

Reviewed-by: Paul E. McKenney <paulmck@kernel.org>

> ---
>  kernel/bpf/devmap.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
> index 2f6bd75cd682..7a0c008f751b 100644
> --- a/kernel/bpf/devmap.c
> +++ b/kernel/bpf/devmap.c
> @@ -558,7 +558,7 @@ int dev_map_enqueue_multi(struct xdp_buff *xdp, struct net_device *dev_rx,
>  
>  	if (map->map_type == BPF_MAP_TYPE_DEVMAP) {
>  		for (i = 0; i < map->max_entries; i++) {
> -			dst = READ_ONCE(dtab->netdev_map[i]);
> +			dst = rcu_dereference(dtab->netdev_map[i]);
>  			if (!is_valid_dst(dst, xdp, exclude_ifindex))
>  				continue;
>  
> @@ -654,7 +654,7 @@ int dev_map_redirect_multi(struct net_device *dev, struct sk_buff *skb,
>  
>  	if (map->map_type == BPF_MAP_TYPE_DEVMAP) {
>  		for (i = 0; i < map->max_entries; i++) {
> -			dst = READ_ONCE(dtab->netdev_map[i]);
> +			dst = rcu_dereference(dtab->netdev_map[i]);
>  			if (!dst || dst->dev->ifindex == exclude_ifindex)
>  				continue;
>  
> -- 
> 2.32.0
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next] bpf/devmap: convert remaining READ_ONCE() to rcu_dereference()
  2021-06-28 23:00 [PATCH bpf-next] bpf/devmap: convert remaining READ_ONCE() to rcu_dereference() Toke Høiland-Jørgensen
  2021-06-28 23:05 ` Paul E. McKenney
@ 2021-06-28 23:55 ` Martin KaFai Lau
  2021-06-29  9:37   ` Toke Høiland-Jørgensen
  1 sibling, 1 reply; 4+ messages in thread
From: Martin KaFai Lau @ 2021-06-28 23:55 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen
  Cc: bpf, netdev, Hangbin Liu, Jesper Dangaard Brouer,
	Magnus Karlsson, Paul E . McKenney, Jakub Kicinski,
	kernel test robot

On Tue, Jun 29, 2021 at 01:00:51AM +0200, Toke Høiland-Jørgensen wrote:
> There were a couple of READ_ONCE()-invocations left-over by the devmap RCU
> conversion. Convert these to rcu_dereference() as well to avoid complaints
> from sparse.
> 
> Fixes: 782347b6bcad ("xdp: Add proper __rcu annotations to redirect map entries")
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
> ---
>  kernel/bpf/devmap.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
> index 2f6bd75cd682..7a0c008f751b 100644
> --- a/kernel/bpf/devmap.c
> +++ b/kernel/bpf/devmap.c
> @@ -558,7 +558,7 @@ int dev_map_enqueue_multi(struct xdp_buff *xdp, struct net_device *dev_rx,
>  
>  	if (map->map_type == BPF_MAP_TYPE_DEVMAP) {
>  		for (i = 0; i < map->max_entries; i++) {
> -			dst = READ_ONCE(dtab->netdev_map[i]);
> +			dst = rcu_dereference(dtab->netdev_map[i]);
__dev_map_lookup_elem() uses rcu_dereference_check(dtab->netdev_map[key], rcu_read_lock_bh_held()).
It is not needed here?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next] bpf/devmap: convert remaining READ_ONCE() to rcu_dereference()
  2021-06-28 23:55 ` Martin KaFai Lau
@ 2021-06-29  9:37   ` Toke Høiland-Jørgensen
  0 siblings, 0 replies; 4+ messages in thread
From: Toke Høiland-Jørgensen @ 2021-06-29  9:37 UTC (permalink / raw)
  To: Martin KaFai Lau
  Cc: bpf, netdev, Hangbin Liu, Jesper Dangaard Brouer,
	Magnus Karlsson, Paul E . McKenney, Jakub Kicinski,
	kernel test robot

Martin KaFai Lau <kafai@fb.com> writes:

> On Tue, Jun 29, 2021 at 01:00:51AM +0200, Toke Høiland-Jørgensen wrote:
>> There were a couple of READ_ONCE()-invocations left-over by the devmap RCU
>> conversion. Convert these to rcu_dereference() as well to avoid complaints
>> from sparse.
>> 
>> Fixes: 782347b6bcad ("xdp: Add proper __rcu annotations to redirect map entries")
>> Reported-by: kernel test robot <lkp@intel.com>
>> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
>> ---
>>  kernel/bpf/devmap.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
>> index 2f6bd75cd682..7a0c008f751b 100644
>> --- a/kernel/bpf/devmap.c
>> +++ b/kernel/bpf/devmap.c
>> @@ -558,7 +558,7 @@ int dev_map_enqueue_multi(struct xdp_buff *xdp, struct net_device *dev_rx,
>>  
>>  	if (map->map_type == BPF_MAP_TYPE_DEVMAP) {
>>  		for (i = 0; i < map->max_entries; i++) {
>> -			dst = READ_ONCE(dtab->netdev_map[i]);
>> +			dst = rcu_dereference(dtab->netdev_map[i]);
> __dev_map_lookup_elem() uses rcu_dereference_check(dtab->netdev_map[key], rcu_read_lock_bh_held()).
> It is not needed here?

Hmm, I somehow managed to convince myself last night that it wasn't, but
looking at it again now I think you're right. Will send a v2.

-Toke


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-29  9:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-28 23:00 [PATCH bpf-next] bpf/devmap: convert remaining READ_ONCE() to rcu_dereference() Toke Høiland-Jørgensen
2021-06-28 23:05 ` Paul E. McKenney
2021-06-28 23:55 ` Martin KaFai Lau
2021-06-29  9:37   ` Toke Høiland-Jørgensen

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).