mbox series

[bpf-next,v2,0/2] Enable static subprog calls in spin lock critical sections

Message ID 20240204222349.938118-1-memxor@gmail.com (mailing list archive)
Headers show
Series Enable static subprog calls in spin lock critical sections | expand

Message

Kumar Kartikeya Dwivedi Feb. 4, 2024, 10:23 p.m. UTC
This set allows a BPF program to make a call to a static subprog within
a bpf_spin_lock critical section. This problem has been hit in sched-ext
and ghOSt [0] as well, and is mostly an annoyance which is worked around
by inling the static subprog into the critical section.

In case of sched-ext, there are a lot of other helper/kfunc calls that
need to be allow listed for the support to be complete, but a separate
follow up will deal with that.

Unlike static subprogs, global subprogs cannot be allowed yet as the
verifier will not explore their body when encountering a call
instruction for them. Therefore, we would need an alternative approach
(some sort of function summarization to ensure a lock is never taken
from a global subprog and all its callees).

 [0]: https://lore.kernel.org/bpf/bd173bf2-dea6-3e0e-4176-4a9256a9a056@google.com

Changelog:
----------
v1 -> v2
v1: https://lore.kernel.org/bpf/20240204120206.796412-1-memxor@gmail.com

 * Indicate global function call in verifier error string (Yonghong, David)
 * Add Acks from Yonghong, David

Kumar Kartikeya Dwivedi (2):
  bpf: Allow calling static subprogs while holding a bpf_spin_lock
  selftests/bpf: Add test for static subprog call in lock cs

 kernel/bpf/verifier.c                         | 11 +++-
 .../selftests/bpf/prog_tests/spin_lock.c      |  2 +
 .../selftests/bpf/progs/test_spin_lock.c      | 65 +++++++++++++++++++
 .../selftests/bpf/progs/test_spin_lock_fail.c | 44 +++++++++++++
 .../selftests/bpf/progs/verifier_spin_lock.c  |  2 +-
 5 files changed, 120 insertions(+), 4 deletions(-)


base-commit: 2a79690eae953daaac232f93e6c5ac47ac539f2d

Comments

Barret Rhoden Feb. 5, 2024, 10:37 p.m. UTC | #1
On 2/4/24 17:23, Kumar Kartikeya Dwivedi wrote:
> This set allows a BPF program to make a call to a static subprog within
> a bpf_spin_lock critical section. This problem has been hit in sched-ext
> and ghOSt [0] as well, and is mostly an annoyance which is worked around
> by inling the static subprog into the critical section.

thanks!  i look forward to deleting my various noinline hacks.  =)
patchwork-bot+netdevbpf@kernel.org Feb. 6, 2024, 4 a.m. UTC | #2
Hello:

This series was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Sun,  4 Feb 2024 22:23:47 +0000 you wrote:
> This set allows a BPF program to make a call to a static subprog within
> a bpf_spin_lock critical section. This problem has been hit in sched-ext
> and ghOSt [0] as well, and is mostly an annoyance which is worked around
> by inling the static subprog into the critical section.
> 
> In case of sched-ext, there are a lot of other helper/kfunc calls that
> need to be allow listed for the support to be complete, but a separate
> follow up will deal with that.
> 
> [...]

Here is the summary with links:
  - [bpf-next,v2,1/2] bpf: Allow calling static subprogs while holding a bpf_spin_lock
    https://git.kernel.org/bpf/bpf-next/c/a44b1334aadd
  - [bpf-next,v2,2/2] selftests/bpf: Add test for static subprog call in lock cs
    https://git.kernel.org/bpf/bpf-next/c/e8699c4ff85b

You are awesome, thank you!