Skip to content

bpf: Make BPF and PREEMPT_RT co-exist

Thomas Gleixner bpf lkml netdev 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest22 patches 6 repliesIn review
  2. v220 patches 3 repliesSuperseded
  3. v11 patch 0 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/22bpf: Tighten the requirements for preallocated hash mapskernel/bpf/verifier.c+28 -110 replies
2/22bpf: Enforce preallocation for instrumentation programs on RTkernel/bpf/verifier.c+9 -40 replies
3/22bpf: Update locking comment in hashtab codekernel/bpf/hashtab.c+20 -40 replies
4/22bpf/tracing: Remove redundant preempt_disable() in __bpf_trace_run()kernel/trace/bpf_trace.c+1 -20 replies
5/22bpf/trace: Remove EXPORT from trace_call_bpf()kernel/trace/bpf_trace.c+0 -11 reply
6/22bpf/trace: Remove redundant preempt_disable from trace_call_bpf()kernel/trace/bpf_trace.c+1 -24 replies
7/22perf/bpf: Remove preempt disable around BPF invocationkernel/events/core.c+0 -20 replies
8/22bpf: Remove recursion prevention from rcu free callbackkernel/bpf/hashtab.c+0 -80 replies
9/22bpf: Dont iterate over possible CPUs with interrupts disabledkernel/bpf/percpu_freelist.c+10 -100 replies
10/22bpf: Provide bpf_prog_run_pin_on_cpu() helperinclude/linux/filter.h+24 -22 replies
11/22bpf: Replace cant_sleep() with cant_migrate()include/linux/filter.h+1 -10 replies
12/22bpf: Use bpf_prog_run_pin_on_cpu() at simple call sites.include/linux/filter.h kernel/seccomp.c net/core/flow_dissector.c +2 more+6 -180 replies
13/22bpf/tests: Use migrate disable instead of preempt disablelib/test_bpf.c net/bpf/test_run.c+6 -60 replies
14/22bpf: Use migrate_disable/enabe() in trampoline code.kernel/bpf/trampoline.c+5 -40 replies
15/22bpf: Use migrate_disable/enable in array macros and cgroup/lirc code.include/linux/bpf.h include/linux/filter.h+7 -60 replies
16/22bpf: Provide recursion prevention helpersinclude/linux/bpf.h+30 -00 replies
17/22bpf: Use recursion prevention helpers in hashtab codekernel/bpf/hashtab.c+4 -80 replies
18/22bpf: Replace open coded recursion prevention in sys_bpf()kernel/bpf/syscall.c+8 -190 replies
19/22bpf: Factor out hashtab bucket lock operationskernel/bpf/hashtab.c+46 -230 replies
20/22bpf: Prepare hashtab locking for PREEMPT_RTkernel/bpf/hashtab.c+56 -90 replies
21/22bpf, lpm: Make locking RT friendlykernel/bpf/lpm_trie.c+6 -60 replies
22/22bpf/stackmap: Dont trylock mmap_sem with PREEMPT_RT and interrupts disabledkernel/bpf/stackmap.c+15 -30 replies

Reviews trailers per patch

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

Read the v3 thread

Cover letter [patch V3 00/22] bpf: Make BPF and PREEMPT_RT co-exist

Hi!

This is the third version of the BPF/RT patch set which makes both coexist nicely. The long explanation can be found in the cover letter of the V1 submission:

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

V2 is here:

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

The following changes vs. V2 have been made:

- Rebased to bpf-next, adjusted to the lock changes in the hashmap code.

- Split the preallocation enforcement patch for instrumentation type BPF programs into two pieces:

1) Emit a one-time warning on !RT kernels when any instrumentation type BPF program uses run-time allocation. Emit also a corresponding warning in the verifier log. But allow the program to run for backward compatibility sake. After a grace period this should be enforced.

2) On RT reject such programs because on RT the memory allocator cannot be called from truly atomic contexts.

- Fixed the fallout from V2 as reported by Alexei and 0-day

- Removed the redundant preempt_disable() from trace_call_bpf()

- Removed the unused export of trace_call_bpf()

The series applies on top of:

git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master

Selftest result:
# Summary: 1580 PASSED, 0 SKIPPED, 0 FAILED

Thanks,

tglx

---
 include/linux/bpf.h          |   38 ++++++++-
 include/linux/filter.h       |   37 +++++++--
 kernel/bpf/hashtab.c         |  172 ++++++++++++++++++++++++++++++-------------
 kernel/bpf/lpm_trie.c        |   12 +--
 kernel/bpf/percpu_freelist.c |   20 ++---
 kernel/bpf/stackmap.c        |   18 +++-
 kernel/bpf/syscall.c         |   27 ++----
 kernel/bpf/trampoline.c      |    9 +-
 kernel/bpf/verifier.c        |   40 +++++++---
 kernel/events/core.c         |    2 
 kernel/seccomp.c             |    4 -
 kernel/trace/bpf_trace.c     |    7 -
 lib/test_bpf.c               |    4 -
 net/bpf/test_run.c           |    8 +-
 net/core/flow_dissector.c    |    4 -
 net/core/skmsg.c             |    8 --
 net/kcm/kcmsock.c            |    4 -
 17 files changed, 274 insertions(+), 140 deletions(-)