Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp1924056rdb; Tue, 5 Sep 2023 09:00:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEp7MIwtH3cHLNlfmnofJsj5/k98AnbPO4fnuY/Y5V2tMM7/n48Y4nb4KeeUQndbUnUkE0O X-Received: by 2002:a05:6a20:1447:b0:14c:a2e1:65fd with SMTP id a7-20020a056a20144700b0014ca2e165fdmr14237026pzi.9.1693929615674; Tue, 05 Sep 2023 09:00:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693929615; cv=none; d=google.com; s=arc-20160816; b=g9rG15SaFfMv/vmdIVG5k9SwLG2H7x8pyWqJ35nNOTLA+qe66YTxPpwNJbV1lSt3ZY qPW7Q1W8IoLSnwLfE1dejDBuG1vy1yNjpvnekTEpogZr16gaPTnuLPJSSfkCZ9XjtLOk /w5gsDJXnLm+KJX8tScbG2+Npl+crzm4v8Ui/3XQDVyJVjTa6obbrtXA1YAgRnvFoKap VtWklgqlPM19JMh/byZPrWiyAovZHzhneI5i+CAY2+hwsN06BzKkCmUr5fzYSeKeriBV MEOJAnk/XqfaddsL52vAl+WSuMvT5Sz512aBjZpY9m/bWm7A6Gfe32HxHqJEwoN7LY0d X6tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=i+XpQDDmwQBy8jzCY1DrR2HD6p2PyjJo1YosVoL1p7E=; fh=e12tVoXNpSqo2PKyWeu9ZauTgx5CUsylWqN+juSLqRs=; b=B/2wWgSILI6qpdSzO0VleeeBJByVvr5hVUjSslInfhU6+PJquQkVJ1GaqratKUN27e oG4BCovdTbilQ/UXhpCxKGq021zXCu7vN3+0Rb2QQ/DBvsubgDeC8+twiYQSfwkpQh09 U9QVFUpl4QdNmbMYpEgX66JAgsoi7imeqXtuZ7ceWQDEcf1Zaqg/RiI8VKrnfXl//ErY PfYil16cq5KF1lHSH+qOFGuFqEDO866XzDOyYjazP+mmqJGrQNJ+3HDCaS/bQxIqHLWr WKn0cxOYurgnomOsULHDWU4MWmg6QjeDogCdeXPZ3UoAHmVe+bgDzgNfWdJYCpRKji5f /rpA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l65-20020a633e44000000b00563e23a5520si9453543pga.353.2023.09.05.09.00.11; Tue, 05 Sep 2023 09:00:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349509AbjIDJyF (ORCPT + 19 others); Mon, 4 Sep 2023 05:54:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244654AbjIDJyE (ORCPT ); Mon, 4 Sep 2023 05:54:04 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E9DFDE72; Mon, 4 Sep 2023 02:53:38 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A0E9F1474; Mon, 4 Sep 2023 02:54:16 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3DD7D3F793; Mon, 4 Sep 2023 02:53:35 -0700 (PDT) From: James Clark To: linux-perf-users@vger.kernel.org, irogers@google.com Cc: James Clark , John Garry , Will Deacon , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Kan Liang , Jing Zhang , Haixin Yu , Kajol Jain , Ravi Bangoria , Yang Jihong , Eduard Zingerman , Madhavan Srinivasan , Chen Zhongjin , Miguel Ojeda , Liam Howlett , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 6/7] perf pmus: Simplify perf_pmus__find_core_pmu() Date: Mon, 4 Sep 2023 10:50:48 +0100 Message-Id: <20230904095104.1162928-7-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230904095104.1162928-1-james.clark@arm.com> References: <20230904095104.1162928-1-james.clark@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently the while loop always either exits on the first iteration with a core PMU, or exits with NULL on heterogeneous systems or when not all CPUs are online. Both of the latter behaviors are undesirable for platforms other than Arm so simplify it to always return the first core PMU, or NULL if none exist. This behavior was depended on by the Arm version of pmu_metrics_table__find(), so the logic has been moved there instead. Suggested-by: Ian Rogers Reviewed-by: Ian Rogers Signed-off-by: James Clark --- tools/perf/arch/arm64/util/pmu.c | 8 +++++++- tools/perf/util/pmus.c | 14 +------------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/tools/perf/arch/arm64/util/pmu.c b/tools/perf/arch/arm64/util/pmu.c index 3d9330feebd2..3099f5f448ba 100644 --- a/tools/perf/arch/arm64/util/pmu.c +++ b/tools/perf/arch/arm64/util/pmu.c @@ -10,8 +10,14 @@ const struct pmu_metrics_table *pmu_metrics_table__find(void) { - struct perf_pmu *pmu = perf_pmus__find_core_pmu(); + struct perf_pmu *pmu; + + /* Metrics aren't currently supported on heterogeneous Arm systems */ + if (perf_pmus__num_core_pmus() > 1) + return NULL; + /* Doesn't matter which one here because they'll all be the same */ + pmu = perf_pmus__find_core_pmu(); if (pmu) return perf_pmu__find_metrics_table(pmu); diff --git a/tools/perf/util/pmus.c b/tools/perf/util/pmus.c index 032ce57d2b8e..5ae41644ccda 100644 --- a/tools/perf/util/pmus.c +++ b/tools/perf/util/pmus.c @@ -596,17 +596,5 @@ struct perf_pmu *evsel__find_pmu(const struct evsel *evsel) struct perf_pmu *perf_pmus__find_core_pmu(void) { - struct perf_pmu *pmu = NULL; - - while ((pmu = perf_pmus__scan_core(pmu))) { - /* - * The cpumap should cover all CPUs. Otherwise, some CPUs may - * not support some events or have different event IDs. - */ - if (RC_CHK_ACCESS(pmu->cpus)->nr != cpu__max_cpu().cpu) - return NULL; - - return pmu; - } - return NULL; + return perf_pmus__scan_core(NULL); } -- 2.34.1