Skip to content

bpf: Fast-Path approach for BPF program termination

Siddharth Chintamaneni bpf llvm oe-kbuild-all 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 5 repliesIn review

v2 -> v3 from the cover letter

- Cloning of BPF programs has been removed.
- Created call sites table to maintain helper/ kfunc call instruction offsets.
- Termination is triggered inside the softlockup detector not affecting any fast path operations.

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4bpf: Introduce new structs and struct fields for fast path terminationinclude/linux/bpf.h kernel/bpf/core.c+79 -272 replies
2/4bpf: Creating call sites table to stub instructions during runtimearch/x86/net/bpf_jit_comp.c include/linux/bpf_verifier.h kernel/bpf/core.c +1 more+137 -130 replies
3/4bpf: runtime part of fast-path termination approacharch/x86/net/bpf_jit_comp.c include/linux/bpf.h include/linux/filter.h +2 more+182 -12 replies
4/4selftests/bpf: Adds selftests to check termination of long running nested bpf loopstools/testing/selftests/bpf/prog_tests/bpf_termination.c tools/testing/selftests/bpf/progs/bpf_termination.c+86 -00 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 0/4] bpf: Fast-Path approach for BPF program termination

This is RFC v3 of

	https://lore.kernel.org/all/[email protected]/

The termination handler call from the softlockup detector is mainly for the demonstration of the entire workflow and also serves as a potential use case for discussion. However, the runtime mechanism is modular enough to be ported to different scenarios such as deadlocks, page faults, userspace BPF management tools, and stack overflows.

The main changes that we bring in this version are: We have avoided the memory overhead caused by program cloning in previous versions. During normal program execution, none of the termination logic causes any additional overhead.

Change log:
v2 -> v3:
- Cloning of BPF programs has been removed.
- Created call sites table to maintain helper/ kfunc call instruction offsets.
- Termination is triggered inside the softlockup detector not affecting any fast path operations.

v1 -> v2:
- Patch generation has been moved after verification and before JIT.
- Now patch generation handles both helpers and kfuncs.
- Sanity check on original prog and patch prog after JIT.
- Runtime termination handler is now global termination mechanism using text_poke.
- Termination is triggered by watchdog timer.

 arch/x86/net/bpf_jit_comp.c                   | 141 ++++++++++++++++++
 include/linux/bpf.h                           |  77 ++++++----
 include/linux/bpf_verifier.h                  |   1 +
 include/linux/filter.h                        |   6 +
 kernel/bpf/core.c                             |  67 +++++++++
 kernel/bpf/verifier.c                         | 135 +++++++++++++++--
 kernel/watchdog.c                             |   8 +
 .../bpf/prog_tests/bpf_termination.c          |  39 +++++
 .../selftests/bpf/progs/bpf_termination.c     |  47 ++++++
 9 files changed, 482 insertions(+), 39 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/bpf_termination.c
 create mode 100644 tools/testing/selftests/bpf/progs/bpf_termination.c
Signature · 1 line
2.43.0