From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.200 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796334757; b=1geUCcbY5TS517cVauXrv2uq5r5ps0RA07k26oTyf3hoyeaScEG5owBwHhOKKeiKYyb2 TlpisCXpBZr9ia4Ig+w6b8zG8eABktt0d0dF7SdQKMRQnNGTaNOQuutmSAntUFhuGfjfH 18ZaYd7Bkep2I7jYiwcDhFv/SmdtaDvLhwf+Sg8t0BCbMsHvA4zuKsJJ+nq9sVCIw1Jjd tij9d7ZzSBUeALGxJtdZK6IMK1GgHtEzPNUb8CYbSuOAkwsCTopDx2Ny0g4vgJeTayiPR wqlW20wfLmWa5ABnftZhnRrgy7zayb/YKEf2Fg29wIz+T888f/8jdQZsGkaXJoSzLTw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796334757; 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=vYJVBXvsaS86qlvFO5REfAo52jLXYVpzEv/HmAd2Jns=; b=hfcHUNEF40nkGtEnEzKWieuhfwRrJUrZ+3tFXakqyYs6/G7xKhB/f85+xEV9GcFrtOIZ TkmaESsh9AwnnRO5h9KBsV7ygxjZKTJZBWyiXSwYsoYhZiLMGL8NMZfT2ku2WzuCXBcA3 VxGu+TuHFc+YOj3trTsFVlZfq8hPILEcliX+8naupcJ99qDgoQobJV6ilIj2NMPvMETyK 8eTtVikqADgMeV9YWAfhCPoZWI9aj5h1ThLTBR/n/shH4HB1Nscgc6Bru0a3rzPLjXTQ5 EJyRxcR6GNQXlRXZs4CsEwoTAGNTBavH43pYtOwvuTQzAdepaDkewcfWetneYHICxpQ== 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=BMPEMg2x; arc=none smtp.remote-ip=74.125.82.200 Received: from mail-dy1-f200.google.com (mail-dy1-f200.google.com [74.125.82.200]) (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 673A3606A691 for ; Thu, 3 Dec 2026 21:52:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 673A3606A691 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=BMPEMg2x Received: by mail-dy1-f200.google.com with SMTP id 5a478bee46e88-341eff9e381so455586eec.1 for ; Thu, 03 Dec 2026 13:52:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796334755; x=1796939555; 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=vYJVBXvsaS86qlvFO5REfAo52jLXYVpzEv/HmAd2Jns=; b=BMPEMg2xjRi3GPa3iWZzFEy8bNhC1BlBrFD3Xk0eCChTB3wEaliKqUothQWmh2w6Dd je+fSlfrZFLhfG/5JD4Bl6BpWrFIb7aDPVengWNQUHthWyh6xrYPIGJWYAwcj9WTy6jZ 1o8UGBWshG5RhMoN3MIZ1kDwfD28YQ0tt9x7TGcsjaOX9cwCOvwMV0hpnaak6J/SzOHQ aU+GG7AtmePiszWeBhpmePWhiCXO2A5SCLQoMq2Llh0+d7PWdNrIPm72NZp1lKnPIFa5 cId3ebQ+mihJFp3EdkdGFIiSnwwHFGvfzMZcxlfDI9uRAd/sziu3gaHfrGJ8keRHvFvR gkoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796334755; x=1796939555; 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=vYJVBXvsaS86qlvFO5REfAo52jLXYVpzEv/HmAd2Jns=; b=u9/T5aLunSQS47zhzDmwEk+kO1sDCYMKKWcHd58NsTlcNC+8B3ANpRzpTchyyNe4Jz pJGkPPFWK5CoXATCJ0XcbWaGIowA9eWB4KZfBTexMwTynpM1PEEBebXklje9xeuvwkzj RR+97dLmkb5Ywuel9DqkXRDKlOCZfrftGWLUE3vGLQFxvPhgyezvcMyntjA/bml1e+Qd OadJ+O/fBHHZylU3Wp0XP9lAPIB5R/EbmdwjXAIFCP5YYlAk9UcQJQAN5GvncZXghtRO //c0YCC3QjdywglTtLELto9TJjhxfManwU+Ue7AUultMonlSJ9992zMqsastZ0yn9akO bzaw== X-Forwarded-Encrypted: i=1; AL+hErHd5T2KySpsks/a/23MpBHi9sYedUI2h+hbFW6+t6gxfV/NyUt5uYmr9DhcHRLk9z9iFkGQt31ZXG+yZxI=@vger.kernel.org X-Gm-Message-State: APuU4Z8i2W4s6ybznte1tpUzR27UJAiMFTRVKxh+XXieCvdZN2m87ZnI Dfp9tSveQbn0g/2qBu8uD1xv1Wi6en0M+5eEmIebYG02mlyND75P2pBHRUXmndNQrEtV8hNPfA1 qRBHYrp4afw== X-Received: from dyec15.prod.google.com ([2002:a05:7300:220f:b0:386:e8d2:1d75]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7301:1526:b0:369:1401:c5c2 with SMTP id 5a478bee46e88-387521b3135mr95489eec.26.1796334755036; Thu, 03 Dec 2026 13:52:35 -0800 (PST) Date: Thu, 3 Dec 2026 13:52:12 -0800 In-Reply-To: <20261203215222.1392035-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: <20261203215222.1392035-1-irogers@google.com> X-Mailer: git-send-email 2.56.1.915.g69d5ec7298-goog Message-ID: <20261203215222.1392035-4-irogers@google.com> Subject: [PATCH v2 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: Athira Rajeev , TAKANO Mitsuhiro , Hang Zhengyang , 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.915.g69d5ec7298-goog