Re: [RFC PATCH 0/3] Introduce a classic BPF filter cache for seccomp

From: Alexei Starovoitov

Date: Thu Nov 26 2026 - 15:17:51 EST


On Thu, Nov 26, 2026 at 07:02 AM Xu Kuohai <xukuohai@xxxxxxxxxxxxxxx> wrote:
> After further profiling, I found that this collapse is
> mainly caused by Firecracker instances queuing on the
> global pack_mutex in bpf_prog_pack_alloc(). So a better
> approach is to replace the global mutex to per-pack locks.
> I will work on that instead.

Makes sense to fix it there. Every prog load benefits.
But I doubt that per-pack locks help.
bpf_prog_pack_alloc() walks pack_list from the head and takes the first
pack that has room. All loaders pick the same pack and queue on its lock.

I suspect the hold time comes from these:

path under pack_mutex what it does
----- -------------------------- --------------------------------
alloc bpf_arch_pred_flush() x86: IBPB via on_each_cpu()
free bpf_arch_text_invalidate() x86: text_poke_set(), text_mutex
free bpf_arch_text_invalidate() arm64: kick_all_cpus_sync()

Every free marks its pack dirty. A cBPF alloc from a dirty pack flushes.
The log of commit a9b1f19a6a67 ("bpf: Prefer packs that won't trigger
an IBPB flush on allocation") has ideas how to flush less.

bpf_arch_text_invalidate() doesn't need pack_mutex. The bits of the
chunks are still set in pack->bitmap at that point, so nobody can take
the chunks or free the pack.

What do you see in your profile?