Re: [PATCH v4 03/19] perf/uapi: Add BUILD_ID_OFFSET sample types to UAPI
From: Ian Rogers
Date: Mon Nov 30 2026 - 14:39:00 EST
On Wed, Nov 25, 2026 at 01:45:32PM -0800, Namhyung Kim wrote:
> On Wed, Nov 25, 2026 at 02:25:12PM +0100, Peter Zijlstra wrote:
> > > 64-bit offsets whose top 8 bits encode the 1-based build ID index (or
> > > 0x00 for unresolved user addresses and 0xff for kernel/context entries).
> > > In common cases where multiple callchain frames belong to the same
> > > binary, each unique build ID is encoded only once.
> >
> > Why ?!? This is insane
>
> This is basically to save space for callchains. When multiple entries
> fall into the same binary, it can have a table of binaries/build-ids
> and use indices instead of repeating full build-id for each entry.
>
> It'd be great if it could have a global (or per-session) table. This is
> a per-sample table. Please let us know if you have a better idea.
For context on how we arrived here: in v1/v2 each callchain frame was
simply a fixed 32-byte { struct perf_build_id bid; u64 offset; } entry
(4x larger than raw u64 IPs, ~4 KiB for a 127-frame stack). The
per-sample table + 8-bit index in v3/v4 was an attempt to cut that size
overhead while keeping each sample self-contained.
Fair enough if the bit-packing / per-sample table complexity is too
ugly for UAPI. Before spinning v5, what direction would you prefer?
Some alternatives:
1. Simple fixed-size entries per frame (no table, no bit-packing):
back to { struct perf_build_id bid; u64 offset; } per entry, trading
extra ring-buffer bytes for a trivial UAPI and kernel path.
2. Per-sample table without bit-packing into offsets: e.g. fixed
struct perf_build_id build_ids[nr_build_ids] plus explicit
{ u64 offset; u32 bid_idx; u32 reserved; } (or separate u8/u16
index array) so 64-bit offsets/addresses stay untouched.
3. A session/ring-buffer sideband record (e.g. assigning a monotonic
ID per build ID when first encountered, or emitting a build-ID table
record) so samples only carry { id, offset } instead of repeating
20-byte build IDs across samples.
Which aspect is the main objection here -- the 8-bit/56-bit packing,
the per-sample deduplication in the kernel, or repeating build IDs per
sample instead of a sideband mapping?
Thanks,
Ian