[PW_SID:1155929] riscv: kprobes: simulate nop and c.nop instructions - #2576
[PW_SID:1155929] riscv: kprobes: simulate nop and c.nop instructions#2576linux-riscv-bot wants to merge 3 commits into
Conversation
A kprobe or uprobe placed on a nop currently replays the instruction out-of-line: the breakpoint trap runs the probe handler and redirects execution to a copy of the instruction sitting in an XOL slot, and a second breakpoint appended after the copy traps again to finish the hit. That costs an extra exception round-trip per hit; for uprobes the slot runs in user mode, so the re-trap is a full kernel<->userspace round-trip. nop and c.nop have no architectural effect, so the replay can be replaced by simply advancing the program counter when handling the initial breakpoint, completing every hit within a single trap. arm64 does the same in its probe-decode path, which is also shared between kprobes and uprobes; see commit ac4ad5c ("arm64: insn: Simulate nop instruction for better uprobe performance"). riscv_probe_decode_insn() is shared by kprobes and uprobes, so the simulation applies to both. It primarily matters for uprobes on USDT probe sites: under the SystemTap SDT ABI (sys/sdt.h, parsed by libbpf), the recorded probe location is by construction a plain nop or c.nop, the same case that motivated the arm64 series. Measured on QEMU (RISC-V virt, emulated): for a uprobe on a USDT style nop site the per-hit cost drops by roughly 80 percent; for a kprobe on a nop by roughly 40 percent. On real arm64 hardware the referenced commit measured ~2x. Compile tested on RISC-V, and verified with the RISC-V kprobes KUnit test which now covers nop and c.nop. Signed-off-by: Xiaofeng Yuan <yuanxiaofeng@eswincomputing.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Extend the RISC-V kprobes KUnit test with test_kprobes_nop and test_kprobes_c_nop, covering both the 32-bit nop and the compressed c.nop simulation paths. Signed-off-by: Xiaofeng Yuan <yuanxiaofeng@eswincomputing.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "[v3,1/2] riscv: kprobes: simulate nop and c.nop instructions" |
|
Patch 1: "[v3,1/2] riscv: kprobes: simulate nop and c.nop instructions" |
|
Patch 1: "[v3,1/2] riscv: kprobes: simulate nop and c.nop instructions" |
|
Patch 1: "[v3,1/2] riscv: kprobes: simulate nop and c.nop instructions" |
|
Patch 1: "[v3,1/2] riscv: kprobes: simulate nop and c.nop instructions" |
|
Patch 1: "[v3,1/2] riscv: kprobes: simulate nop and c.nop instructions" |
|
Patch 1: "[v3,1/2] riscv: kprobes: simulate nop and c.nop instructions" |
|
Patch 1: "[v3,1/2] riscv: kprobes: simulate nop and c.nop instructions" |
|
Patch 1: "[v3,1/2] riscv: kprobes: simulate nop and c.nop instructions" |
|
Patch 1: "[v3,1/2] riscv: kprobes: simulate nop and c.nop instructions" |
|
Patch 1: "[v3,1/2] riscv: kprobes: simulate nop and c.nop instructions" |
|
Patch 1: "[v3,1/2] riscv: kprobes: simulate nop and c.nop instructions" |
|
Patch 2: "[v3,2/2] riscv: kprobes: add nop and c.nop to the KUnit test" |
|
Patch 2: "[v3,2/2] riscv: kprobes: add nop and c.nop to the KUnit test" |
|
Patch 2: "[v3,2/2] riscv: kprobes: add nop and c.nop to the KUnit test" |
|
Patch 2: "[v3,2/2] riscv: kprobes: add nop and c.nop to the KUnit test" |
|
Patch 2: "[v3,2/2] riscv: kprobes: add nop and c.nop to the KUnit test" |
|
Patch 2: "[v3,2/2] riscv: kprobes: add nop and c.nop to the KUnit test" |
|
Patch 2: "[v3,2/2] riscv: kprobes: add nop and c.nop to the KUnit test" |
|
Patch 2: "[v3,2/2] riscv: kprobes: add nop and c.nop to the KUnit test" |
|
Patch 2: "[v3,2/2] riscv: kprobes: add nop and c.nop to the KUnit test" |
|
Patch 2: "[v3,2/2] riscv: kprobes: add nop and c.nop to the KUnit test" |
|
Patch 2: "[v3,2/2] riscv: kprobes: add nop and c.nop to the KUnit test" |
|
Patch 2: "[v3,2/2] riscv: kprobes: add nop and c.nop to the KUnit test" |
9ed823f to
a54e736
Compare
PR for series 1155929 applied to workflow__riscv__fixes
Name: riscv: kprobes: simulate nop and c.nop instructions
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1155929
Version: 3