From: Ian Rogers <irogers@google.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Alireza Haghdoost <haghdoost@uber.com>,
Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
Alessio Podda <aleph.pi.gh@gmail.com>,
Michael Liang <mliang@purestorage.com>,
Shimin Guo <shimin.guo@skydio.com>,
Tanushree Shah <tshah@linux.ibm.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 0/3] perf: Fix libdw addr2line fallback, pr_debugN overhead, and cumulative hist decay
Date: Sun, 25 Oct 2026 23:50:42 -0700 [thread overview]
Message-ID: <cover.1792995775.git.irogers@google.com> (raw)
Three standalone fixes found while profiling `perf top` and DSO symbol/DWARF
resolution:
1. **perf libdw: Optimize fallback logic for missing DWARF**:
`libdw__addr2line()` previously returned `-1` when `dwfl_module_getdwarf()`
or `dwfl_module_getsrc()` returned `NULL`, while `addr2line()` in
`srcline.c` only stopped its fallback loop on `ret > 0`. This caused
`perf` to fall back through `llvm`, `libbfd`, and the external
`addr2line` subprocess on every stripped DSO or unmapped address, and
kept the `Dwfl` ELF mmap open on stripped binaries. Standardize backend
return values so `0` denotes conclusively missing DWARF/line info
(stopping the fallback loop and freeing the `Dwfl` session when no
DWARF exists), `< 0` denotes backend/initialization error, and `> 0`
denotes resolved source line info.
An earlier version of this patch was posted at:
https://lore.kernel.org/linux-perf-users/20260824062841.1529489-3-irogers@google.com/
This version addresses the review feedback from that thread.
2. **perf debug: Avoid calling eprintf() in pr_debugN() when verbose < n**:
`pr_debugN()` unconditionally evaluated its arguments and called
`eprintf()` -> `veprintf()` before checking `verbose >= n`, accounting
for ~15% of total CPU time in `perf top` during ELF symbol loading even
at default `verbose == 0`. Guard `eprintf()` with `unlikely(verbose >= (n))`.
3. **perf hist: Do not delete cumulative caller entries before stat_acc decays**:
When `symbol_conf.cumulate_callchain` is enabled (`perf top -g`),
callchain caller entries with `he->stat.period == 0` were deleted on the
first `hists__decay_entries()` pass even while `he->stat_acc->period > 0`.
Require `he->stat_acc->period == 0` before deleting entries in
cumulative mode.
Assisted-by: Antigravity:gemini-3.1-pro
Ian Rogers (3):
perf libdw: Optimize fallback logic for missing DWARF
perf debug: Avoid calling eprintf() in pr_debugN() when verbose < n
perf hist: Do not delete cumulative caller entries before stat_acc
decays
tools/perf/tests/pmu-events.c | 5 ++-
tools/perf/util/addr2line.c | 28 ++++++++++---
tools/perf/util/debug.h | 5 +--
tools/perf/util/dso.h | 2 +-
tools/perf/util/hist.c | 6 ++-
tools/perf/util/libbfd.c | 6 +--
tools/perf/util/libdw.c | 25 ++++++++---
tools/perf/util/libdw.h | 5 ++-
tools/perf/util/llvm-c-helpers.cpp | 66 +++++++++++++++++++-----------
tools/perf/util/llvm.c | 12 ++++--
tools/perf/util/srcline.c | 21 +++++++---
11 files changed, 125 insertions(+), 56 deletions(-)
--
2.56.0.307.g5fe7bd680c-goog
next reply other threads:[~2026-10-26 6:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-26 6:50 Ian Rogers [this message]
2026-10-26 6:50 ` [PATCH 1/3] perf libdw: Optimize fallback logic for missing DWARF Ian Rogers
2026-10-26 6:50 ` [PATCH 2/3] perf debug: Avoid calling eprintf() in pr_debugN() when verbose < n Ian Rogers
2026-10-26 6:50 ` [PATCH 3/3] perf hist: Do not delete cumulative caller entries before stat_acc decays 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=cover.1792995775.git.irogers@google.com \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=aleph.pi.gh@gmail.com \
--cc=haghdoost@uber.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=mliang@purestorage.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=shimin.guo@skydio.com \
--cc=tshah@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®