Article View: linux.kernel.netdev
Article #23616Re: [RFC PATCH 0/3] Introduce a classic BPF filter cache for seccomp
From: Xu Kuohai
Date: Fri, 27 Nov 2026 15:15
Date: Fri, 27 Nov 2026 15:15
65 lines
11829 bytes
11829 bytes
On 11/27/2026 4:17 AM, Alexei Starovoitov wrote:
> On Thu, Nov 26, 2026 at 07:02 AM Xu Kuohai <xukuohai@huaweicloud.com> 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?
Hi Alexei,
You are correct.
The benchmark server is arm64. The lock hold times in bpf_prog_pack_alloc()
and bpf_prog_pack_free() are typically 8–16 us and 256–512 us, respectively.
The free path is dominated by bpf_arch_text_invalidate(), which sends IPIs
to all CPUs and waits for completion. The wait happens after put_cpu(), so
the task is preemptible. If the task is preempted, other lock waiters remain
blocked until it is scheduled back and releases the lock. This can extend
the lock hold time to seconds.
Below is a sample of the captured preemption stack:
-> bpf_prog_pack_free
-> bpf_arch_text_invalidate
-> aarch64_insn_set
-> __text_poke
-> kick_all_cpus_sync
-> smp_call_function_many_cond
-> el1h_64_irq
-> el1h_64_irq_handler
-> el1_interrupt
-> arm64_exit_to_kernel_mode_preempt
-> irqentry_exit_cond_resched
-> preempt_schedule_irq
-> __schedule
After moving bpf_arch_text_invalidate() out of pack_mutex, the p99 VM
startup latency drops from 2.79 s to 170 ms under the same workload.
I will post the patch once it is ready.
Technical Details
Message-ID:
<5b1c03a4-f910-4f97-af3e-1b8c328dd1ba@huaweicloud.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372816-linux-kernel-netdev=dewy.ruReferences:
<cover.1795139109.git.xukuohai@huaweicloud.com> <DN0AIFQ82CFP.34SDTH6ZFZC1G@gmail.com> <309b8e49-2f9c-4a2f-9b40-8e7e7cce3455@huaweicloud.com> <DN5F4EBDNESC.3UOJRTCXCL4HI@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372816-linux-kernel-netdev=dewy.ru From: xukuohai@huaweicloud.com (Xu Kuohai) Newsgroups: linux.kernel.netdev Subject: Re: [RFC PATCH 0/3] Introduce a classic BPF filter cache for seccomp Date: Fri, 27 Nov 2026 23:15:49 +0800 Organization: Usenet Network Message-ID: <5b1c03a4-f910-4f97-af3e-1b8c328dd1ba@huaweicloud.com> References: <cover.1795139109.git.xukuohai@huaweicloud.com> <DN0AIFQ82CFP.34SDTH6ZFZC1G@gmail.com> <309b8e49-2f9c-4a2f-9b40-8e7e7cce3455@huaweicloud.com> <DN5F4EBDNESC.3UOJRTCXCL4HI@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="759447"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:BQMgWAzyuKC5LodU4TILekwG96I= sha256:Acc4MkiAA12l5LRJen5iocZN+g7vIojdIp7Z2PjL9dk= sha1:UIBu/MX3HC5XrFR7QSHyVZZ0PRA= sha256:nOKteNaV3cj5Bz8rPA/aA3UzegCCYZ+YIR2tMScKNIU= Content-Language: en-US List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 7874E125F62; Fri, 27 Nov 2026 18:16:19 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31 tests=[HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 66Xl2lgClYcZ; Fri, 27 Nov 2026 18:16:14 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-372816-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=huaweicloud.com X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 79639125F5E; Fri, 27 Nov 2026 18:16:09 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 81F7960394A; Fri, 27 Nov 2026 15:16:07 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795792563; b=xPGEb1vJZYvrmQYaQ5UrV7LwP2FgzwvbsWebwkB2nIcwoGf+i06UufNb5b43a/FbE5VL HEOUgNXIAGhuVNO0AynBLPZlBhPawKhwgHYL0igZZnURLSy+FGABl2dC4SmqJRk4y1lAa LuUY/obgtvHcqaWik/p7dH2Zeg/wSiaLpLq342IfOyCp4kA+qguIMpzfmQgb87evldXl9 60F5sUeboN58V1TSov1F50cf4N7i0OfzjCsn7t07Ik8MJg1nNno731nBOXXFNB6xcesHK KQg1lpN+HqB0IIPJwITmqUXxRTCo+vRdYaMgMTEG3W4rNcVe3wackhLGaGNtZHi13Xw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795792563; h=X-Original-To:Received:DMARC-Filter:Received:Received:Received: Message-ID:Date:X-Mailing-List:List-Id:List-Post:List-Help: List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version: User-Agent:Subject:Content-Language:To:Cc:References:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-CM-TRANSID: X-Coremail-Antispam:X-CM-SenderInfo; bh=UovAB91mpmRvk0vwp+7ZyfpwJL8uSdEUcyWvQiIlTp0=; b=KAlAxJNcII+/mD3QFapGUxc5qwCM+bJXkVle/L8wUw+u3dy57QMo0YQU2ITxZuECWZN/ wRqcF/cdep8pT//7UBtKSe4qxQXHfyU5FAWWnhVZTm9uXsYEsTz8UZga78Qn2721VqrDW 4ICjFDua9DE7VC4Om0R0afC1XA9MmXaouws1EziIRj5Ewnz9bRJV+32ErYc6f/CZo190I jkTGQJ5uAeREaKWJ0jOYBnGzoyde80YgGn7Pxn31nbYvOL25UOkfkvthdYZpC/TS++FO7 Zosn5ziiYf4StsG8HFhfZBcAZQJKxk4ZHwHdEIekrFirph/BZlduy+FAyqmYVibapwg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E99E6606A336; Fri, 27 Nov 2026 15:16:02 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=124.71.93.99 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795792562; b=TtkMDJOMR5VDY7Si+aq6futXSw4nezNpZuQ+Sgr4wlzBMJ/nDyOhCQG9gop69GyItVA+ W/otB5eG678J/uWUA+iyU/x54PswozMMZ39PzJXEcJc/f3LPj4LgToOHqOClQN+korPYt 2cNSU5ZQnYxGAIpOH7ogbM9Z27ZnTiHvMWaZMy6SjjlPAOVP8py+SSxd+YXgFm05EmmAk YmmyN0S9iLmLVGsuJARU3TJtTB6jGkUUOoY5aOSyHUUCcVgxvuBgpv1SDq0kTkc8JXMy/ iqTXpcCdU7iK+b2WuLbkip5nkRLZzNrFVhGwAodBnOKUF7RfA9V+6g/O+jNQIXglHrg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795792562; h=DMARC-Filter:Received:Received:Received:Message-ID:Date:MIME-Version: User-Agent:Subject:Content-Language:To:Cc:References:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-CM-TRANSID: X-Coremail-Antispam:X-CM-SenderInfo; bh=UovAB91mpmRvk0vwp+7ZyfpwJL8uSdEUcyWvQiIlTp0=; b=mZ3CRdohbVzW0Vzrtj+rPZtY/6m1meB5FwdtaFXoVQtOvncAdo7ITdCAS+6pDaqOOhYT WS0RrCK+M+zGt/bsHnwmLOrz0ffHmrrMPcNyepIKm3Zbfurx8/6AVviOVGDNmQuhANLSa AxQjQvh6L18QYKXi9yQIZtMwgq66nKZlYpjAKHa8+HXWIc+LYrB1oGGzcIwSBWVBc1EWf smK173Ax6N3u9yuMbcI4drZyJKcHJ7oQqMkOAFxeT4RzObbodTffquy061l4XybGciUSP AlYZ7wvr0OfW3y9Xon7NDyat4khVd7Bxk92MJfCR8g+KT0wZdnQYBfN5vq9ofA/hQNA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.remote-ip=124.71.93.99 X-Received: from dggmsgout11.his.huawei.com (dggmsgout11.his.huawei.com [124.71.93.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81105606A31C; Fri, 27 Nov 2026 15:16:00 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 81105606A31C X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com X-Received: from mail.maildlp.com (unknown [172.19.163.198]) by dggmsgout11.his.huawei.com (SkyGuard) with ESMTP id 4jbcRy2Mjsz1c0Qv; Fri, 27 Nov 2026 23:15:42 +0800 (CST) X-Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 3591F40573; Fri, 27 Nov 2026 23:15:51 +0800 (CST) X-Received: from [10.67.111.192] (unknown [10.67.111.192]) by APP4 (Coremail) with UTF8SMTPA id gCh0CgA3dfSlnglrgroaGA--.48334S2; Fri, 27 Nov 2026 23:15:51 +0800 (CST) X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-User-Agent: Mozilla Thunderbird X-Cc: Kees Cook <kees@kernel.org>, Andy Lutomirski <luto@amacapital.net>, Will Drewry <wad@chromium.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> X-In-Reply-To: <DN5F4EBDNESC.3UOJRTCXCL4HI@gmail.com> X-CM-TRANSID: gCh0CgA3dfSlnglrgroaGA--.48334S2 X-Coremail-Antispam: 1UD129KBjvJXoW7ZFW5Aw4ftr1fJFyxGryrtFb_yoW5JFWxpF ZxtrWftw1UJw12vw17Xr4UWryrZw4DWFyrGr15Ww4xurn0kr1IgF1Ikw48urWY9ryrG3yF yr4qqrZ3Xrn8AaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvjb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I 0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40E x7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x 0Yz7v_Jr0_Gr1lF7xvr2IY64vIr41lFIxGxcIEc7CjxVA2Y2ka0xkIwI1lc7CjxVAaw2AF wI0_Jw0_GFyl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4 xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43 MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I 0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWU JVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUF1 v3UUUUU X-CM-SenderInfo: 50xn30hkdlqx5xdzvxpfor3voofrz/