mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/4] perf tools: Fix thread cache race, stat per-pkg delta bug, and memory leaks
@ 2026-11-30 22:43 Ian Rogers
  2026-11-30 22:43 ` [PATCH v2 1/4] perf threads: Don't resurrect removed threads in last_match Ian Rogers
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Ian Rogers @ 2026-11-30 22:43 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim
  Cc: Jiri Olsa, Adrian Hunter, James Clark, Ian Rogers,
	linux-perf-users, linux-kernel

Four standalone bug fixes for pre-existing issues in perf tools uncovered
during Sashiko review:

1. util/threads.c: Fix a race between threads__find() and
   threads__remove() where dropping table->lock between lookup and
   updating table->last_match could resurrect a removed thread in
   last_match (and avoid taking down_write(&table->lock) on last_match
   cache hits).
2. util/stat.c: Fix process_counter_values() on skipped per-pkg secondary
   CPUs: compute interval deltas before check_per_pkg() so prev_raw_counts
   and interval ena/run are accurate, remove the static zero struct, and
   return 0 when skip is true so non-global aggregation modes (such as
   --per-socket and --per-die) do not mark ps_aggr failed (<not counted>)
   or inflate ps_aggr->nr.
3. util/metricgroup.c: Fix realloc() failure memory leaks of pending in
   resolve_metric() and root_metric->metric_refs in __add_metric().
4. util/pmu.c: Free alias on parse_double() and io__getline() error
   returns in perf_pmu__new_alias().

Changes in v2:
- Rebase onto perf-tools-next (419442c00c66).
- Patch 2: Return 0 immediately from process_counter_values() when skip
  is true (after computing interval deltas before check_per_pkg()) instead
  of falling through with a zeroed count struct, which caused
  evsel__count_has_error() in non-global aggregation modes (e.g.
  --per-socket, --per-die) to wipe out the primary CPU's package count,
  mark ps_aggr->failed, and increment ps_aggr->nr (Sashiko).

v1: https://lore.kernel.org/linux-perf-users/20261118075516.1278903-1-irogers@google.com/

AI Assistance Disclosure (per Documentation/process/coding-assistants.rst
and Documentation/process/generated-content.rst):
- Tools used: Sashiko automated patch review (sashiko.dev) for bug
  detection, and Google Antigravity / Jetski coding assistant for root
  cause verification and patch drafting.
- Summary of prompts and assistance: Verified pre-existing issues flagged
  by Sashiko during review of the perf generic hashmap series and prepared
  standalone fixes with Fixes tags against perf-tools-next.
- Testing performed: Built on perf-tools-next (419442c00c66) with GCC
  (-DREFCNT_CHECKING=1) and Clang (BUILD_NONDISTRO=1, including
  -Wthread-safety context analysis); verified per-pkg aggregation and
  interval deltas across AGGR_GLOBAL and AGGR_SOCKET; ran perf test and
  scripts/checkpatch.pl.

Ian Rogers (4):
  perf threads: Don't resurrect removed threads in last_match
  perf stat: Skip per-pkg secondary CPUs after computing deltas
  perf metricgroup: Fix realloc() leaks in resolve_metric() and
    __add_metric()
  perf pmu: Free alias on error paths in perf_pmu__new_alias()

 tools/perf/util/metricgroup.c | 19 +++++++++++++------
 tools/perf/util/pmu.c         |  5 ++++-
 tools/perf/util/stat.c        |  9 ++++-----
 tools/perf/util/threads.c     | 16 +++++++++++-----
 4 files changed, 32 insertions(+), 17 deletions(-)


base-commit: 419442c00c667d33e27db4fef9733fa966e6a149
-- 
2.56.1.839.g22a8290db9-goog


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

end of thread, other threads:[~2026-11-30 22:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30 22:43 [PATCH v2 0/4] perf tools: Fix thread cache race, stat per-pkg delta bug, and memory leaks Ian Rogers
2026-11-30 22:43 ` [PATCH v2 1/4] perf threads: Don't resurrect removed threads in last_match Ian Rogers
2026-11-30 22:43 ` [PATCH v2 2/4] perf stat: Skip per-pkg secondary CPUs after computing deltas Ian Rogers
2026-11-30 22:43 ` [PATCH v2 3/4] perf metricgroup: Fix realloc() leaks in resolve_metric() and __add_metric() Ian Rogers
2026-11-30 22:43 ` [PATCH v2 4/4] perf pmu: Free alias on error paths in perf_pmu__new_alias() Ian Rogers

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®