Re: [PATCH bpf-next] tracing: Make per-template BTF id lists file-local
Mykyta Yatsenko <[email protected]> Thu, 30 Jul 2026 14:48:25 +0100
| Newsgroups | dev.linux.lists.sashiko-reviews,org.kernel.vger.bpf |
|---|---|
| Message-ID | <[email protected]> |
On 7/30/26 2:03 PM, [email protected] wrote: > Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: > - [Medium] Using `BTF_ID_LIST()` instead of `BTF_ID_LIST_GLOBAL()` for tracepoint classes introduces significant BSS memory bloat when `CONFIG_DEBUG_INFO_BTF` is disabled. > -- > > --- Patch [1]: [PATCH bpf-next] tracing: Make per-template BTF id lists file-local --- > commit 49d7faf72ef8695ae45768a193f5a09e2cfe872d > Author: Mykyta Yatsenko <[email protected]> > > tracing: Make per-template BTF id lists file-local > > This commit converts trace event BTF id lists from global to file-local to > avoid symbol clashes when multiple translation units instantiate the same > class. It also explicitly provides local BTF id lists for handcrafted syscall > events. > > Link: https://lore.kernel.org/all/[email protected]/ > >> diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h >> index 09ad57ac4b73e..45ffbe04b5805 100644 >> --- a/include/trace/trace_events.h >> +++ b/include/trace/trace_events.h >> @@ -404,10 +404,12 @@ static inline notrace int trace_event_get_offsets_##call( \ >> * [0] FUNC __bpf_trace_<call> (the BPF dispatcher) >> * [1] STRUCT trace_event_raw_<call> (the ring-buffer record) >> * Exposed via the events/<sys>/<name>/btf_ids tracefs file. >> + * >> + * File-local: the class name is not unique, so a global symbol would >> + * clash across translation units. >> */ >> #define _TRACE_BTF_IDS_DECLARE(call) \ >> - extern u32 __bpf_trace_btf_ids_##call[]; \ >> - BTF_ID_LIST_GLOBAL(__bpf_trace_btf_ids_##call, 2) \ >> + BTF_ID_LIST(__bpf_trace_btf_ids_##call) \ >> BTF_ID(func, __bpf_trace_##call) \ >> BTF_ID(struct, trace_event_raw_##call) > > [Severity: Medium] > Does changing this to BTF_ID_LIST() introduce significant BSS memory bloat > when CONFIG_DEBUG_INFO_BTF is disabled? > > When CONFIG_DEBUG_INFO_BTF is disabled, the fallback for BTF_ID_LIST is > defined as: > > include/linux/btf_ids.h: > #define BTF_ID_LIST(name) static u32 __maybe_unused name[128]; > > BTF_ID_LIST_GLOBAL(..., 2) only allocated 2 elements (8 bytes), but this > fallback statically allocates a 128-element u32 array (512 bytes) per > instance. > > Because _TRACE_BTF_IDS_DECLARE is instantiated via DECLARE_EVENT_CLASS for > over a thousand trace event classes across the kernel, this seems to silently > add roughly 750 KB of wasted BSS memory. > I'll follow up on this