Skip to content

bpf: Shorten pack_mutex critical sections

Puranjay Mohan bpf 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 2 repliesIn review

Changes since v1 from the cover letter

- Invalidate before taking pack_mutex on all archs, instead of dropping and retaking it on arm64
- New patch 1 for the deadlock

[1] https://lore.kernel.org/bpf/[email protected]/

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2bpf: Don't allocate and free prog pack memory with pack_mutex heldkernel/bpf/core.c+36 -162 replies
2/2bpf: Invalidate freed prog pack memory without holding pack_mutexkernel/bpf/core.c+3 -30 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH bpf 0/2] bpf: Shorten pack_mutex critical sections

Patch 2 moves bpf_arch_text_invalidate() out of pack_mutex, as suggested on v1 [1].

That makes the frees fast enough to hit a deadlock that was already
there: the pack_mutex owner frees an empty pack and waits in flush_work() for vmalloc purge work, which cannot run while bpf_prog_free_deferred() items waiting for pack_mutex fill the system_percpu_wq pool. Patch 1 allocates and frees pack memory without pack_mutex. Seen on arm64; x86 and powerpc take the same path.

Changes since v1:
- Invalidate before taking pack_mutex on all archs, instead of dropping and retaking it on arm64
- New patch 1 for the deadlock

[1] https://lore.kernel.org/bpf/[email protected]/

Puranjay Mohan (2):
bpf: Don't allocate and free prog pack memory with pack_mutex held
bpf: Invalidate freed prog pack memory without holding pack_mutex

 kernel/bpf/core.c | 58 +++++++++++++++++++++++++++++++----------------
 1 file changed, 39 insertions(+), 19 deletions(-)

base-commit: 9abe2c42ecab6c86b54838d2d645ca2e10204606

Signature · 1 line
2.53.0-Meta