Received: by 2002:a05:7412:3210:b0:e2:908c:2ebd with SMTP id eu16csp450221rdb; Thu, 31 Aug 2023 14:27:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFY1tdNswXbMsdJ25AJr9TLK2eXX5xSOsDd0XMbvb4cCnb4P1Cxei4sTzilQFHwIr6FPW54 X-Received: by 2002:a17:906:2252:b0:9a1:bd33:4389 with SMTP id 18-20020a170906225200b009a1bd334389mr399444ejr.74.1693517271550; Thu, 31 Aug 2023 14:27:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693517271; cv=none; d=google.com; s=arc-20160816; b=ITq6ErK7XHCS8dpKrbXXRrlqlagbD+AKOnkMDosadaEumvNiIUeeJ8xk30MLqvM52y TOCHXgkU3tHwaIq2yDVQNJ06l358j+CJLI3azTKH3L+Vl3MH72lbSCuugUaWlJcDpt7E ec+RSCk5FSxU0NiaQzkgLeihYSmLvihGqWJUXatFk3b+npWPPp1a8kC5yX19GpSYr3RO f/YQVl+TiuxTKeKBrUJER2WPn+N78KqoyWVZ06xFIYToQlw7vsS0kAK7sm3XeJVvxs1c T7/mhebVZeu0vq85CHfEjQXXMPLTuRo97cjPzafmg+OBIsyZXXC572yNBewSRRlMHLJx i0mQ== 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=91opCPEflHSnMNixUPWKshvtSgfqHxmI+lG4thmcFrw=; fh=/uIWXwg2klHEL+eohGFhdAzXIz/rNA3ySyuSy7X8uxo=; b=Hv3lKoq3xqQbUX8W5bSnCwZ5BVUwplMAXUZjljGUlhUR7zftfmELbjaU+9lg5/2HU5 UB+uXUjL2rIDS66eq63mfVQQoO1u6e+W4BLdkM1/+X36zbl4NUma7kC4wx2936u6egvp Hc8RgF/60opv+XdE/nM11kyWdp7H1ZPQuGis1nwWN2A4Tq6MRte/+weFoRZMdcxqMS7U FIdqk+tzuptEKFSeHUzkrKlJQ5ayG1FDLqa/dlj+ae7sAS2FfG14kVIaBamINIhnox5q mdKKcRf+1cfhxGV1KDn+AjOj+RfOMjmOdzD1T8axlqqVLchyZ/EX6DVt9o8K5pc6bLLb RyzQ== 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 s21-20020a170906961500b009a16b635792si1561618ejx.716.2023.08.31.14.27.43; Thu, 31 Aug 2023 14:27:51 -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 S244990AbjHaPSs (ORCPT + 30 others); Thu, 31 Aug 2023 11:18:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236867AbjHaPSs (ORCPT ); Thu, 31 Aug 2023 11:18:48 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9FA04E72; Thu, 31 Aug 2023 08:18:34 -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 A8449C15; Thu, 31 Aug 2023 08:19:13 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0835D3F64C; Thu, 31 Aug 2023 08:18:30 -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 , Liam Howlett , Miguel Ojeda , Chen Zhongjin , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 6/7] perf pmus: Simplify perf_pmus__find_core_pmu() Date: Thu, 31 Aug 2023 16:16:17 +0100 Message-Id: <20230831151632.124985-7-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230831151632.124985-1-james.clark@arm.com> References: <20230831151632.124985-1-james.clark@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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 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