]> www.infradead.org Git - users/hch/misc.git/commitdiff
uprobe: Move arch_uprobe_optimize right after handlers execution
authorJiri Olsa <jolsa@kernel.org>
Wed, 1 Oct 2025 13:24:49 +0000 (15:24 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Tue, 14 Oct 2025 08:38:09 +0000 (10:38 +0200)
It's less confusing to optimize uprobe right after handlers execution
and before we do the check for changed ip register to avoid situations
where changed ip register would skip uprobe optimization.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Oleg Nesterov <oleg@redhat.com>
kernel/events/uprobes.c

index 8709c69118b59963c454ff05c63e4c5224f0cdca..f11ceb8be8c419b2894afea064363a0597021442 100644 (file)
@@ -2765,6 +2765,9 @@ static void handle_swbp(struct pt_regs *regs)
 
        handler_chain(uprobe, regs);
 
+       /* Try to optimize after first hit. */
+       arch_uprobe_optimize(&uprobe->arch, bp_vaddr);
+
        /*
         * If user decided to take execution elsewhere, it makes little sense
         * to execute the original instruction, so let's skip it.
@@ -2772,9 +2775,6 @@ static void handle_swbp(struct pt_regs *regs)
        if (instruction_pointer(regs) != bp_vaddr)
                goto out;
 
-       /* Try to optimize after first hit. */
-       arch_uprobe_optimize(&uprobe->arch, bp_vaddr);
-
        if (arch_uprobe_skip_sstep(&uprobe->arch, regs))
                goto out;