Skip to content

rtla/timerlat: Add low-latency BPF-based actions

Tomas Glozar linux-trace-kernel lkml 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest7 patches 2 repliesIn review
  2. v37 patches 11 repliesSuperseded
  3. v27 patches 1 replySuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v14 patches11 repliesSuperseded

Changes in v4 from the cover letter

- Rename cover letter to avoid confusing the Gmail web client.
- Rebase over latest linux-next.
- Fix typo "doing doing" -> "doing".
- Add reviews by Wander from v3.
- Clarify documentation entry about BPF program name.

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7rtla/timerlat: Support tail call from BPF programtools/tracing/rtla/src/timerlat.bpf.c tools/tracing/rtla/src/timerlat_bpf.c tools/tracing/rtla/src/timerlat_bpf.h+35 -40 replies
2/7rtla/timerlat: Add --bpf-action optiontools/tracing/rtla/src/timerlat.c tools/tracing/rtla/src/timerlat.h tools/tracing/rtla/src/timerlat_bpf.c +3 more+80 -20 replies
3/7rtla/timerlat: Add example for BPF action programtools/tracing/rtla/Makefile tools/tracing/rtla/example/timerlat_bpf_action.c tools/tracing/rtla/example/timerlat_load.py+24 -12 replies
4/7rtla/tests: Test BPF action programtools/tracing/rtla/Makefile tools/tracing/rtla/tests/bpf/bpf_action_map.c tools/tracing/rtla/tests/timerlat.t+48 -20 replies
5/7rtla/tests: Run Test::Harness in verbose modetools/tracing/rtla/Makefile tools/tracing/rtla/tests/engine.sh+1 -20 replies
6/7Documentation/rtla: Rename sample/ to example/Documentation/tools/rtla/common_timerlat_options.txt+1 -10 replies
7/7Documentation/rtla: Document --bpf-action optionDocumentation/tools/rtla/common_timerlat_options.txt+18 -00 replies

Reviews trailers per patch

2 of 7 patches have a Reviewed-by or Acked-by.

PatchWander Lairson Costa
1/7
2/7
3/7
4/7
5/7R-b
6/7R-b
7/7

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 0/7] rtla/timerlat: Add low-latency BPF-based actions

This patchset extends rtla-timerlat's BPF support with the option of executing a user-supplied BPF program on latency threshold overflow.

See the supplied example and documentation for how to create a program. bpf_tail_call() is used to chain the program with the built-in BPF sample collection program, if the threshold is hit.

The feature can be used for both in-kernel data collection and sending signals to userspace directly from the kernel, if the kernel version allows it.

Note: The patchset will have to be rebased on top of [1], or vice versa, since they both touch stop_tracing() ([1] adds one call of it, and this patchset adds an extra argument to it).

I have contemplated adding this as --on-threshold bpf,... but it does not fit the existing actions infrastructure very well, since the action happens in the BPF program, not in RTLA, and only one BPF action is supported.

[1] https://lore.kernel.org/linux-trace-kernel/[email protected]/

v4:
- Rename cover letter to avoid confusing the Gmail web client.
- Rebase over latest linux-next.
- Fix typo "doing doing" -> "doing".
- Add reviews by Wander from v3.
- Clarify documentation entry about BPF program name.

v3 changes:
- Add tests/bpf/bpf_action_map.c to test commit (forgot to run git add before).

v2 changes:
- Properly bpf__object_close() also when bpf__object_load() fails.
- Use goto for error paths in timerlat_load_bpf_action_program().
- Remove unneeded NULLing of obj and prog in timerlat_bpf_init().
- Add entry to Makefile to build example.
- Add test for BPF actions.
- Rename sample/ directory to example/, also in docs.
- Run Test::Harness in verbose mode during "make check".

Thanks to Crystal and Wander for their input.

Tomas Glozar (7):
rtla/timerlat: Support tail call from BPF program rtla/timerlat: Add --bpf-action option rtla/timerlat: Add example for BPF action program rtla/tests: Test BPF action program rtla/tests: Run Test::Harness in verbose mode Documentation/rtla: Rename sample/ to example/ Documentation/rtla: Document --bpf-action option

 .../tools/rtla/common_timerlat_options.txt    | 20 +++++-
 tools/tracing/rtla/Makefile                   | 19 +++++-
 .../rtla/example/timerlat_bpf_action.c        | 16 +++++
 .../rtla/{sample => example}/timerlat_load.py |  0
 tools/tracing/rtla/src/timerlat.bpf.c         | 25 +++++--
 tools/tracing/rtla/src/timerlat.c             | 11 ++++
 tools/tracing/rtla/src/timerlat.h             |  2 +-
 tools/tracing/rtla/src/timerlat_bpf.c         | 66 +++++++++++++++++++
 tools/tracing/rtla/src/timerlat_bpf.h         |  7 +-
 tools/tracing/rtla/src/timerlat_hist.c        |  5 ++
 tools/tracing/rtla/src/timerlat_top.c         |  5 ++
 tools/tracing/rtla/tests/bpf/bpf_action_map.c | 25 +++++++
 tools/tracing/rtla/tests/engine.sh            |  1 -
 tools/tracing/rtla/tests/timerlat.t           | 15 +++++
 14 files changed, 206 insertions(+), 11 deletions(-)
 create mode 100644 tools/tracing/rtla/example/timerlat_bpf_action.c
 rename tools/tracing/rtla/{sample => example}/timerlat_load.py (100%)
 create mode 100644 tools/tracing/rtla/tests/bpf/bpf_action_map.c
Signature · 1 line
2.51.1