All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] perf: Fix libdw addr2line fallback, pr_debugN overhead, and cumulative hist decay
@ 2026-10-26  6:50 Ian Rogers
  2026-10-26  6:50 ` [PATCH 1/3] perf libdw: Optimize fallback logic for missing DWARF Ian Rogers
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Ian Rogers @ 2026-10-26  6:50 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Namhyung Kim, Alireza Haghdoost,
	Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Jiri Olsa, Adrian Hunter,
	James Clark, Alessio Podda, Michael Liang, Shimin Guo,
	Tanushree Shah, linux-perf-users, linux-kernel

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-10-27 20:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-26  6:50 [PATCH 0/3] perf: Fix libdw addr2line fallback, pr_debugN overhead, and cumulative hist decay Ian Rogers
2026-10-26  6:50 ` [PATCH 1/3] perf libdw: Optimize fallback logic for missing DWARF Ian Rogers
2026-10-26  9:31   ` sashiko-bot
2026-10-26  6:50 ` [PATCH 2/3] perf debug: Avoid calling eprintf() in pr_debugN() when verbose < n Ian Rogers
2026-10-26  9:35   ` sashiko-bot
2026-10-26  6:50 ` [PATCH 3/3] perf hist: Do not delete cumulative caller entries before stat_acc decays Ian Rogers
2026-10-26  9:41   ` sashiko-bot
2026-10-27 20:42 ` [PATCH 0/3] perf: Fix libdw addr2line fallback, pr_debugN overhead, and cumulative hist decay Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.