bpf: no longer acquire map_idr_lock in bpf_map_inc_not_zero()
Subsystems (4)
PATCH 1/1 bpf: no longer acquire map_idr_lock in bpf_map_inc_not_zero()
bpf_sk_storage_clone() is the only caller of bpf_map_inc_not_zero() and is holding rcu_read_lock().
map_idr_lock does not add any protection, just remove the cost for passive TCP flows.
--- kernel/bpf/syscall.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
kernel/bpf/syscall.c +2 -5
@@ -1593,11 +1593,8 @@ struct bpf_map *__bpf_map_inc_not_zero(struct bpf_map *map, bool uref)struct bpf_map *bpf_map_inc_not_zero (struct bpf_map *map) { -spin_lock_bh (&map_idr_lock); - map =__bpf_map_inc_not_zero (map, false); -spin_unlock_bh (&map_idr_lock); - -return map; +lockdep_assert (rcu_read_lock_held ()); +return __bpf_map_inc_not_zero (map, false); }EXPORT_SYMBOL_GPL (bpf_map_inc_not_zero);
Signature · 1 line
2.48.1.711.g2feabab25a-goog
Quoted 7 lines · Eric Dumazet
bpf_sk_storage_clone()is the only caller ofbpf_map_inc_not_zero()and is holdingrcu_read_lock().
map_idr_lockdoes not add any protection, just remove the cost for passive TCP flows.Signed-off-by Eric Dumazet <[email protected]>
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:
Quoted 11 lines · On Sat, 1 Mar 2025 19:13:15 +0000 you wrote:
bpf_sk_storage_clone()is the only caller ofbpf_map_inc_not_zero()and is holdingrcu_read_lock().
map_idr_lockdoes not add any protection, just remove the cost for passive TCP flows.Signed-off-by Eric Dumazet <[email protected]>Cc Kui-Feng Lee <[email protected]>Cc Martin KaFai Lau <[email protected]>[...]
Here is the summary with links:
- [bpf-next] bpf: no longer acquire map_idr_lock in bpf_map_inc_not_zero()
https://git.kernel.org/bpf/bpf-next/c/17a82ed98f62
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html