Re: [PATCH v3 03/19] perf/uapi: Add BUILD_ID_OFFSET sample types to UAPI

From: Ian Rogers

Date: Mon Nov 30 2026 - 14:32:59 EST


On Thu, Nov 26, 2026 at 02:06:57PM +0530, Athira Rajeev wrote:
> Thanks Ian, Namhyung, that clears up the non-resolved cases. One follow-up on the callchain form:
>
> Where does the build-ID table live: per sample, or per event?
>
> * If it is per sample, the same binary appearing in many samples gets a table entry in each one.
> Is that duplication acceptable, and is it how the format is meant to work?
>
> * If it is per event, so that common addresses and binaries across samples share one table,
> how does a reader find the table for a given sample? Does the 8-bit index mean at most 255 distinct build-IDs per event? What happens when the table exceeds 255 entries, or when a file offset needs more than 56 bits?
> Do those entries fall back to the unresolved form (raw IP, 0x00 top byte), or does the event fail?

In v3/v4 the build-ID table is per sample (or per
PERF_RECORD_CALLCHAIN_DEFERRED record), so each record is completely
self-contained and can be decoded independently without cross-sample
state. Within a single sample it deduplicates frames from the same
binary, while separate samples do repeat the build IDs they reference.

Because it is per sample, the limit is 254 distinct build IDs per
sample (indices 1..254; 0x00 is unresolved user IP and 0xff is reserved
for PERF_CONTEXT_* markers), which is well above the default
perf_event_max_stack of 127. If a sample exceeds 254 unique build IDs
(or a file offset exceeds 56 bits), the frame falls back to the
unresolved raw user virtual address (0x00 top byte) rather than failing
the event (note: perf inject currently checks offset >> 56 == 0, and
the kernel path should do the same rather than masking).

That said, Peter Zijlstra just pushed back on the per-sample bit-packed
table on the v4 03/19 thread, and Namhyung also raised the idea of a
global/per-session table there -- so this callchain encoding is
actively under discussion on v4 and may change for v5 depending on
where that lands.

Thanks,
Ian