From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Emil Tsalapatis" <emil@etsalapatis.com>, <bpf@vger.kernel.org>
Cc: <andrii@kernel.org>, <eddyz87@gmail.com>, <memxor@gmail.com>,
<daniel@iogearbox.net>
Subject: Re: [PATCH bpf 1/2] bpf: Use dedicated workqueue for freeing BPF programs
Date: Mon, 02 Nov 2026 17:58:36 +0000 [thread overview]
Message-ID: <DMKX4WVWG2FZ.O4KZQEIOSRA9@gmail.com> (raw)
In-Reply-To: <20261102073439.6822-2-emil@etsalapatis.com>
On Sun, Nov 01, 2026 at 11:34 PM Emil Tsalapatis <emil@etsalapatis.com> wrote:
> BPF free workers can exhaust a CPU's system workqueue active slots while
> waiting for pack_mutex. The worker holding pack_mutex then waits for a
> vmalloc purge helper on that same queue, which cannot run until a slot
> is freed.
This doesn't apply to bpf tree.
Commit 4eaf4d71b91a ("bpf: Keep the symbols of a program until it has
ended") moved bpf_jit_free() into bpf_prog_free_images().
bpf_prog_free_deferred() queues it with
queue_rcu_work(system_percpu_wq, &aux->rwork).
So with this patch the pack_mutex waiters are still on system_percpu_wq.
__bpf_tramp_image_put_deferred() has the same problem.
It runs from schedule_work(), and arch_free_bpf_trampoline() calls
bpf_prog_pack_free().
Let's move all three to the new wq in one patch?
> Fixes: 6b88aaec81db ("x86/bpf: Enable EXECMEM_ROX_CACHE for BPF allocations")
The ROX cache is not the cause.
Without it bpf_jit_free_exec() is vfree() of a VM_FLUSH_RESET_PERMS area.
vm_reset_perms() calls _vm_unmap_aliases() and gets to the same
flush_work(), also under pack_mutex.
That's every arch with bpf_prog_pack since
commit 72210662c5a2 ("mm: vmalloc: offload free_vmap_area_lock lock").
> + bpf_prog_free_wq = alloc_workqueue("bpf_prog_free", WQ_UNBOUND, 0);
0 means 1024. That's up to 1024 kworkers that sleep on pack_mutex.
max_active = 1 like cgroup_bpf_destroy_wq ?
pw-bot: cr
next prev parent reply other threads:[~2026-11-02 17:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 7:34 [PATCH bpf 0/2] bpf: Avoid workqueue deadlock when freeing programs Emil Tsalapatis
2026-11-02 7:34 ` [PATCH bpf 1/2] bpf: Use dedicated workqueue for freeing BPF programs Emil Tsalapatis
2026-11-02 17:58 ` Alexei Starovoitov [this message]
2026-11-02 7:34 ` [PATCH bpf 2/2] selftests/bpf: Add a selftest for program allocation/freeing Emil Tsalapatis
2026-11-02 7:47 ` sashiko-bot
2026-11-02 17:55 ` [PATCH bpf 0/2] bpf: Avoid workqueue deadlock when freeing programs Andrii Nakryiko
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=DMKX4WVWG2FZ.O4KZQEIOSRA9@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=memxor@gmail.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