Skip to content

Commit 68748f0

Browse files
image-dragonAlexei Starovoitov
authored andcommitted
bpf: use rcu_read_lock_dont_migrate() for bpf_iter_run_prog()
Use rcu_read_lock_dont_migrate() and rcu_read_unlock_migrate() in bpf_iter_run_prog 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 f2fa9b9 commit 68748f0

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

kernel/bpf/bpf_iter.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -705,13 +705,11 @@ int bpf_iter_run_prog(struct bpf_prog *prog, void *ctx)
705705
migrate_enable();
706706
rcu_read_unlock_trace();
707707
} else {
708-
rcu_read_lock();
709-
migrate_disable();
708+
rcu_read_lock_dont_migrate();
710709
old_run_ctx = bpf_set_run_ctx(&run_ctx);
711710
ret = bpf_prog_run(prog, ctx);
712711
bpf_reset_run_ctx(old_run_ctx);
713-
migrate_enable();
714-
rcu_read_unlock();
712+
rcu_read_unlock_migrate();
715713
}
716714

717715
/* bpf program can only return 0 or 1:

0 commit comments

Comments
 (0)