Re: [PATCH] uprobe: Move arch_uprobe_optimize right after handlers execution
From: Andrii Nakryiko
Date: Wed Oct 01 2025 - 12:39:50 EST
On Wed, Oct 1, 2025 at 6:25 AM Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
>
> 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@xxxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> ---
> kernel/events/uprobes.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
makes sense
Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx>
> diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
> index 5dcf927310fd..c14ec27b976d 100644
> --- a/kernel/events/uprobes.c
> +++ b/kernel/events/uprobes.c
> @@ -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;
>
> --
> 2.51.0
>