From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.199 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795418377; b=QvPdhVNB16e0Uhb57ZoADFCdpD5dqKXPCm+toIAsm2B3wPg+fA23YcYFZ7eUO0rL45k1 xfwkx2ZmNc9tfmBgSHHr16MBqYU8XPXcxsXS2HFFCq1FdVk7zM29hR0I2o/SpZmOxpSZt GT0brOgI+Q4EX54VkGxWKHj5c+8rrWraVa42ghUlFh7MbtRW3ebogToIYL3fnmcSQoOn9 UF4hrIkIkWUEwExLZjhum85chrJnenKWRrOif06MzGTYG8c6aNq1yf3+g4GPc2oLMO97k kJaZet41c95YrCumLPv1T7OyMIf5Npa+c/nkct46jNkD5CpH/FmiSPd2n5WdmkZDHXg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795418377; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=IMd33jYcNZqKzcubrxm3ZjVIehLYL/REobXhw2TBdkc=; b=GeUqoAmguFkrZyJ94lV2qQAz+Y1YKhyHNXB/6dmH85zfZk597SS9MBN1t0xcogg2f6ay JUHYL/IhMTfy8SYhDn/QXtBqsApdlpdANsBL0l6h5A4tcH7FMRoAp34M7NTyungX/Y0fq GLRWxScBkx7K0/3HAufNWH6cBmZfThyCeLrvUk0sYxQJ+8e4O7aEGKrbR7rRFBCls4aUa pF9zC0nYJgcELjmmCZ7O940ckSQH41UFw4k0dJEd0/pNpHo2hqnCXN/tY1l9v6unIVCkm 3ebXsT/BVAHFibt7ASb4rv8hp1d+WdMk52Fg1eAmsN6MwX2mBuUFcAHM12nXo7drGzA== 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=EHNqtqVX; arc=none smtp.remote-ip=209.85.214.199 Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) (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 D7CAF606A321 for ; Mon, 23 Nov 2026 07:19:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D7CAF606A321 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=EHNqtqVX Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-2f0467a525eso21483735ad.2 for ; Sun, 22 Nov 2026 23:19:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795418376; x=1796023176; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=IMd33jYcNZqKzcubrxm3ZjVIehLYL/REobXhw2TBdkc=; b=EHNqtqVX924a3sJc8UV+EMhdnAvjiJWuS4zowCnFH2JyG4pP/ljl47bjKQjpo7rOUT ZFQomX+RGXRmx0QtaKPIrvQgYHfIObJ/kxbLRkHJTBAGc/8qLzqe9V603QoLvU9eDAB/ 32maiYjrS0skMqmHVIQInu5+ZfhVVpaKJEFnFyljW0muVsuEyfsYKs9rDhw77bAOIqiZ tGaTVx/stPgcb82KxkuSKRQLPp8fT82n+8/fYqcjshDIlYm0ARx1ndc3RmaFgX2AVv3r lMIlt3BiSzao7BVlpt309ZGu/fPye67XZV3unWw9FSJY+rHuAjUKLjNKVYRAVSsFDwd8 V0fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795418376; x=1796023176; h=content-type: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:content-type; bh=IMd33jYcNZqKzcubrxm3ZjVIehLYL/REobXhw2TBdkc=; b=GmoaD6MKgu9jAJOEyT6KY6VnnSKL68zPtVlDwdenUWOfynFHGK38yAQUZeP2m6KSFO VIFf7DcZlmX/l9DUfwwzyIAMmJVXR8mX03nOxQTG1doI0tbWMzjMbz96bM20xiFRbrEA D0lSRc05gT/hbBxeCdTI7nTYEAB2CcEuQv7rb1S4gbpa7gpGtOAQYHgav66pieH+cS81 CMTABL1ZDlg6G7lnRmfxyw73cOysOX2wYzNy6zmecz206N1TbS6zVxD2dFBOa6D04l2z j+1wNRR9gRMS/oO/GQ2HCb3VOSCCa8NkbRrGccVNR2AFxYuZv0jAiSsbCRlBaGFL+3i+ je4g== X-Forwarded-Encrypted: i=1; AL+hErGY3uO/UmEM8urN++TUq3r++rsGt6GDsKTCTkIMouuOViXiY2tlzyWztgJrlFHffYbXXgM5ep+HiC0/zJE=@vger.kernel.org X-Gm-Message-State: APuU4Z/enlw0V1LDXr/l1YlZIA6Pk8eRhBcUkyByu8otpf27v1EoeraV HthU5HWbZvFBPW1VnzVjvMe+HcgNzi+WWOV/YceDqB8kASMHzl4woD+U7KZiMEl9RE0/y+lOaRJ yMtkM+kVWWw== X-Received: from pjbiz18.prod.google.com ([2002:a17:90a:e792:b0:3b4:23bc:9fe5]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:442c:b0:3ac:a203:e0a1 with SMTP id 98e67ed59e1d1-3b41c92a902mr9665930a91.37.1795418376056; Sun, 22 Nov 2026 23:19:36 -0800 (PST) Date: Sun, 22 Nov 2026 23:19:03 -0800 In-Reply-To: <20261123071913.653315-1-irogers@google.com> 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 References: <20261123071913.653315-1-irogers@google.com> X-Mailer: git-send-email 2.56.1.750.gf70dc682cf-goog Message-ID: <20261123071913.653315-4-irogers@google.com> Subject: [PATCH v1 03/13] libperf evlist: Recompute CPU map when an evsel goes system wide From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark Cc: Howard Chu , Thomas Falcon , Song Liu , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" perf_evlist__go_system_wide() marks the evsel as system wide and then propagates the evlist's maps to it. __perf_evlist__propagate_maps() only assigns the PMU CPUs to evsel->cpus if the map is empty, but an evsel added after the evlist's maps were created already has the user requested CPUs propagated (e.g. the "any CPU" map of -1 in per-thread or workload mode). Going system wide then leaves the evsel opened on the wrong CPUs. Drop the existing CPU map before propagating so the evsel is given all of its PMU's CPUs, as is expected for a system wide event. Propagate the maps of all evsels, rather than just the one going system wide, so that evlist->all_cpus is rebuilt. Otherwise the evsel's previous CPUs, such as the "any CPU" -1, remain in evlist->all_cpus and may cause per-thread rather than per-CPU mmaps to be used. Fixes: 811082e4b668 ("perf parse-events: Support user CPUs mixed with threads/processes") Reviewed-by: James Clark Signed-off-by: Ian Rogers --- tools/lib/perf/evlist.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/lib/perf/evlist.c b/tools/lib/perf/evlist.c index c1c5b0684eed..c6ce56b46ac1 100644 --- a/tools/lib/perf/evlist.c +++ b/tools/lib/perf/evlist.c @@ -835,7 +835,15 @@ void perf_evlist__go_system_wide(struct perf_evlist *evlist, struct perf_evsel * { if (!evsel->system_wide) { evsel->system_wide = true; - if (evlist->needs_map_propagation) - __perf_evlist__propagate_maps(evlist, evsel); + if (evlist->needs_map_propagation) { + perf_cpu_map__put(evsel->cpus); + evsel->cpus = NULL; + /* + * Propagate the maps of all evsels, rather than just + * this one, so that evlist->all_cpus is rebuilt and + * doesn't retain this evsel's previous CPUs. + */ + perf_evlist__propagate_maps(evlist); + } } } -- 2.56.1.750.gf70dc682cf-goog