[PATCH bpf-next 5/7] bpf: use rcu_migrate_* for bpf_task_storage_free()

From: Menglong Dong
Date: Fri Aug 15 2025 - 02:21:08 EST


Replace the migrate_disable/migrate_enable with
rcu_migrate_disable/rcu_migrate_enable in bpf_task_storage_free to obtain
better performance when PREEMPT_RCU is not enabled.

Signed-off-by: Menglong Dong <dongml2@xxxxxxxxxxxxxxx>
---
kernel/bpf/bpf_task_storage.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/bpf/bpf_task_storage.c b/kernel/bpf/bpf_task_storage.c
index 1109475953c0..cbbf1b72eece 100644
--- a/kernel/bpf/bpf_task_storage.c
+++ b/kernel/bpf/bpf_task_storage.c
@@ -70,7 +70,7 @@ void bpf_task_storage_free(struct task_struct *task)
{
struct bpf_local_storage *local_storage;

- migrate_disable();
+ rcu_migrate_disable();
rcu_read_lock();

local_storage = rcu_dereference(task->bpf_storage);
@@ -82,7 +82,7 @@ void bpf_task_storage_free(struct task_struct *task)
bpf_task_storage_unlock();
out:
rcu_read_unlock();
- migrate_enable();
+ rcu_migrate_enable();
}

static void *bpf_pid_task_storage_lookup_elem(struct bpf_map *map, void *key)
--
2.50.1