mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: Xu Kuohai <xukuohai@huaweicloud.com>,
	bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
	io-uring@vger.kernel.org, netdev@vger.kernel.org
Cc: Andy Lutomirski <luto@amacapital.net>,
	Will Drewry <wad@chromium.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Stanislav Fomichev <sdf@fomichev.me>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Jens Axboe <axboe@kernel.dk>
Subject: Re: [RFC PATCH 0/3] Introduce a classic BPF filter cache for seccomp
Date: Mon, 23 Nov 2026 12:47:53 +1000	[thread overview]
Message-ID: <EF2067C8-7F71-4D92-ABC9-25BC3234036E@kernel.org> (raw)
In-Reply-To: <cover.1795139109.git.xukuohai@huaweicloud.com>



On November 20, 2026 4:48:49 PM GMT+10:00, Xu Kuohai <xukuohai@huaweicloud.com> wrote:
>Sandboxes like Firecracker use seccomp filters to restrict allowed
>syscalls. Hundreds to thousands of Firecracker VM instances can run
>from a single template. Each instance loads identical seccomp filters.
>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
>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.
>
>This series introduces a classic BPF filter cache. It is implemented as
>a hash table that maps user-space filter instructions to the prepared
>bpf prog.
>
>The cache lookup occurs before filter preparation:
>- cache hit: Returns the shared bpf prog directly.
>- cache miss: Reserves an entry. Concurrent tasks loading the same filter
>  wait on a wait queue until preparation completes.
>
>The cache is instantiated per subsystem. Currently, seccomp is the only
>user.
>
>This series ends with a benchmark test. Every producer spawns one worker
>thread at a time, the worker installs a batch of filters and exits, the
>benchmark reports the number of filters installed per second. The table
>below benchmarks the batch size and the instruction length in one round,
>running the command below with different option values. The base column
>runs the same command on a kernel without this series. All data was
>measured on a local test setup with 32 producers.

I would expect either memory usage or launch benchmarks, not just filter install timings.

Is there a workload where there is a problem? It is hinted at in the opening paragraph, but I'd want to better understand the actual constraints before jumping to a solution. E.g. it's already possible to share filters by way of process hierarchy, so perhaps the issue is lack of hierarchy?

I've seen proposals in the past about having handles to pre-constructed filters, which could be applied (i.e. much of the existing caching and lifetime management remained unchanged).

-Kees

-- 
Kees Cook

      parent reply	other threads:[~2026-11-23  2:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20  6:48 Xu Kuohai
2026-11-20  6:48 ` [RFC PATCH 1/3] bpf: Introduce classic BPF filter cache Xu Kuohai
2026-11-20  6:48 ` [RFC PATCH 2/3] seccomp: Use the " Xu Kuohai
2026-11-20  6:48 ` [RFC PATCH 3/3] selftests/bpf: Add benchmark for seccomp filter install Xu Kuohai
2026-11-20 19:37 ` [RFC PATCH 0/3] Introduce a classic BPF filter cache for seccomp Alexei Starovoitov
2026-11-23  2:47 ` Kees Cook [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=EF2067C8-7F71-4D92-ABC9-25BC3234036E@kernel.org \
    --to=kees@kernel.org \
    --cc=ast@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=io-uring@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --cc=wad@chromium.org \
    --cc=xukuohai@huaweicloud.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®