Re: [PATCH bpf-next] bpf: Disable preemption while a raw tracepoint regs slot is in use

From: bot+bpf-ci

Date: Mon Nov 16 2026 - 13:01:05 EST


> bpf: Disable preemption while a raw tracepoint regs slot is in use

TL;DR: Commit message only: the "few instructions" cost claim may be wrong,
since build ID resolution in bpf_get_stack()/bpf_get_stackid() would now run
with preemption disabled. Changelog should mention it or justify it.

> The cost is small: the helpers already disable preemption around most
> of their work, the unwind in bpf_get_stack() and bpf_get_stackid() and
> all of bpf_perf_event_output(); this adds the few instructions around
> it.

This isn't a bug, but is the cost really only a few instructions when build
IDs are requested?

In kernel/bpf/stackmap.c the build ID resolution happens outside the
existing preempt-disabled sections:

__bpf_get_stack():
preempt_enable();

return callchain_finalize(buf, size, trace_nr, elem_size, flags, may_fault);

bpf_get_stackid():
scoped_guard(preempt) { ... }

return stackid_install(&stackid, map, new_bucket, flags);

Both callchain_finalize() and stackid_install() call
stack_map_get_build_id_offset(), which takes mmap_read_trylock() and, for
every frame (up to sysctl_perf_event_max_stack, 127 by default), calls
find_vma() and fetch_build_id().

With this patch, a raw_tp or tracing program calling bpf_get_stack() with
BPF_F_USER_STACK | BPF_F_USER_BUILD_ID, or bpf_get_stackid() on a
BPF_F_STACK_BUILD_ID stack map, now runs that whole build ID resolution
with preemption disabled, where it previously ran preemptibly.

Could the changelog mention the build ID case, or explain why holding the
slot across build ID resolution (which no longer uses regs) is acceptable?


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/43920336669