Skip to content

Commit f8ac5a4

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 dd4d3ef commit f8ac5a4

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
@@ -1593,11 +1593,8 @@ struct bpf_map *__bpf_map_inc_not_zero(struct bpf_map *map, bool uref)
15931593

15941594
struct bpf_map *bpf_map_inc_not_zero(struct bpf_map *map)
15951595
{
1596-
spin_lock_bh(&map_idr_lock);
1597-
map = __bpf_map_inc_not_zero(map, false);
1598-
spin_unlock_bh(&map_idr_lock);
1599-
1600-
return map;
1596+
lockdep_assert(rcu_read_lock_held());
1597+
return __bpf_map_inc_not_zero(map, false);
16011598
}
16021599
EXPORT_SYMBOL_GPL(bpf_map_inc_not_zero);
16031600

0 commit comments

Comments
 (0)