From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.197 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796078618; b=dYkmJv3Rexi5yQRydaBw2z6aTFG6q2fWGJ+W/eom54ED7sHtQgmOpPLuaw5lGb3Qju9e gB/crwXPXCZG9Okn33FK++VKdU9kwEjzhkaxVSuskmB3J99VTuWWwPLbb9Ao2N+on0gPw 7j+Q0Nc8nUH/tqgiJV9TLaSQTRPHkf6C6azdmMb1rqXyGdkER7Roh83lCZVh4o8vvUQq9 2/mA0OZUN7MpA0nqIrWQ1wGAT1b/32wQdW7iSLB+wBzIil8x6Uc0h5neXUNqc0C/g6zMm NGz5FfPjETrXWDbku8l/1XRcS5kOLPzi7i7N0f4P1isyODSg32AVWhN834/oTumZ7vw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796078618; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:Mime-Version: X-Mailer:Message-ID:Subject:From:To:Cc:Content-Type; bh=ljCwTfC5rDPBC0zSsr5kzXhc/Bzi0NThj91FwqUfTQc=; b=nEJIa+Ep199lJXDQ1uQgDLkFSdNRjdEVrJykl1w7/Nh7BeVxSm1iwHXpu/7Bn/bYQrmw yWi4OCqQDByAHfjv8+JQpJ8d3KAmo8xrgV5DruAnFme6jGxW9AEHtcCVgEX+NfcQohmPl RsSyw9bdq+FmQ57PmmfzkzYjGgj7meZbD4c+qKHpX7ztrroOxUUdEVi4Bx6aDFspAzsod i+t+Nqu7uM4hM3hS0QgrxwMe9M2Av5SmkyugrqkX4pRYWUKPJ01IZgU26HtJYB+VR93g3 BPOxJSgG1KQRAJI+tyhtzK4y8RnPnyc80hievoIVAzinXTBtYOjicrQCBSZghJGz8Cg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=Gi41KAP4; arc=none smtp.remote-ip=74.125.82.197 Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85CC9606A31A for ; Mon, 30 Nov 2026 22:43:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 85CC9606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=Gi41KAP4 Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-33713e5e6daso16455259eec.0 for ; Mon, 30 Nov 2026 14:43:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796078618; x=1796683418; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ljCwTfC5rDPBC0zSsr5kzXhc/Bzi0NThj91FwqUfTQc=; b=Gi41KAP4bgS/aMqopEhfLMIZ0nPesOWTJHcP4SEPNihfClEK/9aBUNnjCPSPPBfcm4 kDUqFpyWeb2ToOnxn/tfUb+C+oc7D4rAR5rWc3ae1oVN4SQtHVGOLifqrzIChlSK55d8 M9A+QEING9OxPCKjG1fWBOGXT5xAvsydqrrBHJM2aS5R5sCbiNh6gQE9ns5Ns1fHX4st GZPrQ9RxeO+t1oW8LOHpS/i4BpDRU2d9RXUpOPy2hZVdAMaFUx8Q+TQfjfiuMu+H1jDV R2FBUu6RZtn/DA70cM6P4mu373z0jGSRrw7PVjAgP4RLWsINzAbXNmI8jKl524PUZqZt Wzdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796078618; x=1796683418; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ljCwTfC5rDPBC0zSsr5kzXhc/Bzi0NThj91FwqUfTQc=; b=Fbs4cenoK4CYGOCAErfDu3PgdTEXQored1DXW1TvyurvUiaesNo0mXBBlEnqLx8GIP D4tk9artNtwgntG4TYfM90UGAWoZfGLtTFJub41JqL4jR9jgsgWaNQCouhrC/P3mu4bm Aa19PnwSEW5jzxDp6PBRbhXQ5JulX3MOm4foZwC35nJWiEDk0iXcZSnivCbAXBUiliZS mapAbyHF++DeO/NOeY1D/PeGfNZ+XNFo9NwzeXLAztnS51/+SsB+lePyQJddJuh9o3MT AmaLNU1vmBFumr3O6Q3NplvhZaSU8CIIrlA7xLZCzYI5efu2w79Z+BK2Hf1iMi57wZVx NujQ== X-Forwarded-Encrypted: i=1; AL+hErG3ruD8Fi7LpVyMSsdCfXsTEaibhIz43x1FVG+1b2gEmBtjD9O9oAsUfV+2S3TZnfEk9QMQTlxP0DRH3k4=@vger.kernel.org X-Gm-Message-State: APuU4Z8rMmigkBgwChJ8h8Kr23x+u0ADqdcjwavOrN8D6ez8oMpBgnXN tPttUSrDcC7d3FCCAyaBzMIrP6lZfX2bLEZI8wKgIielLFlFBDWyUUvPEkpvnwMrzLp8CkJtx+B IzCNcGI7XqQ== X-Received: from dybqf1.prod.google.com ([2002:a05:7301:6481:b0:386:a9a2:8031]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:693c:4143:10b0:36a:1f4f:3e9 with SMTP id 5a478bee46e88-386b1067bf5mr28802405eec.20.1796078617235; Mon, 30 Nov 2026 14:43:37 -0800 (PST) Date: Mon, 30 Nov 2026 14:43:28 -0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 X-Mailer: git-send-email 2.56.1.839.g22a8290db9-goog Message-ID: <20261130224332.79575-1-irogers@google.com> Subject: [PATCH v2 0/4] perf tools: Fix thread cache race, stat per-pkg delta bug, and memory leaks From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim Cc: Jiri Olsa , Adrian Hunter , James Clark , Ian Rogers , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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 () 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