From nobody Mon Feb 9 02:52:11 2026 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.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 64C4D2DEA6B for ; Wed, 3 Dec 2025 21:47:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764798442; cv=none; b=UJfegv1kVS4iNK3AB90LpB7cjI5JFQHojxzTQJZh6nmcrhqvSWVT+XqBRx95b4F0kWCF5kK0429F06unAjKUsNVTi8rT1HM/HeqP++sOabChDZy8+r6sjd5Fb4EVkkn1Ppvm/bJh9/oKfdiakzm08gaW11ZNGd4Ki3kNY0kONGQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764798442; c=relaxed/simple; bh=Kyld/TH14VvFTwm+4dZFdkYfKcCb+2QzuTXq2FWHP/w=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=o1t3lyWnBzADvaz/VC2Ilgdw2bByFL5q8tW0zjX3xsZSyBf/CER0n6IQ4iJMOt3f2fCq3tsOQCtaFLslJQTvMztXnNAN9nXrHpdV58XkAzYhIrTU7KKvuPVnkabrPXHgYDgbLa6y6V1/WFlCPvGDyota4J8DtUDElAMjg01AuQk= 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=RvfxAOeG; arc=none smtp.client-ip=209.85.216.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="RvfxAOeG" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-3416dc5754fso306732a91.1 for ; Wed, 03 Dec 2025 13:47:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764798438; x=1765403238; 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=KVrVKz8Lai23YOYMICxCQxi+2iTcn8EZtLBh+0CJH0s=; b=RvfxAOeGQ0re1jP26AG3sXrU/l2KOP+ovky8ou4MGERPo3PBAYCg3YRzlJSuiCtoM7 VFYHi3ZzllZuICj6Y9LGhJTPQj4w2cOdoNO05eHt3kaGf/TKRv4MqIh0P0jSin9WsI3D 0vPIF3zm44IfD2jgPchqOans/CcNuQjUaIym6FLhRjrjO4s2SqxddJL3u+sYxPCu2hCs b1Fw0geNaYsYGd+NNT5TgplA6mdUu6seGI00X9ATi5BTDlwnG2HYzJUhtigcMLuaJ9Mx Lw528NAUDylUDnvpzVpdaPG99gkHfheJvleXBj03ozU7Gk4TotjfbR94K+p65T3cueRx pUFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764798438; x=1765403238; 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=KVrVKz8Lai23YOYMICxCQxi+2iTcn8EZtLBh+0CJH0s=; b=ojYpG31tR9I5vU2vctVgCqv02Zjt9SycpBqmNJZD/y/S+9kTen2KER+fN1pUi4zbf8 kuQuhTz+k2+ey6eA1z3LtOobpjdipF672x442Jt8+mfcNSYQjkEV4m9g2H72/j/PjfkW mH3zwUGsTczTfHsKi2OKsq8jvwdiKY+GXi8y3txZWBO4l2bQ+mtsrISf7CD8jnwz0L8l aQjkAWfDv78yqErRGtWjqiMyxBIpUK2iG3elPeONOpmVIbtY0Iqf1C/rWAV0Ft1Lw/Ur Y3pvCSqK6XsaEOXGP8dMsPXw6jOindkthao5DDws3lqgWAgCW9+NQ0ntfoGipOc8/yTU 7KOw== X-Forwarded-Encrypted: i=1; AJvYcCUvhDBbrFxNqIOS9PdxtSK9qE7V0ZCuJJoAc7icn5E0QwbTSbA7F20hsclNmMadd1f2qMJSv1tNW67x6ZE=@vger.kernel.org X-Gm-Message-State: AOJu0YwNiRYsIf8yypbW36CnQpwGwJqRXLgfhLA3fFkVXKqQ2B/pLQkd EBPqKBz52wZ1MrmGp89HQnAbR/yyEV+bjOBof3wvhRBuUq8ZxsfsVfnISPgqbdUd6/fqRYMbSHT q2KetJp941w== X-Google-Smtp-Source: AGHT+IHQNalAFA0VgFKH+HuXt5tSRXPCzbxo8ZyVDg59kZ29Ina+YFWr1q9VEzg+9t3xXETcoD2Qq+FkDeUj X-Received: from dlii30.prod.google.com ([2002:a05:7022:419e:b0:119:78ff:fe16]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:390:b0:11a:fe6f:806a with SMTP id a92af1059eb24-11df0cc65a1mr3127815c88.31.1764798437402; Wed, 03 Dec 2025 13:47:17 -0800 (PST) Date: Wed, 3 Dec 2025 13:47:02 -0800 In-Reply-To: <20251203214706.112174-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251203214706.112174-1-irogers@google.com> X-Mailer: git-send-email 2.52.0.177.g9f829587af-goog Message-ID: <20251203214706.112174-4-irogers@google.com> Subject: [PATCH v2 3/7] perf cpumap: Add "any" CPU handling to cpu_map__snprint_mask From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Thomas Richter , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ingo Molnar Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If the perf_cpu_map is empty or is just the any CPU value, then early return. Don't process the "any" CPU when creating the bitmap. Tested-by: Ingo Molnar Signed-off-by: Ian Rogers --- tools/perf/util/cpumap.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c index 89570397a4b3..a80845038a5e 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c @@ -684,16 +684,21 @@ size_t cpu_map__snprint_mask(struct perf_cpu_map *map= , char *buf, size_t size) unsigned char *bitmap; struct perf_cpu c, last_cpu =3D perf_cpu_map__max(map); =20 - if (buf =3D=3D NULL) + if (buf =3D=3D NULL || size =3D=3D 0) return 0; =20 + if (last_cpu.cpu < 0) { + buf[0] =3D '\0'; + return 0; + } + bitmap =3D zalloc(last_cpu.cpu / 8 + 1); if (bitmap =3D=3D NULL) { buf[0] =3D '\0'; return 0; } =20 - perf_cpu_map__for_each_cpu(c, idx, map) + perf_cpu_map__for_each_cpu_skip_any(c, idx, map) bitmap[c.cpu / 8] |=3D 1 << (c.cpu % 8); =20 for (int cpu =3D last_cpu.cpu / 4 * 4; cpu >=3D 0; cpu -=3D 4) { --=20 2.52.0.177.g9f829587af-goog