From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (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 B22AB29BDBF for ; Tue, 10 Feb 2026 06:04:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770703446; cv=none; b=YoiHb75Xc+LZeCWDcFIb/pNE6IL+70QrH3gL3MvttsxAT3gNGX3qSQiTnRaHbx6jegoF/TEfC84kPpfntVWSg7wvaVvNcaQq+aob+1GDQxWhAaUcGj9mkN/NrDj/ZQS5r4IQlNzFHsNiI4d6ahqLQ3ATuQnN2lFdKzyYF5W57/M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770703446; c=relaxed/simple; bh=Zfybov18wp+XKF9zfziT3A7XQ8Rz6pik8UZSDbDPmuE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=F6v3mKdrjvLGo1CplW2MHp3sFq1pmUEOxO8lrm35qthpNooyg1YoOdRaTa2XW6DK5WSLizg/av/md8z/SF21saTRhL2H1VxZb838qENspMdLkkBcJ4I1ZXjdWtDIRNaCa1duovRQ6BcE1Ane9PosWGeeRB3N1tAUH9D8+y/Dec8= 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.74 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-f74.google.com with SMTP id a92af1059eb24-1233b81a92dso5535277c88.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=NsLULpX3kNGuKd+uanhPTjiuKrAvXB9u1dN4cLwINWdUy3r79xFPeo1f4xQPFzu5p1 IC5Om0Qj6Db/2CbtKDPpYwocH8RoDh1dObonz3TDdzqjA9zb9T2j/ZmRddt0NSzsJ+19 BXlUWBn62chuowxGj2AC9PmYE3myHCCrUeWFbb2hG8KbncxWi2Fp1c5eHC6bNemY3jwJ M1WRfbMPnyN2D3bWGweCga0gVHeHhwkp1vl2ftWRGy7gCQdRXDIUkyu+jwZJ3O+XdTN6 gcPP/CsooJJRo54D8XUHKHdmB0Mw6yheRgl2swxDNV8919W4+wogGwLMT8wy1p6teaI8 UXAg== X-Forwarded-Encrypted: i=1; AJvYcCU71Og+VCuvnff9Bq2OZkM25SPOQ/cHtbBV2T1cqf8fe3ofmSzhzAlLLvZLlsGW5N5KhWCuRvgIlWH/e/g=@vger.kernel.org X-Gm-Message-State: AOJu0YwWOrCHWuVIs4rrLa4S3IcJTJFstZTaCvsD+ySszxCM26vwN/Qq Cb1b14BmtUJBVfjNKtKy5Vd+9rk2LAS1NiKq0HO1yYEakbHHdgbBmXeunYNL1E5nMKhOlzDZpyg 2eH0PFSuMRQ== 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-kernel@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