Re: [PATCH bpf-next v3 4/9] bpf: take the vmlinux BTF from the btf_vmlinux module

From: Alexei Starovoitov

Date: Sat Sep 26 2026 - 04:29:35 EST


On Fri, Sep 25, 2026 at 10:42 PM Jay Wang <wanjay@xxxxxxxxxx> wrote:
> + if (!data && load) {
> + /*
> + * The module notifier installs the BTF before init_module()
> + * returns, so it is either there after this or the module is
> + * not available (yet). Not cached: a later call retries,
> + * e.g. once the module becomes reachable on the root fs.
> + */
> + request_module("btf_vmlinux");

This will deadlock.
event_btf_ids_read() calls btf_get_module_btf(NULL) with event_mutex
held. With =m and BTF not loaded yet
cat /sys/kernel/tracing/events/sched/sched_switch/btf_ids
gets here and waits for modprobe. modprobe gets to
trace_module_notify() which takes event_mutex.
lockdep doesn't see it.

print_function_args() gets here for every line of the trace,
from ftrace_dump() with irqs off too. When the module is not
installed that is one modprobe per line.

Every caller of bpf_get_btf_vmlinux() and bpf_find_btf_id() was
written for a function that doesn't wait for user space.

pw-bot: cr