net/sysctl: avoid two synchronize_rcu() calls
Subsystems (2)
PATCH 1/1 net/sysctl: avoid two synchronize_rcu() calls
From: Eric Dumazet <[email protected]>
Both rps_sock_flow_sysctl() and flow_limit_cpu_sysctl() are using synchronize_rcu() right before freeing memory either by vfree() or kfree()
They can switch to kvfree_rcu(ptr) and kfree_rcu(ptr) to benefit from asynchronous mode, instead of blocking the current thread.
Note that kvfree_rcu(ptr) and kfree_rcu(ptr) eventually can have to use synchronize_rcu() in some memory pressure cases.
--- net/core/sysctl_net_core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
net/core/sysctl_net_core.c +2 -4
@@ -103,8 +103,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,if (orig_sock_table) {static_branch_dec (&rps_needed);static_branch_dec (&rfs_needed); -synchronize_rcu (); -vfree (orig_sock_table); +kvfree_rcu (orig_sock_table); } } }
@@ -142,8 +141,7 @@ static int flow_limit_cpu_sysctl(struct ctl_table *table, int write, lockdep_is_held(&flow_limit_update_mutex));if (cur && !cpumask_test_cpu (i, mask)) {RCU_INIT_POINTER (sd->flow_limit,NULL ); -synchronize_rcu (); -kfree (cur); +kfree_rcu (cur); }else if (!cur &&cpumask_test_cpu (i, mask)) { cur =kzalloc_node (len,GFP_KERNEL ,cpu_to_node (i));
Signature · 1 line
2.35.1.574.g5d30c73bfb-goog
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 10 lines · On Fri, 25 Feb 2022 08:18:55 -0800 you wrote:
From: Eric Dumazet <[email protected]>
Both
rps_sock_flow_sysctl()andflow_limit_cpu_sysctl()are usingsynchronize_rcu()right before freeing memory either byvfree()orkfree()They can switch to
kvfree_rcu(ptr)andkfree_rcu(ptr)to benefit from asynchronous mode, instead of blocking the current thread.[...]
Here is the summary with links:
- [net-next] net/sysctl: avoid two synchronize_rcu() calls
https://git.kernel.org/netdev/net-next/c/b3483bc7a1f2
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html