Re: [RFC PATCH 0/3] Introduce a classic BPF filter cache for seccomp
From: Xu Kuohai
Date: Thu Nov 26 2026 - 10:03:25 EST
On 11/21/2026 3:37 AM, Alexei Starovoitov wrote:
On Thu, Nov 19, 2026 at 10:48 PM Xu Kuohai <xukuohai@xxxxxxxxxxxxxxx> wrote:
The kernel repeatedly translates and JIT-compiles these same cBPF
programs, wasting CPU cycles and slowing down bulk startup of
identically sandboxed workloads. cBPF lacks dynamic instruction patching
There is no VM startup number in the series
which makes me question the whole thing.
The problem comes from an agent sandbox deployment, where
sandboxes are snapshotted to disk and resumed on demand for
each new request.
Below are the Firecracker microVM startup latencies I
measured on a local server at different VM request rates.
Parentheses show the improvement over the base kernel.
VM req/s base p50 series p50 (gain) base p95 series p95 (gain) base p99 series p99 (gain)
400 20.2 ms 19.7 ms (+2%) 29.2 ms 27.9 ms (+5%) 34.7 ms 33.3 ms (+4%)
500 28.2 ms 27.1 ms (+4%) 96.8 ms 69.4 ms (+28%) 164.0 ms 107.9 ms (+34%)
600 56.6 ms 45.0 ms (+21%) 602 ms 154.5 ms (+74%) 831.8 ms 223.6 ms (+73%)
700 65.5 ms 41.1 ms (+37%) 1.63 s 134.1 ms (+92%) 2.43 s 194.1 ms (+92%)
800 65.4 ms 39.4 ms (+40%) 2.97 s 113.8 ms (+96%) 4.60 s 167.3 ms (+96%)
900 61.9 ms 35.7 ms (+42%) 3.04 s 95.2 ms (+97%) 5.13 s 147.3 ms (+97%)
1000 53.2 ms 32.2 ms (+39%) 3.38 s 80.0 ms (+98%) 5.78 s 125.1 ms (+98%)
At 400 VM/s, the two kernels perform similarly. At higher
rates, the base kernel suffers severe tail latency
collapse, while this series keeps p99 below 225 ms,
reducing it by up to 98% at 1000 VM/s.
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.
features like tail calls or tracing. Its JITed instructions remain
immutable at runtime. This makes it possible to share the same cBPF
filter between different processes.
Immutable is not enough. The image depends on the caps of the task
that loads the filter.
Also any task can time seccomp() and learn that somebody has this filter.
seccomp_get_filter() needs CAP_SYS_ADMIN for that today.
fork() shares the filter already, see copy_seccomp().
A launcher can install the common filter once and fork the VMs.
I don't think we need this.
pw-bot: cr