Skip to content

libbpf: Make optimized uprobes backward compatible

Jiri Olsa bpf lkml 5 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest5 patches 0 repliesApplied 5/5
  2. v45 patches 2 repliesSuperseded
  3. v35 patches 8 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v25 patches2 repliesSuperseded
v14 patches8 repliesSuperseded

Changes in v5 from the cover letter

- keep nop_combo on stack and levae buf uninitialized in has_nop_combo function [David]

Patches in v5 All 5 applied

#Subject and filesSizeRepliesApplied
1/5libbpf: Add uprobe syscall feature detectiontools/lib/bpf/features.c tools/lib/bpf/libbpf_internal.h+26 -00 repliesApplied
2/5libbpf: Add support to detect nop,nop5 instructions combo for usdt probetools/lib/bpf/usdt.c+43 -40 repliesApplied
3/5selftests/bpf: Emit nop,nop5 instructions combo for x86_64 archtools/testing/selftests/bpf/usdt.h+2 -00 repliesApplied
4/5selftests/bpf: Add test for checking correct nop of optimized usdttools/testing/selftests/bpf/.gitignore tools/testing/selftests/bpf/Makefile tools/testing/selftests/bpf/prog_tests/usdt.c +3 more+142 -10 repliesApplied
5/5selftests/bpf: Add usdt trigger benchtools/testing/selftests/bpf/Makefile tools/testing/selftests/bpf/bench.c tools/testing/selftests/bpf/benchs/bench_trigger.c +2 more+76 -20 repliesApplied

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.

Read the v5 thread

Cover letter [PATCHv5 bpf-next 0/5] libbpf: Make optimized uprobes backward compatible

hi,
we can currently optimize uprobes on top of nop5 instructions, so application can define USDT_NOP to nop5 and use USDT macro to define optimized usdt probes.

This works fine on new kernels, but could have performance penalty on older kernels, that do not have the support to optimize and to emulate nop5 instruction.

This patchset adds support to workaround the performance penalty on older kernels that do not support uprobe optimization, please see detailed description in patch 2.

v1: https://lore.kernel.org/bpf/[email protected]/
v2: https://lore.kernel.org/bpf/[email protected]/
v3: https://lore.kernel.org/bpf/[email protected]/T/#t
v4: https://lore.kernel.org/bpf/[email protected]/

v5 changes:
- keep nop_combo on stack and levae buf uninitialized in has_nop_combo function [David]

v4 changes:
- rebased on latest bpf-next/master
- use pread for nop combo read [Andrii]
- renamed usdt triger benchmark names [Andrii]
- added more ip address checks to tests [Andrii]

v3 changes:
- fix __x86_64 define and other typos [CI]
- add missing '?' to usdt trigger program [CI]

v2 changes:
- after more investigation we realized there are some versions of bpftrace and stap that does not work with solution suggested in version 1, so we decided to switch to following solution:

- change USDT macro [1] emits nop,nop5 instructions combo by default
- libbpf detects nop,nop5 instructions combo for USDT probe, if there is and if uprobe syscall is detected libbpf installs usdt probe on top of nop5 instruction to get it optimized

- added usdt trigger benchmarks [Andrii]
- several small fixes on uprobe syscall detection, tests and other places [Andrii]
- true usdt.h source [1] updated [Andrii]
- compile usdt_* objects unconditionally [Andrii]

thanks,
jirka

[1] https://github.com/libbpf/usdt
---
Jiri Olsa (5):
libbpf: Add uprobe syscall feature detection
libbpf: Add support to detect nop,nop5 instructions combo for usdt probe selftests/bpf: Emit nop,nop5 instructions combo for x86_64 arch selftests/bpf: Add test for checking correct nop of optimized usdt selftests/bpf: Add usdt trigger bench

 tools/lib/bpf/features.c                                | 24 ++++++++++++++++++++++++
 tools/lib/bpf/libbpf_internal.h                         |  2 ++
 tools/lib/bpf/usdt.c                                    | 47 +++++++++++++++++++++++++++++++++++++++++++----
 tools/testing/selftests/bpf/.gitignore                  |  2 ++
 tools/testing/selftests/bpf/Makefile                    |  5 ++++-
 tools/testing/selftests/bpf/bench.c                     |  4 ++++
 tools/testing/selftests/bpf/benchs/bench_trigger.c      | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/testing/selftests/bpf/benchs/run_bench_uprobes.sh |  2 +-
 tools/testing/selftests/bpf/prog_tests/usdt.c           | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/testing/selftests/bpf/progs/test_usdt.c           | 12 ++++++++++++
 tools/testing/selftests/bpf/progs/trigger_bench.c       | 10 +++++++++-
 tools/testing/selftests/bpf/usdt.h                      |  2 ++
 tools/testing/selftests/bpf/usdt_1.c                    | 18 ++++++++++++++++++
 tools/testing/selftests/bpf/usdt_2.c                    | 16 ++++++++++++++++
 14 files changed, 289 insertions(+), 7 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/usdt_1.c
 create mode 100644 tools/testing/selftests/bpf/usdt_2.c