From: Michael Liang <mliang@purestorage.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Michael Liang <mliang@purestorage.com>
Subject: [PATCH 0/1] perf libdw: fix outer-frame name and spurious "(inlined)" tag
Date: Tue, 28 Jul 2026 14:42:14 -0600 [thread overview]
Message-ID: <20260728204215.327318-1-mliang@purestorage.com> (raw)
When perf is built with libdw support, addr2line uses libdw and
cu_walk_functions_at() walks the containing DW_TAG_subprogram DIE
plus every DW_TAG_inlined_subroutine DIE at the sample address. The
libdw_a2l_cb() callback treated the outer subprogram DIE the same
way as inlined subroutines, causing two bugs on the outer frame:
1. C++ frames lost their namespace/class qualification, because
die_name() returns the unqualified DW_AT_name -- so
ns::Class::method rendered as method.
2. Any DWARF-vs-ELF name mismatch on the outer frame tripped
new_inline_sym()'s fallback path, which fabricates a fake
symbol tagged "(inlined)". This hit C++ (die_name()'s
unqualified string never matched the demangled ELF symbol)
*and* it hit C functions renamed by GCC IPA-clone (foo vs
foo.isra.0 / .constprop / .part / .cold), since
DW_AT_linkage_name doesn't reflect those renames either.
The patch does two things:
* Prefer die_get_linkage_name() (mangled, fully qualified),
falling back to die_name() when absent (C, extern "C").
new_inline_sym() already demangles via dso__demangle_sym().
* For the outer DW_TAG_subprogram DIE, use base_sym directly --
the DIE tag already tells us it is the outer function, so we
skip the name comparison entirely for both C++ qualification
and IPA-clone renames.
Testing
=======
Reproduced with a small C++ program that exercises both a
non-inline namespaced class method (which GCC also IPA-SRA-clones
into a .isra.0 symbol) and an always_inline helper:
namespace demo {
static volatile std::uint64_t sink;
class Worker {
public:
__attribute__((noinline))
void run_one_io_task(std::uint64_t seed) {
std::uint64_t x = seed;
for (int i = 0; i < 400000; ++i)
x = x * 2862933555777941757ULL + 3037000493ULL;
sink = x;
}
__attribute__((always_inline))
inline void spin(std::uint64_t seed) {
std::uint64_t x = seed;
for (int i = 0; i < 300000; ++i)
x = x * 3935559000370003845ULL + 2691343689449507681ULL;
sink = x;
}
};
} // namespace demo
int main() {
demo::Worker w;
for (int i = 0; i < 400; ++i) {
w.run_one_io_task(i);
w.spin(i ^ 0xa5a5a5a5a5a5a5a5ULL);
}
}
Build:
g++ -O2 -g -fno-omit-frame-pointer demo.cpp -o demo
Then:
perf record -g -F 999 -- ./demo
perf script | head
On unpatched perf, every C++ frame comes out unqualified and tagged
"(inlined)" -- including the outer IPA-cloned frame:
run_one_io_task+0x24 (inlined) [WRONG: unqualified, not inlined]
spin+0x40 (inlined) [WRONG: unqualified]
With this patch:
demo::Worker::run_one_io_task(unsigned long) [clone .isra.0]+0x24
demo::Worker::spin(unsigned long)+0x40 (inlined) [true inline]
The outer frame is fully qualified and no longer carries a spurious
"(inlined)" tag; the truly-inlined helper stays correctly tagged.
The same mis-tagging behavior is reproducible in pure C by taking
any function GCC IPA-clones (e.g. a static helper that gets .isra
/ .constprop applied) -- unpatched perf tags the outer frame
"(inlined)"; with the patch it renders as the base symbol.
Michael Liang (1):
perf libdw: Fix outer-frame name resolution and spurious "(inlined)"
tag
tools/perf/util/libdw.c | 34 ++++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)
--
2.34.1
next reply other threads:[~2026-07-28 20:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 20:42 Michael Liang [this message]
2026-07-28 20:42 ` [PATCH 1/1] perf libdw: Fix outer-frame name resolution and spurious "(inlined)" tag Michael Liang
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=20260728204215.327318-1-mliang@purestorage.com \
--to=mliang@purestorage.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/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