Skip to content

Commit

Permalink
inet: use call_rcu_hurry() in inet_free_ifa()
Browse files Browse the repository at this point in the history
This is a followup of commit c4e86b4 ("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>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Apr 29, 2024
1 parent cd42ba1 commit 61f5338
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion net/ipv4/devinet.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,19 @@ 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);
}

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)
Expand Down

0 comments on commit 61f5338

Please sign in to comment.