netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpf: no longer acquire map_idr_lock in bpf_map_inc_not_zero()
@ 2025-03-01 19:13 Eric Dumazet
  2025-03-02  0:05 ` Stanislav Fomichev
  2025-03-03  2:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2025-03-01 19:13 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, John Fastabend
  Cc: Stanislav Fomichev, netdev, bpf, eric.dumazet, Eric Dumazet,
	Kui-Feng Lee, Martin KaFai Lau

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 <edumazet@google.com>
Cc: Kui-Feng Lee <kuifeng@meta.com>
Cc: Martin KaFai Lau <martin.lau@kernel.org>
---
 kernel/bpf/syscall.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index e1e42e918ba7f682223e9a78028bb0cc360c01ce..d68c8d61f7ceddb732a5646c00b8f0c71fdc2d71 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -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);
 
-- 
2.48.1.711.g2feabab25a-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf-next] bpf: no longer acquire map_idr_lock in bpf_map_inc_not_zero()
  2025-03-01 19:13 [PATCH bpf-next] bpf: no longer acquire map_idr_lock in bpf_map_inc_not_zero() Eric Dumazet
@ 2025-03-02  0:05 ` Stanislav Fomichev
  2025-03-03  2:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Stanislav Fomichev @ 2025-03-02  0:05 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Alexei Starovoitov, Daniel Borkmann, John Fastabend,
	Stanislav Fomichev, netdev, bpf, eric.dumazet, Kui-Feng Lee,
	Martin KaFai Lau

On 03/01, Eric Dumazet wrote:
> 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 <edumazet@google.com>

Acked-by: Stanislav Fomichev <sdf@fomichev.me>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf-next] bpf: no longer acquire map_idr_lock in bpf_map_inc_not_zero()
  2025-03-01 19:13 [PATCH bpf-next] bpf: no longer acquire map_idr_lock in bpf_map_inc_not_zero() Eric Dumazet
  2025-03-02  0:05 ` Stanislav Fomichev
@ 2025-03-03  2:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-03-03  2:30 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: ast, daniel, john.fastabend, sdf, netdev, bpf, eric.dumazet,
	kuifeng, martin.lau

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Sat,  1 Mar 2025 19:13:15 +0000 you wrote:
> 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 <edumazet@google.com>
> Cc: Kui-Feng Lee <kuifeng@meta.com>
> Cc: Martin KaFai Lau <martin.lau@kernel.org>
> 
> [...]

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-03  2:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-01 19:13 [PATCH bpf-next] bpf: no longer acquire map_idr_lock in bpf_map_inc_not_zero() Eric Dumazet
2025-03-02  0:05 ` Stanislav Fomichev
2025-03-03  2:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).