uprobe: Move arch_uprobe_optimize right after handlers execution
Subsystems (4)
Jiri Olsa
reviewerPATCH 1/1 uprobe: Move arch_uprobe_optimize right after handlers execution
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.
--- kernel/events/uprobes.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/events/uprobes.c +3 -3
@@ -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;
Signature · 1 line
2.51.0
Quoted 11 lines · Jiri Olsa
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
Quoted 27 lines
kernel/events/uprobes.c +3
-4@@ -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
Quoted 6 lines · On Wed, 1 Oct 2025 15:24:49 +0200 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]>
Looks good to me.
Thanks,
Quoted 31 lines
--- kernel/events/uprobes.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)kernel/events/uprobes.c +3
-3@@ -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;Signature · 1 line
2.51.0
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Quoted 14 lines · Jiri Olsa
kernel/events/uprobes.c +3
-0@@ -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.
kernel/events/uprobes.c static void handle_swbp(struct pt_regs *regs) · line 2779
Quoted 8 lines
kernel/events/uprobes.c +0
-3@@ -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;
The following commit has been merged into the perf/urgent branch of tip:
The following commit has been merged into the perf/urgent branch of tip:
Commit-ID: 62685ab071de7c39499212bff19f1b5bc0148bc7 Gitweb: https://git.kernel.org/tip/62685ab071de7c39499212bff19f1b5bc0148bc7 Author: Jiri Olsa <[email protected]> AuthorDate: Wed, 01 Oct 2025 15:24:49 +02:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Tue, 14 Oct 2025 10:38:09 +02:00
uprobe: Move arch_uprobe_optimize right after handlers execution
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.
--- kernel/events/uprobes.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/events/uprobes.c +3 -3
@@ -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;