All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: ipv6: use the new fib6_nh_release_dsts helper in fib6_nh_release
@ 2021-11-29 12:09 Nikolay Aleksandrov
  2021-11-29 15:33 ` Nikolay Aleksandrov
  0 siblings, 1 reply; 5+ messages in thread
From: Nikolay Aleksandrov @ 2021-11-29 12:09 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, dsahern, Nikolay Aleksandrov

From: Nikolay Aleksandrov <nikolay@nvidia.com>

We can remove a bit of code duplication by reusing the new
fib6_nh_release_dsts helper in fib6_nh_release. Their only difference is
that fib6_nh_release's version doesn't use atomic operation to swap the
pointers because it assumes the fib6_nh is no longer visible, while
fib6_nh_release_dsts can be used anywhere.

Suggested-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Nikolay Aleksandrov <nikolay@nvidia.com>
---
 net/ipv6/route.c | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 62f1e16eea2b..b44438b9a030 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -3656,24 +3656,9 @@ void fib6_nh_release(struct fib6_nh *fib6_nh)
 
 	rcu_read_unlock();
 
-	if (fib6_nh->rt6i_pcpu) {
-		int cpu;
-
-		for_each_possible_cpu(cpu) {
-			struct rt6_info **ppcpu_rt;
-			struct rt6_info *pcpu_rt;
-
-			ppcpu_rt = per_cpu_ptr(fib6_nh->rt6i_pcpu, cpu);
-			pcpu_rt = *ppcpu_rt;
-			if (pcpu_rt) {
-				dst_dev_put(&pcpu_rt->dst);
-				dst_release(&pcpu_rt->dst);
-				*ppcpu_rt = NULL;
-			}
-		}
-
+	fib6_nh_release_dsts(fib6_nh);
+	if (fib6_nh->rt6i_pcpu)
 		free_percpu(fib6_nh->rt6i_pcpu);
-	}
 
 	fib_nh_common_release(&fib6_nh->nh_common);
 }
-- 
2.31.1


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

* Re: [PATCH net-next] net: ipv6: use the new fib6_nh_release_dsts helper in fib6_nh_release
  2021-11-29 12:09 [PATCH net-next] net: ipv6: use the new fib6_nh_release_dsts helper in fib6_nh_release Nikolay Aleksandrov
@ 2021-11-29 15:33 ` Nikolay Aleksandrov
  2021-11-29 15:44   ` [PATCH net-next v2] " Nikolay Aleksandrov
  0 siblings, 1 reply; 5+ messages in thread
From: Nikolay Aleksandrov @ 2021-11-29 15:33 UTC (permalink / raw)
  To: Nikolay Aleksandrov, netdev; +Cc: davem, kuba, dsahern

On 29/11/2021 14:09, Nikolay Aleksandrov wrote:
> From: Nikolay Aleksandrov <nikolay@nvidia.com>
> 
> We can remove a bit of code duplication by reusing the new
> fib6_nh_release_dsts helper in fib6_nh_release. Their only difference is
> that fib6_nh_release's version doesn't use atomic operation to swap the
> pointers because it assumes the fib6_nh is no longer visible, while
> fib6_nh_release_dsts can be used anywhere.
> 
> Suggested-by: David Ahern <dsahern@gmail.com>
> Signed-off-by: Nikolay Aleksandrov <nikolay@nvidia.com>
> ---
>  net/ipv6/route.c | 19 ++-----------------
>  1 file changed, 2 insertions(+), 17 deletions(-)
> 
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 62f1e16eea2b..b44438b9a030 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -3656,24 +3656,9 @@ void fib6_nh_release(struct fib6_nh *fib6_nh)
>  
>  	rcu_read_unlock();
>  
> -	if (fib6_nh->rt6i_pcpu) {
> -		int cpu;
> -
> -		for_each_possible_cpu(cpu) {
> -			struct rt6_info **ppcpu_rt;
> -			struct rt6_info *pcpu_rt;
> -
> -			ppcpu_rt = per_cpu_ptr(fib6_nh->rt6i_pcpu, cpu);
> -			pcpu_rt = *ppcpu_rt;
> -			if (pcpu_rt) {
> -				dst_dev_put(&pcpu_rt->dst);
> -				dst_release(&pcpu_rt->dst);
> -				*ppcpu_rt = NULL;
> -			}
> -		}
> -
> +	fib6_nh_release_dsts(fib6_nh);
> +	if (fib6_nh->rt6i_pcpu)

Actually I can even drop the conditional here, free_percpu() is a noop
if called with NULL. Will respin in a few..

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

* [PATCH net-next v2] net: ipv6: use the new fib6_nh_release_dsts helper in fib6_nh_release
  2021-11-29 15:33 ` Nikolay Aleksandrov
@ 2021-11-29 15:44   ` Nikolay Aleksandrov
  2021-11-30  1:35     ` David Ahern
  2021-11-30 12:10     ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 5+ messages in thread
