From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFA953AAF4B for ; Fri, 7 Aug 2026 07:18:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.197 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786087109; cv=none; b=RLvJJq+H0AvrL5wPbXwwfs4k8IQjpDlurC280d5xNOsSQLS8aG6cbCqxIJmhFG8/AFas08thFA24xMow3S5o3pE4CylIzu6pXCte6Co7ZK3cH434bcV9ySLzhK8lgQvoMGbxZ9w0ShjwJd/Q5fi09P70z+6fSlBs3rXvtwsEhjU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786087109; c=relaxed/simple; bh=pR4sKjOg6M5FpHXGSlh8e2AK38K+ESFD8AdmYkYBd4M=; h=Date:Mime-Version:Message-ID:Subject:From:To:Content-Type; b=ET/FtaZE461aFuoWI6lsxixM3i4An+J1GP7+/n0+4/Ol/wF9zULzKagmfqhKj2rXt85N7ZtNZ1yIorEEYgejPIdrqpEQmzf6iA/ncH6TsREsj1UT+qD0UX+xeWWsGsjL3v8e7sUc++WP+duSVWKrb6tuFS0nTbFcjOnwcAcpbH8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=wPbwIsAq; arc=none smtp.client-ip=209.85.215.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="wPbwIsAq" Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-cbe62e01567so2637086a12.2 for ; Fri, 07 Aug 2026 00:18:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1786087106; x=1786691906; darn=vger.kernel.org; h=content-type:to:from:subject:message-id:mime-version:date:from:to :cc:subject:date:message-id:reply-to:content-type; bh=s0uOfK2vBqt76lOjULU8OLFIMTR7IToQpEOfI/OQz2U=; b=wPbwIsAq1I9i9/EPSCfEogdG+KPMbmFkjjX+Wx/Cf5Y1aiyzR+4933wE9Iso2tqlke rpKK1BKUtzlwDQGJibK29YbRyf6KmNgLIWoR/mNlOJsajAOe0MLh3k54kuYW0XjCmfAx yBAyW5qe7XFM3ja+Go8gRelFJTuGaX21WFH9gjSTlUnTh4dG5kuDtihtq9cOhD7c112u XTbrQnYfjmih4Qqu32A1iVvanrslF8kocJEgPt5FiWlXGWZt198ToO6tNfB88aGdDjRp 7Po3wxv0uh8jNOs5Kv2pPNP9bJ76qLxuwp6sBFS3Xh4EpLrFi2DPV5R/oks/1UPKDAbW lmSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786087106; x=1786691906; h=content-type:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=s0uOfK2vBqt76lOjULU8OLFIMTR7IToQpEOfI/OQz2U=; b=DMnBK63f3OMtZBNZ8K835ZarSeB+81SHKY54s5fD34XSoUZOtNhvPFjkQWns+GTQvQ f7hZBYmZnPqWgNDQY4/6SQO2MUlp3m8GHwDtYyE46MAOHl5ptdt/GGvAr9v0x5gHn+rd hYDxQo6KUr4KrQZ+Jz2j9aLNmh1ho44LiBp3xrKkoHWyQiA03CVxUqivDxYaH/VSSzA6 3o5aDBPEZYTIdy0h7vsZY6w2xoZ5dPVOrHNlR0t5VAQQRFeKBqbIrt2WZ+bD2vV31iBt Xmxqhv47u3cHzDWxDHjV7zkdLswesfBEOeOwJ2lCYttndEo+Ev8wdUZPr9XYa6oVCDOR ZIFA== X-Forwarded-Encrypted: i=1; AHgh+RqICyYmsOpE2gQQcrcE8l3H9pfdA97Hmz34v3DvCqR9UWFlCUiDj7mygO9x6mGmexV/ElGNBKB1yKsbM4o=@vger.kernel.org X-Gm-Message-State: AOJu0YwKnT1GkZGFPVkxjzTj5mY8GR6rL3JjNDmi2/kgmRTQfYCb91Ac tCdiIINLWWko97y4On2hMTg6eK1+KfDeN+DDWS7D7yiO1iHSwT8jef5LOEwTyxhnzqPQ8ROv4T+ /myh7dj+pvw== X-Received: from dlbsj11.prod.google.com ([2002:a05:7022:f90b:b0:140:f42f:50e5]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6300:220a:b0:3c4:2cf9:28ad with SMTP id adf61e73a8af0-3cb85e9927amr26857052637.12.1786087105691; Fri, 07 Aug 2026 00:18:25 -0700 (PDT) Date: Fri, 7 Aug 2026 00:18:10 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.55.0.679.g6767b8d81c-goog Message-ID: <20260807071818.718751-1-irogers@google.com> Subject: [RFC PATCH v1 0/8] perf/core, perf/tools: Add PERF_SAMPLE_BUILD_ID_OFFSET support From: Ian Rogers To: Steven Rostedt , Masami Hiramatsu , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Ian Rogers , Adrian Hunter , James Clark , Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , Thomas Gleixner , Dapeng Mi , Ravi Bangoria , Swapnil Sapkal , Thomas Falcon , Thomas Richter , Dmitrii Dolgov <9erthalion6@gmail.com>, Eric Biggers , Zecheng Li , Gabriel Marin , Tengda Wu , Derek Foreman , Tanushree Shah , Ankur Arora , Aaron Tomlin , tanze , Rui Qi , Howard Chu , Chuck Lever , Shimin Guo , Alessio Podda , linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="UTF-8" This patch series introduces PERF_SAMPLE_BUILD_ID_OFFSET to the perf_event UAPI and implements full support across both the kernel and perf tools. Background & Motivation: In order for perf to translate virtual addresses of samples into symbols a file and offset within the file are needed. During event synthesis perf will create mmap events to facilitate the translation of a virtual address to a file and offset by modelling the address space of a process. By directly recording in a sample the Build ID of a file and the offset within it, no synthesis is necessary. The Build ID and offset as a pair are much larger than a virtual address, so there is a trade-off between synthesis cost and extra size for samples. These changes just facilitate Build ID and offset as a choice for perf samples and the user can have the choice to use it when they believe it is advantageous. In practice perf still needs to map a build ID to a file, so by default this change keeps synthesis to allow this. It is expected a user that knows their build IDs, say through debuginfod, will disable this option with say --synth=no. The kernel support uses the existing build ID and offset support used by BPF stack traces. The Build ID and offset samples inherently don't leak ASLR information. As with the ASLR remapping work in perf inject, support is added to migrate virtual addresses to Build ID and offset for the purposes of testing without kernel support. Series Overview: - Patch 1: Factor struct perf_build_id into top-level header structure. - Patch 2: Add PERF_SAMPLE_BUILD_ID_OFFSET to UAPI. - Patch 3: Implement kernel-side sampling support in perf_output_sample() using stack_map_get_build_id_offset(). - Patch 4: Refactor perf tools thread__find_map and symbol lookup APIs to accept struct perf_sample. - Patch 5: Add perf tools internal parsing and symbol resolution via Build ID + offset. - Patch 6: Extend perf inject with --buildid-offset to convert sample files. - Patch 7: Add --buildid-offset option to perf record. - Patch 8: Add unit and shell test coverage (bid-offset test and inject_bid_offset.sh). Testing & Verification: The series was verified using QEMU hypervisor testing with kernel builds and perf test. Linux Plumbers Tracing Miniconference: I submitted a proposal/abstract to talk about these changes to the Tracing Micro Conference at Linux Plumbers Conference 2026 in Prague. Ian Rogers (8): perf event: Factor build_id out into its own top-level struct perf/core: Add BUILD_ID_OFFSET to UAPI perf/core: Implement BUILD_ID_OFFSET sample type perf: Refactor thread map and symbol APIs to take perf_sample perf tools: Internal support for BUILD_ID_OFFSET perf inject: Extend perf inject to support bid_offset conversion perf record: Add --buildid-offset option perf tests: Add build_id_offset test coverage include/linux/bpf.h | 13 + include/uapi/linux/perf_event.h | 4 +- kernel/bpf/stackmap.c | 2 +- kernel/events/core.c | 85 ++- tools/include/uapi/linux/perf_event.h | 30 +- tools/lib/perf/include/perf/event.h | 18 +- .../arch/powerpc/util/skip-callchain-idx.c | 4 +- tools/perf/builtin-inject.c | 23 +- tools/perf/builtin-record.c | 7 + tools/perf/builtin-script.c | 49 +- tools/perf/builtin-timechart.c | 4 +- tools/perf/builtin-trace.c | 12 +- tools/perf/tests/Build | 1 + tools/perf/tests/bid-offset.c | 60 +++ tools/perf/tests/builtin-test.c | 1 + tools/perf/tests/code-reading.c | 4 +- tools/perf/tests/mmap-thread-lookup.c | 45 +- tools/perf/tests/sample-parsing.c | 37 +- tools/perf/tests/shell/inject_bid_offset.sh | 170 ++++++ tools/perf/tests/shell/record.sh | 69 +++ tools/perf/tests/tests.h | 1 + tools/perf/util/Build | 1 + tools/perf/util/annotate-data.c | 5 +- tools/perf/util/aslr.c | 16 +- tools/perf/util/build-id.c | 5 +- tools/perf/util/capstone.c | 4 +- tools/perf/util/cs-etm.c | 4 +- tools/perf/util/data-convert-json.c | 4 +- tools/perf/util/debug.c | 4 +- tools/perf/util/dlfilter.c | 8 +- tools/perf/util/event.c | 93 ++-- tools/perf/util/evsel.c | 35 ++ tools/perf/util/evsel.h | 3 +- tools/perf/util/evsel_fprintf.c | 2 +- tools/perf/util/inject_bid_offset.c | 504 ++++++++++++++++++ tools/perf/util/inject_bid_offset.h | 21 + tools/perf/util/intel-pt.c | 12 +- tools/perf/util/machine.c | 106 ++-- tools/perf/util/maps.c | 29 + tools/perf/util/maps.h | 2 + tools/perf/util/perf_event_attr_fprintf.c | 3 +- tools/perf/util/python.c | 13 +- tools/perf/util/record.h | 1 + tools/perf/util/sample.h | 13 + .../scripting-engines/trace-event-python.c | 20 +- tools/perf/util/synthetic-events.c | 60 ++- tools/perf/util/thread.c | 11 +- tools/perf/util/thread.h | 14 +- tools/perf/util/unwind-libdw.c | 7 +- tools/perf/util/unwind-libunwind.c | 8 +- 50 files changed, 1473 insertions(+), 174 deletions(-) create mode 100644 tools/perf/tests/bid-offset.c create mode 100755 tools/perf/tests/shell/inject_bid_offset.sh create mode 100644 tools/perf/util/inject_bid_offset.c create mode 100644 tools/perf/util/inject_bid_offset.h -- 2.55.0.679.g6767b8d81c-goog