Skip to content

Commit f29c4bd

Browse files
Tao ChenKernel Patches Daemon
authored andcommitted
bpf: Remove migrate_disable in kprobe_multi_link_prog_run
bpf program should run under migration disabled, kprobe_multi_link_prog_run called all the way from graph tracer, which disables preemption in function_graph_enter_regs, as Jiri and Yonghong suggested, there is no need to use migrate_disable. As a result, some overhead maybe will be reduced. Fixes: 0dcac27 ("bpf: Add multi kprobe link") Acked-by: Yonghong Song <[email protected]> Acked-by: Jiri Olsa <[email protected]> Signed-off-by: Tao Chen <[email protected]>
1 parent 9db1c0b commit f29c4bd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

kernel/trace/bpf_trace.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2734,14 +2734,19 @@ kprobe_multi_link_prog_run(struct bpf_kprobe_multi_link *link,
27342734
goto out;
27352735
}
27362736

2737-
migrate_disable();
2737+
/*
2738+
* bpf program should run under migration disabled, kprobe_multi_link_prog_run
2739+
* called all the way from graph tracer, which disables preemption in
2740+
* function_graph_enter_regs, so there is no need to use migrate_disable.
2741+
* Accessing the above percpu data bpf_prog_active is also safe for the same
2742+
* reason.
2743+
*/
27382744
rcu_read_lock();
27392745
regs = ftrace_partial_regs(fregs, bpf_kprobe_multi_pt_regs_ptr());
27402746
old_run_ctx = bpf_set_run_ctx(&run_ctx.session_ctx.run_ctx);
27412747
err = bpf_prog_run(link->link.prog, regs);
27422748
bpf_reset_run_ctx(old_run_ctx);
27432749
rcu_read_unlock();
2744-
migrate_enable();
27452750

27462751
out:
27472752
__this_cpu_dec(bpf_prog_active);

0 commit comments

Comments
 (0)