From: Nikolay Aleksandrov @ 2021-11-29 15:44 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, dsahern, Nikolay Aleksandrov

From: Nikolay Aleksandrov <nikolay@nvidia.com>

We can remove a bit of code duplication by reusing the new
fib6_nh_release_dsts helper in fib6_nh_release. Their only difference is
that fib6_nh_release's version doesn't use atomic operation to swap the
pointers because it assumes the fib6_nh is no longer visible, while
fib6_nh_release_dsts can be used anywhere.

Suggested-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Nikolay Aleksandrov <nikolay@nvidia.com>
---
v2: no need to check for NULL rt6i_pcpu before calling free_percpu

 net/ipv6/route.c | 20 ++------------------
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 62f1e16eea2b..f0d29fcb2094 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -3656,24 +3656,8 @@ void fib6_nh_release(struct fib6_nh *fib6_nh)
 
 	rcu_read_unlock();
 
-	if (fib6_nh->rt6i_pcpu) {
-		int cpu;
-
-		for_each_possible_cpu(cpu) {
-			struct rt6_info **ppcpu_rt;
-			struct rt6_info *pcpu_rt;
-
-			ppcpu_rt = per_cpu_ptr(fib6_nh->rt6i_pcpu, cpu);
-			pcpu_rt = *ppcpu_rt;
-			if (pcpu_rt) {
-				dst_dev_put(&pcpu_rt->dst);
-				dst_release(&pcpu_rt->dst);
-				*ppcpu_rt = NULL;
-			}
-		}
-
-		free_percpu(fib6_nh->rt6i_pcpu);
-	}
+	fib6_nh_release_dsts(fib6_nh);
+	free_percpu(fib6_nh->rt6i_pcpu);
 
 	fib_nh_common_release(&fib6_nh->nh_common);
 }
-- 
2.31.1


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

* Re: [PATCH net-next v2] net: ipv6: use the new fib6_nh_release_dsts helper in fib6_nh_release
  2021-11-29 15:44   ` [PATCH net-next v2] " Nikolay Aleksandrov
@ 2021-11-30  1:35     ` David Ahern
  2021-11-30 12:10     ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 5+ messages in thread
From: David Ahern @ 2021-11-30  1:35 UTC (permalink / raw)
  To: Nikolay Aleksandrov, netdev; +Cc: davem, kuba, Nikolay Aleksandrov

On 11/29/21 8:44 AM, Nikolay Aleksandrov wrote:
> From: Nikolay Aleksandrov <nikolay@nvidia.com>
> 
> We can remove a bit of code duplication by reusing the new
> fib6_nh_release_dsts helper in fib6_nh_release. Their only difference is
> that fib6_nh_release's version doesn't use atomic operation to swap the
> pointers because it assumes the fib6_nh is no longer visible, while
> fib6_nh_release_dsts can be used anywhere.
> 
> Suggested-by: David Ahern <dsahern@gmail.com>
> Signed-off-by: Nikolay Aleksandrov <nikolay@nvidia.com>
> ---
> v2: no need to check for NULL rt6i_pcpu before calling free_percpu
> 
>  net/ipv6/route.c | 20 ++------------------
>  1 file changed, 2 insertions(+), 18 deletions(-)
> 



Reviewed-by: David Ahern <dsahern@kernel.org>

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

* Re: [PATCH net-next v2] net: ipv6: use the new fib6_nh_release_dsts helper in fib6_nh_release
  2021-11-29 15:44   ` [PATCH net-next v2] " Nikolay Aleksandrov
  2021-11-30  1:35     ` David Ahern
@ 2021-11-30 12:10     ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-11-30 12:10 UTC (permalink / raw)
  To: Nikolay Aleksandrov; +Cc: netdev, davem, kuba, dsahern, nikolay

Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Mon, 29 Nov 2021 17:44:11 +0200 you wrote:
> From: Nikolay Aleksandrov <nikolay@nvidia.com>
> 
> We can remove a bit of code duplication by reusing the new
> fib6_nh_release_dsts helper in fib6_nh_release. Their only difference is
> that fib6_nh_release's version doesn't use atomic operation to swap the
> pointers because it assumes the fib6_nh is no longer visible, while
> fib6_nh_release_dsts can be used anywhere.
> 
> [...]

Here is the summary with links:
  - [net-next,v2] net: ipv6: use the new fib6_nh_release_dsts helper in fib6_nh_release
    https://git.kernel.org/netdev/net-next/c/613080506665

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2021-11-30 12:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-29 12:09 [PATCH net-next] net: ipv6: use the new fib6_nh_release_dsts helper in fib6_nh_release Nikolay Aleksandrov
2021-11-29 15:33 ` Nikolay Aleksandrov
2021-11-29 15:44   ` [PATCH net-next v2] " Nikolay Aleksandrov
2021-11-30  1:35     ` David Ahern
2021-11-30 12:10     ` patchwork-bot+netdevbpf

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.