Skip to content

libbpf: Make optimized uprobes backward compatible#11009

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

libbpf: Make optimized uprobes backward compatible#11009
kernel-patches-daemon-bpf[bot] wants to merge 5 commits intobpf-next_basefrom
series/1052727=>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=1052727

@kernel-patches-daemon-bpf
Copy link
Author

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

@kernel-patches-review-bot
Copy link

commit 70e5527050f3499bd935d6d5bd5dedebf29326cb
Author: Jiri Olsa <jolsa@kernel.org>

selftests/bpf: Emit nop,no5 instructions combo for x86_64 arch

This commit syncs the selftests usdt.h with the upstream libbpf/usdt
project to emit a nop,nop5 instruction combo for x86_64 USDT probes,
allowing libbpf to use the desirable nop instruction for optimization.

> selftests/bpf: Emit nop,no5 instructions combo for x86_64 arch

This isn't a bug, but there's a typo in the subject line. "no5" should
be "nop5".

> Now that we have no5 optimization support in kernel, let's emit

The same typo appears here in the commit body.



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: Emit nop,no5 instructions combo for x86_64 arch
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/21867569087

AI-authorship-score: low
AI-authorship-explanation: The commit shows typical human development patterns including a typo in the commit message, iterative design changes between v1 and v2 based on real-world testing, and normal kernel mailing list review interactions.
issues-found: 1
issue-severity-score: low
issue-severity-explanation: Single typo in commit message subject and body where 'no5' should be 'nop5'; does not affect code functionality.

@kernel-patches-review-bot
Copy link

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

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

This commit adds a test that attaches a BPF program to USDT probes in two
scenarios: one using a single nop instruction (usdt_1), and one using the
nop,nop5 combo (usdt_2) to verify probe optimization behavior.

> 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

[ ... ]

> +#ifdef __x86_64
          ^^^^^^^^
Should this be __x86_64__ (with trailing underscores) to match the standard
GCC predefined macro? The call site in test_usdt() uses __x86_64__:

> @@ -516,6 +599,8 @@ void test_usdt(void)
> #ifdef __x86_64__
> 	if (test__start_subtest("basic_optimized"))
> 		subtest_basic_usdt(true);
> +	if (test__start_subtest("optimized_attach"))
> +		subtest_optimized_attach();
> #endif

Without the trailing underscores, the function definition will not be
compiled on x86_64 while the call will be, leading to a linker error.



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

AI-authorship-score: low
AI-authorship-explanation: The commit follows standard kernel selftest patterns with a natural coding style and contains a typo characteristic of human error rather than AI generation.
issues-found: 1
issue-severity-score: medium
issue-severity-explanation: The mismatched preprocessor macro will cause a linker error on x86_64 builds, preventing the test from compiling.

@kernel-patches-review-bot
Copy link

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

selftests/bpf: Add usdt trigger bench

This commit adds USDT trigger benchmarks for measuring USDT probe performance
with single nop and nop/nop5 combo instruction patterns.

> diff --git a/tools/testing/selftests/bpf/progs/trigger_bench.c b/tools/testing/selftests/bpf/progs/trigger_bench.c
> index 4ea0422d1042..f631706bbdc9 100644

[ ... ]

> @@ -180,3 +181,10 @@ int bench_trigger_rawtp(void *ctx)
>  	handle(ctx);
>  	return 0;
>  }
> +
> +SEC("usdt")
> +int bench_trigger_usdt(void *ctx)

Should this use SEC("?usdt") instead of SEC("usdt")?

All other programs in this file use the '?' prefix to disable autoload by
default:

    SEC("?uprobe")
    SEC("?uprobe.multi")
    SEC("?raw_tp")
    SEC("?kprobe/bpf_get_numa_node_id")
    ...

Without the '?' prefix, bench_trigger_usdt will be auto-loaded whenever the
trigger_bench skeleton is loaded by any benchmark using setup_ctx()/load_ctx(),
adding unnecessary overhead to unrelated benchmarks.

> +{
> +	inc_counter();
> +	return 0;
> +}



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 usdt trigger bench
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/21867569087

AI-authorship-score: low
AI-authorship-explanation: The commit exhibits natural kernel developer style with real benchmark data, informal comments, and follows existing codebase patterns with minor inconsistencies typical of human development.
issues-found: 1
issue-severity-score: low
issue-severity-explanation: Minor pattern inconsistency in test code where SEC("usdt") should use SEC("?usdt") to match the established convention for disabling autoload by default.

@kernel-patches-daemon-bpf
Copy link
Author

@kernel-patches-daemon-bpf
Copy link
Author

@kernel-patches-daemon-bpf
Copy link
Author

@kernel-patches-daemon-bpf
Copy link
Author

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

@kernel-patches-daemon-bpf
Copy link
Author

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

Adding uprobe syscall feature detection that will be used
in following changes.

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

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

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>
Syncing latest usdt.h change [1].

Now that we have no5 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 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 kernel-patches-daemon-bpf bot deleted the series/1052727=>bpf-next branch February 13, 2026 09:07
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