From: Ian Rogers <irogers@google.com>
To: irogers@google.com
Cc: acme@kernel.org, adrian.hunter@intel.com, james.clark@linaro.org,
jolsa@kernel.org, linux-kernel@vger.kernel.org,
linux-perf-users@vger.kernel.org, mingo@redhat.com,
namhyung@kernel.org, peterz@infradead.org,
tmricht@linux.ibm.com
Subject: [PATCH v2 0/3] perf srcline: Fix addr2line cache and fallback bugs
Date: Tue, 15 Sep 2026 23:35:42 -0700 [thread overview]
Message-ID: <20260916063545.3103314-1-irogers@google.com> (raw)
In-Reply-To: <20260914170759.1992947-1-irogers@google.com>
Three fixes to source line resolution, all on the addr2line paths.
1) libdw is pointed at the wrong file. dso__libdw_dwfl() opens the Dwfl
with the name of the file the samples came from, but when the debug
information is in a separate file, symbol loading records that as the
dso's symsrc filename and the Dwfl is left referring to a file with
no DWARF in it.
2) The dso addr2line cache is shared between implementations. The libbfd
reader caches a struct a2l_data and the command line fallback caches
a struct child_process through the same pointer, so once a dso has
fallen back from one to the other the cached object is read back as
the wrong type.
3) libbfd only reports success when the caller asked for a file name.
addr2inlines() doesn't, so srcline.c treats a resolved address as a
failure and tries the next implementation, which appends its own
frames to the ones libbfd already appended. Every frame that isn't
inlined is then reported twice. This is the default when perf is
built with libbfd but without libdw:
$ perf record --call-graph dwarf -- perf test -w inlineloop 1
$ perf script --fields +srcline
...
56051a99503a inlineloop+0x8a (perf)
inlineloop.c:47
56051a99503a inlineloop+0x8a (perf)
inlineloop.c:47
...
With addr2line.style set to "libbfd,addr2line" so the fallback is
taken, the script output for that workload drops from 288 lines to
176, and each repeated frame goes from appearing 16 times to 8.
Changes in v2:
- Add patch 3, so that a resolved address isn't retried by the next
addr2line implementation and reported twice.
- Patch 1: rewrite the commit message to describe the wrong file the
Dwfl is opened with, which is the actual bug, rather than the cache
teardown that follows from it, and add the Fixes tag.
- Rebase onto perf-tools-next.
This series is independent of "perf build: Fix builds with clang and
BUILD_NONDISTRO" posted earlier and applies with or without it.
Testing:
- "perf test addr2line" and the hists tests pass.
- Builds in 13 configurations, including BUILD_NONDISTRO=1 where the
libbfd reader is actually compiled, and with clang and gcc.
- Every patch builds on its own, so the series stays bisectable.
Ian Rogers (3):
perf libdw: Fix Dwfl discovery with split files
perf dso: Separate libbfd and cmd addr2line caches to fix confusion
perf libbfd: Report success when an address is found
.../arch/powerpc/util/skip-callchain-idx.c | 4 +-
tools/perf/util/addr2line.c | 35 ++++++++---
tools/perf/util/dso.c | 58 +++++++++++------
tools/perf/util/dso.h | 26 ++++++--
tools/perf/util/libbfd.c | 52 ++++++++++-----
tools/perf/util/libdw.c | 39 ++++++++----
tools/perf/util/srcline.c | 63 +++++++++++++------
tools/perf/util/unwind-libdw.c | 2 +
tools/perf/util/unwind-libunwind.c | 62 +++++++++++++-----
9 files changed, 245 insertions(+), 96 deletions(-)
base-commit: 91b0782fc9e9d2f0a40b5256146e014802fdbb36
prerequisite-patch-id: b6fdc526887b71fb66f5fe0c0d41f7ef9493861e
prerequisite-patch-id: d47077f674c700f4f6296e9367f7ddfe004aea89
prerequisite-patch-id: ed0db23450840601762fe85ca1bef06ce6d28fe7
prerequisite-patch-id: d84e6b96d533ee6ed549e26e94216e2da60f7f74
prerequisite-patch-id: 6e8f19551d771621a5037096626cfe7e271b36f9
prerequisite-patch-id: 3768dfd588c7439deb741bce44c74763011c6be7
prerequisite-patch-id: babac99a4faa3b1525e44d3f34ab33a88103334c
prerequisite-patch-id: 5279827453fea1536abc620aa33c887c44e41ee9
prerequisite-patch-id: bdc0d648a577142b9270fb59b54496bc2bf8d5ea
--
2.55.0.1032.g73a4cd73de-goog
next prev parent reply other threads:[~2026-09-16 6:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 17:07 [PATCH v1 1/2] perf libdw: Fix Dwfl discovery with split files Ian Rogers
2026-09-14 17:07 ` [PATCH v1 2/2] perf dso: Separate libbfd and cmd addr2line caches to fix confusion Ian Rogers
2026-09-16 6:35 ` Ian Rogers [this message]
2026-09-16 6:35 ` [PATCH v2 1/3] perf libdw: Fix Dwfl discovery with split files Ian Rogers
2026-09-16 6:35 ` [PATCH v2 2/3] perf dso: Separate libbfd and cmd addr2line caches to fix confusion Ian Rogers
2026-09-16 6:35 ` [PATCH v2 3/3] perf libbfd: Report success when an address is found Ian Rogers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260916063545.3103314-1-irogers@google.com \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=tmricht@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®