[PATCH bpf-next v2 0/2] bpf: Move IPIs out of pack_mutex and reduce IBPB flushes
From: Xu Kuohai
Date: Thu Dec 03 2026 - 09:36:50 EST
From: Xu Kuohai <xukuohai@xxxxxxxxxx>
BPF JIT memory is allocated through the BPF program pack allocator,
which uses a global pack_mutex to protect its packs. While holding this
lock, the allocator currently sends IPI to all CPUs on two paths: IBPB
flush on the x86 alloc path and CPU pipeline flush on the arm64 free
path. Because the caller can be preempted while waiting for the IPI
completion, the lock can be held for a long time, causing heavy lock
contention on busy systems.
This series moves both IPIs out of pack_mutex and tracks dirty state per
chunk instead of per pack to reduce IBPB flushes.
v2:
- Switch to Puranjay's patch to move bpf_arch_text_invalidate out of
pack_mutex
- Switch to a new approach suggested by Alexei to move the IBPB flush
out of pack_mutex
v1: https://lore.kernel.org/bpf/cover.1796223449.git.xukuohai@xxxxxxxxxx/
Puranjay Mohan (1):
bpf: Invalidate freed prog pack memory without holding pack_mutex
Xu Kuohai (1):
bpf: Reduce branch predictor flush and move it out of pack_mutex
kernel/bpf/core.c | 101 +++++++++++++++++++++++++---------------------
1 file changed, 56 insertions(+), 45 deletions(-)
--
2.47.3