From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f73.google.com (mail-dl1-f73.google.com [74.125.82.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2AD52AD0C for ; Tue, 10 Feb 2026 06:04:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770703445; cv=none; b=ns2899z6DzEtZWytNNOazmVBNMKcdTN7QTX+X7T4LMX9Uv4toQCNNXMYPoo60YHzgp9javLqg95lI8qzwnutWDIQldaBMEy/lB2QB21zMieAw0uzE/cR/YgLBrEq0r7RVdvbo9FeaCzkRlP/YQREBC3oSUOfXNBW/C9932CKQaM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770703445; c=relaxed/simple; bh=Zfybov18wp+XKF9zfziT3A7XQ8Rz6pik8UZSDbDPmuE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=CCwkEemAsVFmIM/xy7+rHm1VIbfKv/iPJs1eL7j5Y0dBm46/T3lH+lbeYQSOdQPdytbZ/r2ffYigwq9ZhTT+2wQhucSDIl74diABLJ5J0Vu5EmmorZ+jAkmKQeL0S1sxMgsP+vVU6loh5u6+Q5OgzSXESBx8n2lJ4etVNrJ8qC8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=pWNw8eDs; arc=none smtp.client-ip=74.125.82.73 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.b="pWNw8eDs" Received: by mail-dl1-f73.google.com with SMTP id a92af1059eb24-1233b81a92dso5535278c88.0 for ; Mon, 09 Feb 2026 22:04:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1770703444; x=1771308244; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=V+3dGOJiTRqCZMxIxulRVBleFQcYgURizALb+zOiPC8=; b=pWNw8eDsuTlTliALWNl2REPeb4SOEF7BKvFhs9tKom9IArChzr6sJKju4cI/VAuss+ zPUnSxzrRl50X4xgNEvM29qYid9RJgXPxv2Kjpgn/5lIGCQx7jaxgv8/V2VPpH3cn+Ts 76AIKeYA+1trrP4TmEGxiOAHovLiGIh7PFA0gyl3i0j4KFlTkPH75XDrlSf+/HeMoQmW BDKRsgckTfVEW1joo9NSvgmJ2N4SMUAjUTthQbywvik1xULnNw/z3O2rvvn4ZAzNDc98 2qTrbNtTpqogmEw+VyhWXVJx1yMyLW/y/YwIxhPgsTbaAwbrN/TH1B/OeQDiKB5XixFO w62w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770703444; x=1771308244; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=V+3dGOJiTRqCZMxIxulRVBleFQcYgURizALb+zOiPC8=; b=S4xE/6emqNnwPIklQBj/cviSYu9e/xer0aoAz2Hr8vqpFgx6J6CN/0kG43XO2GRVe5 CMutJPWLtD2SDnn4RX7EVieX9CdckpBz1uUxhhEsG8L4Cqrtli7AfhrbkLAmWFl5ujUG fADWEl0nzAlFYCY2gAuIFW9pzpFkRjdgGlvzKLXdG0guFOLTvO4JElNg+VR8Td7lHddZ OQfo1+hXk3HDcUbUro1tz5viE6PUArwJ3zqCamgIzsHm/+QRio25H2CbI6llKFMdrDlg LnXFKi9iL7znaBslYCsQNHGBKOckkqTO/YvkLTXObmZw2ooF/P+qR4FovM9YJjSdCGRa rHrg== X-Forwarded-Encrypted: i=1; AJvYcCWAp3csfWuS9QyH96T1qFYDFVOWNPmtrS+Sy8ZC8r0eGj8dscIxVSG13xiWUXv7H/8ZxcYWURhckPmZxEut6One@vger.kernel.org X-Gm-Message-State: AOJu0Yysi/UNKzoub8yzU8Us7CJxm0tKKkt5wMYkV7jB5K64vz0fMF6F QZ6xDBUZeKF/1LFSIOJrTmuGODY9qF3y4VNbz5Hs/o+7WgnLs0B8I1LyCw0aib6UalqOEyvDGj9 3aVpuej1xQw== X-Received: from dlcip7.prod.google.com ([2002:a05:7023:c087:b0:124:9d31:3581]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:2521:b0:119:e569:f865 with SMTP id a92af1059eb24-127240d1f38mr430946c88.2.1770703443677; Mon, 09 Feb 2026 22:04:03 -0800 (PST) Date: Mon, 9 Feb 2026 22:03:53 -0800 In-Reply-To: Precedence: bulk X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.53.0.rc2.204.g2597b5adb4-goog Message-ID: <20260210060359.2233425-1-irogers@google.com> Subject: [PATCH v9 0/6] perf stat affinity changes From: Ian Rogers To: namhyung@kernel.org, acme@kernel.org Cc: adrian.hunter@intel.com, ak@linux.intel.com, alexander.shishkin@linux.intel.com, andres@anarazel.de, dapeng1.mi@linux.intel.com, irogers@google.com, james.clark@linaro.org, jolsa@kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux@treblig.org, mingo@redhat.com, peterz@infradead.org, thomas.falcon@intel.com, tmricht@linux.ibm.com, yang.lee@linux.alibaba.com Content-Type: text/plain; charset="UTF-8" Change how affinities work with evlist__for_each_cpu. Move the affinity code into the iterator to simplify setting it up. Detect when affinities will and won't be profitable, for example a tool event and a regular perf event (or read group) may face less delay from a single IPI for the event read than from a call to sched_setaffinity. Add a --no-affinity flag to perf stat to allow affinities to be disabled. v9: Fix command line comment for --affinity (Arnaldo, Namhyung) v8: Rebase, due to minor conflict with: https://lore.kernel.org/lkml/20260203230733.1474840-1-ctshao@google.com/ https://lore.kernel.org/lkml/20260206222509.982489-1-irogers@google.com/ v7: Revert "perf tool_pmu: More accurately set the cpus for tool events" that caused issues with user specified CPUs (Andres Freund ). Fix a null test is prepare_metric so that missing events can't trigger segfaults (Andres Freund). Make the CPU map propagation improve the CPU maps for tool events that only read on index 0, this allows later setting when evlist__create_maps is called with the correct user CPUs. Rebase previous non-merged affinity changes that hadn't been picked up yet. https://lore.kernel.org/lkml/20260203225129.4077140-1-irogers@google.com/ v6: Drop merged tool event change. Move TPEBS fix into its own patch 1st. https://lore.kernel.org/lkml/20260108212652.768875-1-irogers@google.com/ v5: Drop merged changes. Move tool event reading to first patch. Change --no-affinity flag to --affinity/--no-affinity flag. https://lore.kernel.org/lkml/20251118211326.1840989-1-irogers@google.com/ On v5 there was discussion with Andi Kleen who points out that affinities will work better with real time priorities but using this requires privileges. v4: Rebase. Add patch to reduce scope of walltime_nsec_stats now that the legacy metric code is no more. Minor tweak to the ru_stats clean up. https://lore.kernel.org/lkml/20251113180517.44096-1-irogers@google.com/ v3: Add affinity clean ups and read tool events last. https://lore.kernel.org/lkml/20251106071241.141234-1-irogers@google.com/ v2: Fixed an aggregation index issue: https://lore.kernel.org/lkml/20251104234148.3103176-2-irogers@google.com/ v1: https://lore.kernel.org/lkml/20251104053449.1208800-1-irogers@google.com/ Ian Rogers (6): Revert "perf tool_pmu: More accurately set the cpus for tool events" perf stat-shadow: In prepare_metric fix guard on reading NULL perf_stat_evsel perf evlist: Special map propagation for tool events that read on 1 CPU perf evlist: Missing TPEBS close in evlist__close perf evlist: Reduce affinity use and move into iterator, fix no affinity perf stat: Add no-affinity flag tools/lib/perf/evlist.c | 36 +++++- tools/lib/perf/include/internal/evsel.h | 2 + tools/perf/Documentation/perf-stat.txt | 5 + tools/perf/builtin-stat.c | 114 ++++++++--------- tools/perf/util/evlist.c | 156 +++++++++++++++--------- tools/perf/util/evlist.h | 27 ++-- tools/perf/util/parse-events.c | 10 +- tools/perf/util/pmu.c | 23 ++++ tools/perf/util/pmu.h | 3 + tools/perf/util/stat-shadow.c | 24 ++-- tools/perf/util/tool_pmu.c | 19 --- tools/perf/util/tool_pmu.h | 1 - 12 files changed, 250 insertions(+), 170 deletions(-) -- 2.53.0.rc2.204.g2597b5adb4-goog