* [PATCH v2] bpf: Use rcu_read_lock_dont_migrate in bpf_sk_storage.c
@ 2025-10-07 7:40 Fushuai Wang
2025-10-07 20:50 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Fushuai Wang @ 2025-10-07 7:40 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, horms, ast, martin.lau, houtao1,
jkangas
Cc: netdev, linux-kernel, bpf, menglong.dong, Fushuai Wang
Use rcu_read_lock_dont_migrate() and rcu_read_unlock_migrate() in
bpf_sk_storage.c to obtain better performance when PREEMPT_RCU is
not enabled.
Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
---
v1 -> v2: no code changes. Simplify and clarify commit message
---
net/core/bpf_sk_storage.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/net/core/bpf_sk_storage.c b/net/core/bpf_sk_storage.c
index 2e538399757f..bdb70cf89ae1 100644
--- a/net/core/bpf_sk_storage.c
+++ b/net/core/bpf_sk_storage.c
@@ -50,16 +50,14 @@ void bpf_sk_storage_free(struct sock *sk)
{
struct bpf_local_storage *sk_storage;
- migrate_disable();
- rcu_read_lock();
+ rcu_read_lock_dont_migrate();
sk_storage = rcu_dereference(sk->sk_bpf_storage);
if (!sk_storage)
goto out;
bpf_local_storage_destroy(sk_storage);
out:
- rcu_read_unlock();
- migrate_enable();
+ rcu_read_unlock_migrate();
}
static void bpf_sk_storage_map_free(struct bpf_map *map)
@@ -161,8 +159,7 @@ int bpf_sk_storage_clone(const struct sock *sk, struct sock *newsk)
RCU_INIT_POINTER(newsk->sk_bpf_storage, NULL);
- migrate_disable();
- rcu_read_lock();
+ rcu_read_lock_dont_migrate();
sk_storage = rcu_dereference(sk->sk_bpf_storage);
if (!sk_storage || hlist_empty(&sk_storage->list))
@@ -213,9 +210,8 @@ int bpf_sk_storage_clone(const struct sock *sk, struct sock *newsk)
}
out:
- rcu_read_unlock();
- migrate_enable();
+ rcu_read_unlock_migrate();
/* In case of an error, don't free anything explicitly here, the
* caller is responsible to call bpf_sk_storage_free.
*/
--
2.36.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] bpf: Use rcu_read_lock_dont_migrate in bpf_sk_storage.c
2025-10-07 7:40 [PATCH v2] bpf: Use rcu_read_lock_dont_migrate in bpf_sk_storage.c Fushuai Wang
@ 2025-10-07 20:50 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-10-07 20:50 UTC (permalink / raw)
To: Fushuai Wang
Cc: davem, edumazet, kuba, pabeni, horms, ast, martin.lau, houtao1,
jkangas, netdev, linux-kernel, bpf, menglong.dong
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Martin KaFai Lau <martin.lau@kernel.org>:
On Tue, 7 Oct 2025 15:40:11 +0800 you wrote:
> Use rcu_read_lock_dont_migrate() and rcu_read_unlock_migrate() in
> bpf_sk_storage.c to obtain better performance when PREEMPT_RCU is
> not enabled.
>
> Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
> ---
> v1 -> v2: no code changes. Simplify and clarify commit message
>
> [...]
Here is the summary with links:
- [v2] bpf: Use rcu_read_lock_dont_migrate in bpf_sk_storage.c
https://git.kernel.org/bpf/bpf-next/c/0db4941d9dae
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] 2+ messages in thread
end of thread, other threads:[~2025-10-07 20:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-07 7:40 [PATCH v2] bpf: Use rcu_read_lock_dont_migrate in bpf_sk_storage.c Fushuai Wang
2025-10-07 20:50 ` 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