Skip to contentSkip to conversation

inet: use call_rcu_hurry() in inet_free_ifa()

PATCH Applied Eric Dumazet 3 participants 3 messages Apr 26, 2024 – Apr 29, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 inet: use call_rcu_hurry() in inet_free_ifa()

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

---
 net/ipv4/devinet.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
net/ipv4/devinet.c +6 -1
index 7592f242336b7fdf67e79dbd75407cf03e841cfc..364dbf0cd9bf2f6e96a221317c88dad965209659 100644
@@ -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)
Signature · 1 line
2.44.0.769.g3c40516874-goog
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Eric Dumazet

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()
Quoted 7 lines

This should speedup device/netns dismantles when CONFIG_RCU_LAZY=y

---
 net/ipv4/devinet.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
#2 lore raw
In reply to Eric Dumazet
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Quoted 9 lines · 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!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html