Skip to content

Commit abdaf49

Browse files
Tao Chenanakryiko
authored andcommitted
bpf: Remove migrate_disable in kprobe_multi_link_prog_run
Graph tracer framework ensures we won't migrate, 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 may will be reduced. And add cant_sleep check for __this_cpu_inc_return. Fixes: 0dcac27 ("bpf: Add multi kprobe link") Signed-off-by: Tao Chen <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent c80d797 commit abdaf49

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
@@ -2728,20 +2728,25 @@ kprobe_multi_link_prog_run(struct bpf_kprobe_multi_link *link,
27282728
struct pt_regs *regs;
27292729
int err;
27302730

2731+
/*
2732+
* graph tracer framework ensures we won't migrate, so there is no need
2733+
* to use migrate_disable for bpf_prog_run again. The check here just for
2734+
* __this_cpu_inc_return.
2735+
*/
2736+
cant_sleep();
2737+
27312738
if (unlikely(__this_cpu_inc_return(bpf_prog_active) != 1)) {
27322739
bpf_prog_inc_misses_counter(link->link.prog);
27332740
err = 1;
27342741
goto out;
27352742
}
27362743

2737-
migrate_disable();
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)