Skip to content

libbpf: Make optimized uprobes backward compatible#11020

Closed
kernel-patches-daemon-bpf[bot] wants to merge 5 commits intobpf-next_basefrom
series/1053028=>bpf-next
Closed

libbpf: Make optimized uprobes backward compatible#11020
kernel-patches-daemon-bpf[bot] wants to merge 5 commits intobpf-next_basefrom
series/1053028=>bpf-next

Conversation

@kernel-patches-daemon-bpf
Copy link

Pull request for series with
subject: libbpf: Make optimized uprobes backward compatible
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1053028

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: dc855b7
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1053028
version: 1

@kernel-patches-review-bot
Copy link

commit 09ff7cdd01d6d9f807baf814ff8fe1f9ece148de
Author: Jiri Olsa <jolsa@kernel.org>

selftests/bpf: Add test for checking correct nop of optimized usdt

This commit adds a selftest that verifies USDT probe optimization behavior
for the nop,nop5 instruction combo on x86_64. It tests two scenarios: a
single nop probe (usdt_1) that stays on the nop instruction, and a nop,nop5
combo probe (usdt_2) that gets optimized onto nop5.

> diff --git a/tools/testing/selftests/bpf/prog_tests/usdt.c b/tools/testing/selftests/bpf/prog_tests/usdt.c
> --- a/tools/testing/selftests/bpf/prog_tests/usdt.c
> +++ b/tools/testing/selftests/bpf/prog_tests/usdt.c

[ ... ]

> +static void subtest_optimized_attach(void)
> +{
> +	struct test_usdt *skel;
> +	__u8 *addr_1, *addr_2;
> +
> +	/* usdt_1 USDT probe has single nop instruction */
> +	addr_1 = find_instr(usdt_1, nop1_nop5_combo, 6);
> +	if (!ASSERT_NULL(addr_1, "usdt_1_find_nop1_nop5_combo"))
> +		return;
> +
> +	addr_1 = find_instr(usdt_1, nop1, 1);
> +	if (!ASSERT_OK_PTR(addr_1, "usdt_1_find_nop1"))
> +		return;
> +
> +	/* usdt_1 USDT probe has nop,nop5 instructions combo */
> +	addr_2 = find_instr(usdt_2, nop1_nop5_combo, 6);

This comment says "usdt_1" but the code operates on "usdt_2". Should this
say "usdt_2 USDT probe has nop,nop5 instructions combo" to match the code?



AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

In-Reply-To-Subject: selftests/bpf: Add test for checking correct nop of optimized usdt
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/21898612624

AI-authorship-score: low
AI-authorship-explanation: The code follows standard kernel selftest patterns with natural commit message style, and the copy-paste comment error is a characteristically human mistake.
issues-found: 1
issue-severity-score: low
issue-severity-explanation: Comment/code mismatch in test file where comment says usdt_1 but code operates on usdt_2; does not affect test functionality.

@kernel-patches-daemon-bpf
Copy link
Author

Syncing latest usdt.h change [1].

Now that we have nop5 optimization support in kernel, let's emit
nop,nop5 for usdt probe. We leave it up to the library to use
desirable nop instruction.

[1] libbpf/usdt@c9865d1
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Adding uprobe syscall feature detection that will be used
in following changes.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Adding support to detect nop,nop5 instructions combo for usdt probe
by checking on probe's following nop5 instruction.

When the nop,nop5 combo is detected together with uprobe syscall,
we can place the probe on top of nop5 and get it optimized.

[1] https://github.com/libbpf/usdt
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Adding test that attaches bpf program on usdt probe in 2 scenarios;

- attach program on top of usdt_1, which is single nop instruction,
  so the probe stays on nop instruction and is not optimized.

- attach program on top of usdt_2 which is probe defined on top
  of nop,nop5 combo, so the probe is placed on top of nop5 and
  is optimized.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Adding usdt trigger bench for usdt:
 trig-usdt_nop - usdt on top of nop1 instruction
 trig-usdt_nop_combo - usdt on top of nop1/nop5 combo

Adding it to benchs/run_bench_uprobes.sh script.

Example run on x86_64 kernel with uprobe syscall:

  # ./benchs/run_bench_uprobes.sh
  usermode-count :  152.507 ± 0.098M/s
  syscall-count  :   14.309 ± 0.093M/s
  uprobe-nop     :    3.190 ± 0.012M/s
  uprobe-push    :    3.057 ± 0.004M/s
  uprobe-ret     :    1.095 ± 0.009M/s
  uprobe-nop5    :    7.305 ± 0.034M/s
  uretprobe-nop  :    2.175 ± 0.005M/s
  uretprobe-push :    2.109 ± 0.003M/s
  uretprobe-ret  :    0.945 ± 0.002M/s
  uretprobe-nop5 :    3.530 ± 0.006M/s
  usdt_nop       :    3.235 ± 0.008M/s   <-- added
  usdt_nop_combo :    7.511 ± 0.045M/s   <-- added

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 4475cda
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1053028
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=1053028 expired. Closing PR.

@kernel-patches-daemon-bpf kernel-patches-daemon-bpf bot deleted the series/1053028=>bpf-next branch February 13, 2026 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant