Skip to content

Commit cf4303b

Browse files
image-dragonAlexei Starovoitov
authored andcommitted
bpf: use rcu_read_lock_dont_migrate() for bpf_task_storage_free()
Use rcu_read_lock_dont_migrate() and rcu_read_unlock_migrate() in bpf_task_storage_free to obtain better performance when PREEMPT_RCU is not enabled. Signed-off-by: Menglong Dong <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 68748f0 commit cf4303b

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

kernel/bpf/bpf_task_storage.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ void bpf_task_storage_free(struct task_struct *task)
7070
{
7171
struct bpf_local_storage *local_storage;
7272

73-
migrate_disable();
74-
rcu_read_lock();
73+
rcu_read_lock_dont_migrate();
7574

7675
local_storage = rcu_dereference(task->bpf_storage);
7776
if (!local_storage)
@@ -81,8 +80,7 @@ void bpf_task_storage_free(struct task_struct *task)
8180
bpf_local_storage_destroy(local_storage);
8281
bpf_task_storage_unlock();
8382
out:
84-
rcu_read_unlock();
85-
migrate_enable();
83+
rcu_read_unlock_migrate();
8684
}
8785

8886
static void *bpf_pid_task_storage_lookup_elem(struct bpf_map *map, void *key)

0 commit comments

Comments
 (0)