net: nexthop: reduce rcu synchronizations when replacing resilient groups
Subsystems (3)
PATCH 1/1 net: nexthop: reduce rcu synchronizations when replacing resilient groups
From: Nikolay Aleksandrov <[email protected]>
We can optimize resilient nexthop group replaces by reducing the number of synchronize_net calls. After commit 1005f19b9357 ("net: nexthop: release IPv6 per-cpu dsts when replacing a nexthop group") we always do a synchronize_net because we must ensure no new dsts can be created for the replaced group's removed nexthops, but we already did that when replacing resilient groups, so if we always call synchronize_net after any group type replacement we'll take care of both cases and reduce synchronize_net calls for resilient groups.
--- net/ipv4/nexthop.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
net/ipv4/nexthop.c +3 -5
@@ -1918,9 +1918,6 @@ static void nh_rt_cache_flush(struct net *net, struct nexthop *nh,if (!replaced_nh->is_group)return ; -/* new dsts must use only the new nexthop group */ -synchronize_net (); - nhg =rtnl_dereference (replaced_nh->nh_grp);for (i =0 ; i < nhg->num_nh; i++) {struct nh_grp_entry *nhge = &nhg->nh_entries[i];
@@ -2002,9 +1999,10 @@ static int replace_nexthop_grp(struct net *net, struct nexthop *old,rcu_assign_pointer (old->nh_grp, newg); +/* Make sure concurrent readers are not using 'oldg' anymore. */ +synchronize_net (); +if (newg->resilient) { -/* Make sure concurrent readers are not using 'oldg' anymore. */ -synchronize_net ();rcu_assign_pointer (oldg->res_table, tmp_table);rcu_assign_pointer (oldg->spare->res_table, tmp_table); }
Signature · 1 line
2.31.1
Quoted 11 lines · Nikolay Aleksandrov
From: Nikolay Aleksandrov <[email protected]>
We can optimize resilient nexthop group replaces by reducing the number of
synchronize_netcalls. After commit1005f19b9357("net: nexthop: release IPv6 per-cpu dsts when replacing a nexthop group") we always do asynchronize_netbecause we must ensure no new dsts can be created for the replaced group's removed nexthops, but we already did that when replacing resilient groups, so if we always callsynchronize_netafter any group type replacement we'll take care of both cases and reducesynchronize_netcalls for resilient groups.
Quoted 2 lines
Suggested-by Ido Schimmel <[email protected]>Signed-off-by Nikolay Aleksandrov <[email protected]>
I ran fib_nexthops.sh that used to trigger the bug fixed by commit 563f23b00253 ("nexthop: Fix division by zero while replacing a resilient group") and it looks good.
Thanks!
Quoted 11 lines · Nikolay Aleksandrov
From: Nikolay Aleksandrov <[email protected]>
We can optimize resilient nexthop group replaces by reducing the number of
synchronize_netcalls. After commit1005f19b9357("net: nexthop: release IPv6 per-cpu dsts when replacing a nexthop group") we always do asynchronize_netbecause we must ensure no new dsts can be created for the replaced group's removed nexthops, but we already did that when replacing resilient groups, so if we always callsynchronize_netafter any group type replacement we'll take care of both cases and reducesynchronize_netcalls for resilient groups.
Quoted 6 lines
Suggested-by Ido Schimmel <[email protected]>Signed-off-by Nikolay Aleksandrov <[email protected]>--- net/ipv4/nexthop.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Quoted 11 lines · On Mon, 29 Nov 2021 14:09:24 +0200 you wrote:
From: Nikolay Aleksandrov <[email protected]>
We can optimize resilient nexthop group replaces by reducing the number of
synchronize_netcalls. After commit1005f19b9357("net: nexthop: release IPv6 per-cpu dsts when replacing a nexthop group") we always do asynchronize_netbecause we must ensure no new dsts can be created for the replaced group's removed nexthops, but we already did that when replacing resilient groups, so if we always callsynchronize_netafter any group type replacement we'll take care of both cases and reducesynchronize_netcalls for resilient groups.
Quoted 1 line
[...]
Here is the summary with links:
- [net-next] net: nexthop: reduce rcu synchronizations when replacing resilient groups
https://git.kernel.org/netdev/net-next/c/7709efa62c4f
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html