On Wed, Oct 1, 2025 at 6:25 AM Jiri Olsa <[email protected]> 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 <[email protected]>
> Signed-off-by: Jiri Olsa <[email protected]>
> ---
>  kernel/events/uprobes.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>

makes sense

Acked-by: Andrii Nakryiko <[email protected]>

> 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
>

Reply via email to