diff mbox series

[net-next] inet: use call_rcu_hurry() in inet_free_ifa()

Message ID 20240426070202.1267739-1-edumazet@google.com (mailing list archive)
State Accepted
Commit 61f5338d62673379ff2ce5a8c05682658a196980
Delegated to: Netdev Maintainers
Headers show
Series [net-next] inet: use call_rcu_hurry() in inet_free_ifa() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 928 this patch: 928
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 938 this patch: 938
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 939 this patch: 939
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 19 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 1 this patch: 1
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-04-26--09-00 (tests: 993)

Commit Message

Eric Dumazet April 26, 2024, 7:02 a.m. UTC
This is a followup of commit c4e86b4363ac ("net: add two more
call_rcu_hurry()")

Our reference to ifa->ifa_dev must be freed ASAP
to release the reference to the netdev the same way.

inet_rcu_free_ifa()

	in_dev_put()
	 -> in_dev_finish_destroy()
	   -> netdev_put()

This should speedup device/netns dismantles when CONFIG_RCU_LAZY=y

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/devinet.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

David Ahern April 26, 2024, 2:35 p.m. UTC | #1
On 4/26/24 1:02 AM, Eric Dumazet wrote:
> This is a followup of commit c4e86b4363ac ("net: add two more
> call_rcu_hurry()")
> 
> Our reference to ifa->ifa_dev must be freed ASAP
> to release the reference to the netdev the same way.
> 
> inet_rcu_free_ifa()
> 
> 	in_dev_put()
> 	 -> in_dev_finish_destroy()
> 	   -> netdev_put()
> 
> This should speedup device/netns dismantles when CONFIG_RCU_LAZY=y
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---
>  net/ipv4/devinet.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 

Reviewed-by: David Ahern <dsahern@kernel.org>
patchwork-bot+netdevbpf@kernel.org April 29, 2024, 9 a.m. UTC | #2
Hello:

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

On Fri, 26 Apr 2024 07:02:02 +0000 you wrote:
> This is a followup of commit c4e86b4363ac ("net: add two more
> call_rcu_hurry()")
> 
> Our reference to ifa->ifa_dev must be freed ASAP
> to release the reference to the netdev the same way.
> 
> inet_rcu_free_ifa()
> 
> [...]

Here is the summary with links:
  - [net-next] inet: use call_rcu_hurry() in inet_free_ifa()
    https://git.kernel.org/netdev/net-next/c/61f5338d6267

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 7592f242336b7fdf67e79dbd75407cf03e841cfc..364dbf0cd9bf2f6e96a221317c88dad965209659 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -224,6 +224,7 @@  static struct in_ifaddr *inet_alloc_ifa(void)
 static void inet_rcu_free_ifa(struct rcu_head *head)
 {
 	struct in_ifaddr *ifa = container_of(head, struct in_ifaddr, rcu_head);
+
 	if (ifa->ifa_dev)
 		in_dev_put(ifa->ifa_dev);
 	kfree(ifa);
@@ -231,7 +232,11 @@  static void inet_rcu_free_ifa(struct rcu_head *head)
 
 static void inet_free_ifa(struct in_ifaddr *ifa)
 {
-	call_rcu(&ifa->rcu_head, inet_rcu_free_ifa);
+	/* Our reference to ifa->ifa_dev must be freed ASAP
+	 * to release the reference to the netdev the same way.
+	 * in_dev_put() -> in_dev_finish_destroy() -> netdev_put()
+	 */
+	call_rcu_hurry(&ifa->rcu_head, inet_rcu_free_ifa);
 }
 
 static void in_dev_free_rcu(struct rcu_head *head)