Skip to content

Commit 17a82ed

Browse files
edumazetAlexei Starovoitov
authored andcommitted
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. Signed-off-by: Eric Dumazet <[email protected]> Cc: Kui-Feng Lee <[email protected]> Cc: Martin KaFai Lau <[email protected]> Acked-by: Stanislav Fomichev <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 53415f6 commit 17a82ed

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

kernel/bpf/syscall.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,11 +1610,8 @@ struct bpf_map *__bpf_map_inc_not_zero(struct bpf_map *map, bool uref)
16101610

16111611
struct bpf_map *bpf_map_inc_not_zero(struct bpf_map *map)
16121612
{
1613-
spin_lock_bh(&map_idr_lock);
1614-
map = __bpf_map_inc_not_zero(map, false);
1615-
spin_unlock_bh(&map_idr_lock);
1616-
1617-
return map;
1613+
lockdep_assert(rcu_read_lock_held());
1614+
return __bpf_map_inc_not_zero(map, false);
16181615
}
16191616
EXPORT_SYMBOL_GPL(bpf_map_inc_not_zero);
16201617

0 commit comments

Comments
 (0)