From patchwork Mon Sep 4 09:50:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13373692 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0D17BC71153 for ; Mon, 4 Sep 2023 09:54:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zuTfuAYSRJcxfqZBJjhO1QbX9IWDPNMKVa4KejeKVig=; b=eK6/wcFwwB5ibm Xs90MsVoJYxsOQJKpDcOjXn+GVvVrW+xx6HhgAi9MX7BfQIT+bE9gv9mPmKgvC/+RC7zSWIZT/RUo vrFx2tA9j76Y+Rqk0P3tzI33YSjGipO/YYvIFkRKOo3hPoojjsTTq3K3eoSVq+J1EIxghJLftjmb3 xP61wK0VRJOScTTiHeMurNOziNGzBQVqeXAdB/IQSvXaPP1Lp2JG2YTF85d37kQ4SEvcLyM/SXn1o 0snYFx8hDIOFajt3k/knmPj9VvmWuNHVKhFVcZb3cp/RUvRZPMY1loK8GarEHx2pszsh3zMFvGyNq vnqQArZoS0LVuzOf9XxA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qd6H9-003ixi-2q; Mon, 04 Sep 2023 09:53:43 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qd6H6-003ivy-2s for linux-arm-kernel@lists.infradead.org; Mon, 04 Sep 2023 09:53:42 +0000 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230904_025340_979558_732835D2 X-CRM114-Status: GOOD ( 17.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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); }