Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4502764rdb; Fri, 15 Sep 2023 04:28:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHgkzE0gh7texXuy8gu4GdUY/OrJnprSMPVW5klo+o+32PIbiBhye2/udlCSEnrUCpGjWeL X-Received: by 2002:a17:90a:bb98:b0:274:4fb:360a with SMTP id v24-20020a17090abb9800b0027404fb360amr1139945pjr.16.1694777329199; Fri, 15 Sep 2023 04:28:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694777329; cv=none; d=google.com; s=arc-20160816; b=EQeQo7OdygLaxaPmgh0wSzdXJ5/QuSW2hYTjObqpoaqgziZKvpRFtwTymD7BjEf5ZO /GcBsT/Jpll6ZysD4/H600zjpV5iu0qM81JepM0b9GX80BFFtGue5eA5aA4S4Mu7rV1U vkRdRbV0XBIj1fMudh0AikLN3V6FirUHFzU2vhXPNutE9t/dx8bhzqdziWIPP0Q2wvvU j3rA9cLsR6YhpxUd7rPwEbHUM0UwcyEumdqEZbKerbF/iWAk1JMT2npNHzLciZDKAHdb /eZoSOEg/aL0VqmNvbRkkyhxhyhJW7GmKsupIhM35QgFbBKKmYqXpMohUHbhu9oFMlYm Ze8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=4tlAwpsMi+gLzUZJqC5eMMuAYvfZlubAzPOWkqtKRgY=; fh=fAo7dZdz8qVR0agD4K/TJj2bUkH5yftqzCsIT1yGA3I=; b=rgLRVsmb8eGCmSSKtQMnmfMV3UCtGYiszBOoG+N9ABvZlQJxFCgRqZ5PYGIojUtBho jqddY8QkrtVWbZUvgj5Q4FZVK4SpYYGw6Hg7MgtAIEKhnuFlegDbunAWf30fSn6egq8f uyZUqjyfBHViq81VoeEqT0XNGcZjpct43R9b3PLAzOj3pJtNVCSbH1f0yMLmC2d0joxL 1+9Z5n/roWSyqTw+H3ufsvY3FWJFqJlKi1KmMhZfph6C4YvwQFRNn/KfcsxphgNZ80R1 afZ6igLqMQWwpaYuI4Bb7S9EoX+htotv+3Hdc/2x6hERT1EQB+S+QA5i0G56o0mgh+e/ 1bjg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id ei3-20020a17090ae54300b002691e035572si5349379pjb.17.2023.09.15.04.28.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 04:28:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id C1944837BE44; Fri, 15 Sep 2023 04:18:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232403AbjIOLSR (ORCPT + 99 others); Fri, 15 Sep 2023 07:18:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230153AbjIOLSQ (ORCPT ); Fri, 15 Sep 2023 07:18:16 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 55C89101; Fri, 15 Sep 2023 04:18:11 -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 91C241FB; Fri, 15 Sep 2023 04:18:47 -0700 (PDT) Received: from [192.168.1.3] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CD0133F5A1; Fri, 15 Sep 2023 04:18:07 -0700 (PDT) Message-ID: Date: Fri, 15 Sep 2023 12:17:56 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH v3 2/3] perf pmus: Simplify perf_pmus__find_core_pmu() Content-Language: en-US To: linux-perf-users@vger.kernel.org, irogers@google.com, acme@kernel.org Cc: 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 References: <20230913153355.138331-1-james.clark@arm.com> <20230913153355.138331-3-james.clark@arm.com> From: James Clark In-Reply-To: <20230913153355.138331-3-james.clark@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,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 morse.vger.email 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 (morse.vger.email [0.0.0.0]); Fri, 15 Sep 2023 04:18:23 -0700 (PDT) On 13/09/2023 16:33, James Clark wrote: > 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 Turns out the "Simple expression parser" test is failing on heterogeneous arm systems without this patch. I didn't realise there was a dependency and should have put the commits the other way round. I will leave the error message here in case someone bumps into it, but no fix is required apart from applying the remaining patches in this set: $ perf test expr -v 4: Simple expression parser : --- start --- test child forked, pid 4902 Using CPUID 0x00000000410fd070 FAILED tests/expr.c:83 get_cpuid test child finished with -1 ---- end ---- Simple expression parser: FAILED! > --- > 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); > }