From patchwork Thu Feb 1 04:22:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 19771 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:106:209c:c626 with SMTP id mn5csp201176dyc; Wed, 31 Jan 2024 20:23:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IHEMHEGrql9poDkgHFhqaw6cvtuyH98wzhS+s6IkHOS3CJS7x6H6BWVZHCzVNthuYbRf8wz X-Received: by 2002:ac8:7dc9:0:b0:42a:94a9:b253 with SMTP id c9-20020ac87dc9000000b0042a94a9b253mr1734359qte.63.1706761391633; Wed, 31 Jan 2024 20:23:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706761391; cv=pass; d=google.com; s=arc-20160816; b=epOxWVofwK8c1dIEXIxYXYf6OzJsXEIqiEAwFswW67hz7GjkRi4HheVuhIQ8gHvPUw ADJx3VfDNbf4Hkd1EDNr884CPSEPXFOLDlFmMUEJgM6eQUZZsdPagmq4RIJu+nf6mKrn f27Lc0XnAYCBAtYy6NN5hAzElz5nTAA9p4wKCH6dgaR+OQFEtks0UYCMs9uR2i82kXH6 viQ85WQm5/7O+hUPO5TBaVdByhJaXsYDAmTKc3j5DjcI/44Lq8tCTk8qlO3za1YN5oBf 9zvewPt394ZNEvW+mgZzBWCJ4uaSiP1fhbFMRThzPcV8J+fO5RebEQ4kG8NxA1phpY89 YO6w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:date:dkim-signature; bh=m0WlzH05D9HaEJ5XU0c1LIE+ZN2b2kci6XhDjYk8zIo=; fh=TGEQ2brPbfNlQIt4/4GKfM5trCABUyAfLmG69NWr0RY=; b=WBOaeaiRm+WFG3+/9Gu3Hjk3nOyKOSZwzQRsOKurhjF75FDND4xZQ+yaoT+l35ybbj gWmWk+I5UVkl2mi/LtUqAcGkqdX2OIZb4jta5Eq4yF+j9E8y9TYQHVJS+uYmQrJOjUHy aVAN1ikUBMWwPOKhDc9fXown7RFW76n4YIVrDnc/fb8nPW/K0j1bbSr4SuH7X2quuhvD n9ItwOksWSen12apToMfgjzySNvG6DEdldJrHAqL6NM0/40OZx+bwnqxJvs1/DmCRSBv gwVNXGy8bdoKdveZAWTd/Gg7H8/NejCQx2iCHwaOtyzzywFO+WtDEMnPHVMeacYFbLzs Hkyg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=enEd3XZY; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-47607-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47607-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCX4Vaovp5VM/4zwHuiRpryRvzjEH9IyXYR8oNDC7tDiC/t17poYoffxY6ZHP7id/5KqnH1UaDemPeTLM4jTtP5gkmYUZQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id k22-20020ac85fd6000000b0042be84e1001si2592393qta.194.2024.01.31.20.23.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 20:23:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47607-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=enEd3XZY; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-47607-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47607-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5EE471C22FAE for ; Thu, 1 Feb 2024 04:23:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4CA673BB4F; Thu, 1 Feb 2024 04:22:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="enEd3XZY" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (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 AD8843B793 for ; Thu, 1 Feb 2024 04:22:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706761371; cv=none; b=rEixtMiCL4Ks9fmRX2zC2+kqa8HegZqtdq7xNyPgly2EwgevbYuJdbCkwxVlY2r4b9/MTxqwF1banC0gcOftj6t2uOghTxyly0DXnMcPURyHXsRrJ2nTZeAovzZSybffpsEN9zwWwCwNkoqL7mqUJFWnWOGFh1hcrtISMZcHn0I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706761371; c=relaxed/simple; bh=6TkGB5DEMxk29IoHd6iWubxchoiv7soE0QNIxx4qk8E=; h=Date:Message-Id:Mime-Version:Subject:From:To:Content-Type; b=tQyVZb2xSvbIN3PPUlZcdIOtYPZOWcd0J6CrShXjaBRNKawNLlL5TFEWxEu3PDuZCvvXMQOdMROedFJMq0r0TgDGqJ0chO82+VQ5D8vHjG8mr7ADTIEToRkAngQ6jdJ/Tj2dO/AUVC5hTlOo7Xe97CwHoBCbiT8+PhoS8UKYWIk= 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=enEd3XZY; arc=none smtp.client-ip=209.85.219.202 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 Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc6531fa07fso633865276.2 for ; Wed, 31 Jan 2024 20:22:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706761368; x=1707366168; darn=vger.kernel.org; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=m0WlzH05D9HaEJ5XU0c1LIE+ZN2b2kci6XhDjYk8zIo=; b=enEd3XZYkaFuRppd8TnmXUghY1TPG4OqtVUIaHfknMiM6UXp1mT8fISFoD2DBUIxLO KXmtJjwvTm38QIIeot2Zc5izC7i8KdYcReSQ2HFGhTtxkT7dS0f0toHLtpxvjRzioRk2 IaWcbN1F2v2bsgOCOS1noc+fReuwovqyhej0+aVjE/kTx7VajHwqLjn0L8AklPWzzfc2 Eb6auxYSVqObCIyhSfsI37M19MUmD+MkyR9y6UCJZ9Khe9/Sb126r8MHrAVQHwwhSj63 nfd9nF4mKSJwezefZNMqJazYLrHMRgVU7Z0/HKR4YGHgSXPSnVK0E42gdbiiqzaH6BO8 V5kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706761368; x=1707366168; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=m0WlzH05D9HaEJ5XU0c1LIE+ZN2b2kci6XhDjYk8zIo=; b=JYWhWezhu7s33KysaDlzBWIFwjW5wjNZYsrThZYILFHEt8cZtYW5fCFiAWAlCgVxUn CEBoP2Ogh7NU8CoBewY15utaTwaSomT76NCYIw0/diWgmkF7kh1aG310C1qsZ9MSULdc kUwTMOVViZrS6BsYJ1HT9VFEqv8a4LvP+8DIin47M2+cmrL5CCiTyFLcYnPkZyKxJQ/7 m9fTCojc6WvavA34PvCOHmPdvbs5HoAshBK4uEUz6HBVCt0A2W+ot4KDflbQhRsu/8M3 Qa7AedMLRiDFW9golHfhTdofSRC3SxnqnTK0Nd2SR546KH833n8cYJIPpJai/ZfivTPt SrcQ== X-Gm-Message-State: AOJu0YxalIGOoMeTRS86eqsZPwhfVmQjdGRH+3MG2I9bn6bAVWv6igPt 8/RP9wxDc6eBMCyTR0Rhc9eOYqp+qxC1fAfqNtmocGmw+dCzUNTVPBBhbKEAVjJtJ17tIWQTNj3 MNIe1Jg== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:16c5:1feb:bf99:a5d1]) (user=irogers job=sendgmr) by 2002:a05:6902:161e:b0:dc2:2ace:860 with SMTP id bw30-20020a056902161e00b00dc22ace0860mr143929ybb.2.1706761368685; Wed, 31 Jan 2024 20:22:48 -0800 (PST) Date: Wed, 31 Jan 2024 20:22:28 -0800 Message-Id: <20240201042236.1538928-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Subject: [PATCH v2 0/8] Clean up libperf cpumap's empty function From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Suzuki K Poulose , Mike Leach , James Clark , Leo Yan , John Garry , Will Deacon , Thomas Gleixner , Darren Hart , Davidlohr Bueso , " =?utf-8?q?Andr=C3=A9_Almeida?= " , Kan Liang , K Prateek Nayak , Sean Christopherson , Paolo Bonzini , Kajol Jain , Athira Rajeev , Andrew Jones , Alexandre Ghiti , Atish Patra , "Steinar H. Gunderson" , Yang Jihong , Yang Li , Changbin Du , Sandipan Das , Ravi Bangoria , Paran Lee , Nick Desaulniers , Huacai Chen , Yanteng Si , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, bpf@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789669033207409666 X-GMAIL-MSGID: 1789669033207409666 Rename and clean up the use of libperf CPU map functions particularly focussing on perf_cpu_map__empty that may return true for maps containing CPUs but also with an "any CPU"/dummy value. perf_cpu_map__nr is also troubling in that iterating an empty CPU map will yield the "any CPU"/dummy value. Reduce the appearance of some calls to this by using the perf_cpu_map__for_each_cpu macro. v2: 6 patches were merged by Arnaldo. New patch added ensure empty maps are allocated as NULL (suggested by James Clark). Hopefully a fix to "perf arm-spe/cs-etm: Directly iterate CPU maps". Ian Rogers (8): libperf cpumap: Add any, empty and min helpers libperf cpumap: Ensure empty cpumap is NULL from alloc perf arm-spe/cs-etm: Directly iterate CPU maps perf intel-pt/intel-bts: Switch perf_cpu_map__has_any_cpu_or_is_empty use perf cpumap: Clean up use of perf_cpu_map__has_any_cpu_or_is_empty perf arm64 header: Remove unnecessary CPU map get and put perf stat: Remove duplicate cpus_map_matched function perf cpumap: Use perf_cpu_map__for_each_cpu when possible tools/lib/perf/cpumap.c | 33 +++++++- tools/lib/perf/include/perf/cpumap.h | 16 ++++ tools/lib/perf/libperf.map | 4 + tools/perf/arch/arm/util/cs-etm.c | 77 ++++++++----------- tools/perf/arch/arm64/util/arm-spe.c | 4 +- tools/perf/arch/arm64/util/header.c | 13 +--- tools/perf/arch/x86/util/intel-bts.c | 4 +- tools/perf/arch/x86/util/intel-pt.c | 10 +-- tools/perf/builtin-c2c.c | 6 +- tools/perf/builtin-stat.c | 31 ++------ tools/perf/tests/bitmap.c | 13 ++-- tools/perf/tests/topology.c | 46 +++++------ tools/perf/util/auxtrace.c | 4 +- tools/perf/util/bpf_kwork.c | 16 ++-- tools/perf/util/bpf_kwork_top.c | 12 +-- tools/perf/util/cpumap.c | 12 ++- tools/perf/util/record.c | 2 +- .../scripting-engines/trace-event-python.c | 12 +-- tools/perf/util/session.c | 5 +- tools/perf/util/stat.c | 2 +- tools/perf/util/svghelper.c | 20 +++-- 21 files changed, 175 insertions(+), 167 deletions(-)