Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3323988rdb; Wed, 13 Sep 2023 08:41:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHku/6pXZEfrUoXaYjW/Em9VdVHZ0ZHKocJxRr7mS+No+XWUXU88edJJd2M8yGKaR2xYmkG X-Received: by 2002:a17:90b:1c0b:b0:273:dffd:664a with SMTP id oc11-20020a17090b1c0b00b00273dffd664amr2449380pjb.20.1694619688145; Wed, 13 Sep 2023 08:41:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694619688; cv=none; d=google.com; s=arc-20160816; b=fn4OaSmR7xl385fx3nQS/JIT7FvmeQOsBIuQ+tjd2NCkJ91xUz7XG9BGarpMnZ3f0H V1HcM0TQ2IEQYyBq5Z9L7LxMeqQDHmmq2uwnGORF7jgwEV5kM1oM44Gy2hG49JigluCd aD++dZjmm5tHtFV7Wh1Y2FJVQRbTjOcZNjR7ejgF+aIFS0TaM7jzNFiSrp/AhgSNhS8+ PofxqPX7AXLhV8F7Y3sirdYF+3wXCHPS8swTS3YMhPafXWSfVLiE3cdbf1HR1Sun73I8 rjtW0L5WIZs15l/mpFZs/kZYoou1Ip0xxqZGy94NKFK5ERe48917Dzvosy0m3xtyQ7dW P52g== 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=1V02S9g/LwsQ/vdVUiMGLtWyNGFHXu2gCnqPVy/BMJA=; fh=EDQ26V2dbIG32P+iRb3QwkGh6gc1vgq5IzeoZq2CWaI=; b=Wm7Yi0qjAlwNXUh+FCJGdwAx5TstgS7Xrw15hgA2cNNJWpU/O4vxp3JaAIvkBuVZgx qmrcSDdeLHeHHYcWlCDTKFtEEhO58Sg2Suj/jDlS1NFtPLuSGqh1XuQRzOANV9O6Bg8/ iuul2wmrsJsw9TTKEAgw4B5aWKqEaY7RIX26wPzkChsqtioj68h+T6D2RZ7sFUdneJ2h SgoCeI6Lx/bNozli3IbkSqzj7UU0WbbkJ56/15P+WPTCQB13eRcSDsqExJn9Qmijhj5M t8FFZXddEY4ZfzSl1Q1J/P7cG+lu9E+C987h9VVbIqw265eAUmJq8F9F8L879mFB1JIu NIPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id l3-20020a17090ac58300b0026b7bee6873si1784761pjt.112.2023.09.13.08.41.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 08:41:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 7172D801BCAD; Wed, 13 Sep 2023 08:35:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229702AbjIMPeu (ORCPT + 99 others); Wed, 13 Sep 2023 11:34:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229741AbjIMPer (ORCPT ); Wed, 13 Sep 2023 11:34:47 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 22B131BEB; Wed, 13 Sep 2023 08:34:42 -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 0726B1FB; Wed, 13 Sep 2023 08:35:19 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DA03C3F5A1; Wed, 13 Sep 2023 08:34:36 -0700 (PDT) From: James Clark To: linux-perf-users@vger.kernel.org, irogers@google.com, acme@kernel.org Cc: James Clark , John Garry , Will Deacon , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Kan Liang , Jing Zhang , Haixin Yu , Eduard Zingerman , Ravi Bangoria , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/3] perf pmus: Simplify perf_pmus__find_core_pmu() Date: Wed, 13 Sep 2023 16:33:49 +0100 Message-Id: <20230913153355.138331-3-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230913153355.138331-1-james.clark@arm.com> References: <20230913153355.138331-1-james.clark@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 13 Sep 2023 08:35:06 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email 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 cec869cbe163..64e798e68a2d 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