Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2545323rwd; Sun, 21 May 2023 23:58:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4lJ3CJAY0jz2AoeZXZ/15mUx8s78E0eNZiwiIHjk+/Iug89qKLLCXuTY6en8gjIFxz4Z/I X-Received: by 2002:a05:6a00:804:b0:649:450f:3231 with SMTP id m4-20020a056a00080400b00649450f3231mr12775459pfk.9.1684738697932; Sun, 21 May 2023 23:58:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684738697; cv=none; d=google.com; s=arc-20160816; b=FjUz4DRXSOmEqyU2x3738J6BgH88rZF+YmozZ06uNSm0akR2Zeh1BtO4beEVjaV3+S nneSKeZQZvkByYL6YwVueUzFRf4x+jaWA7tC5ce1oQrObstYc5uVn8sZ61D6XvOCWagS lU1x1BLpAaaUVXZ4KufplAR7lEi3C9tF85XJmne7dF73TmocWgGPS/D8vpz4ARVX5r3b eJXJFRt3VLNzDfCGEPkgSEll5RW417OTATxj0jXRC9RyEXxSPBfQSmfBsLRai6XjIR4K QPQ2X/g5ly+ccKvyctOuMHXLgMgfpCvJ87dSpm147QhyYqoKfDrFEbOoS5bd0Ak6wJB0 Ft5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=wY12k1F5dOPmIa0ikykHN2ccarTwqFRAmkOKXrH13wU=; b=OQobjG8AOstNDgF+XDm88yhFQgUebLEfop8oL3fxDCnco4fHW0jiuQDs7pHq02BHIl 4PPzi17yONAls1seHLpypDjIxCuQ+BfuBLgamTvj7BmcEnozPROlq76fLR0hC8USnwSk C6/cJEea/HdUmGrEUhDTldijE2DuN4w0VHb4jYn7EddxEz6sHfdKXTp4tHqhgIyTQWMS u0F4l5FxVWXvceib2dFBsipDWENABGLCXLAj40SZjCMK2IVNKJPboDqYaCQt6VEA6kVA mGO33gXJAiDfdaadsc+d0nC+yWVaKYbe0D83jrUVzFeBJ8A85bqJ0/1OZByihih3oxWV 9U2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=2VubbBxC; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r4-20020aa79ec4000000b0064d62bda46bsi1990421pfq.212.2023.05.21.23.58.03; Sun, 21 May 2023 23:58:17 -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; dkim=pass header.i=@google.com header.s=20221208 header.b=2VubbBxC; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231847AbjEVGog (ORCPT + 99 others); Mon, 22 May 2023 02:44:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231975AbjEVGoF (ORCPT ); Mon, 22 May 2023 02:44:05 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B489E40 for ; Sun, 21 May 2023 23:43:54 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1ae8ed1c293so11475385ad.3 for ; Sun, 21 May 2023 23:43:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684737833; x=1687329833; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=wY12k1F5dOPmIa0ikykHN2ccarTwqFRAmkOKXrH13wU=; b=2VubbBxC7SiuoDKB/MAjz1AyE91qcGOI3gAFX+O+h98PNa+/AOLmXiTcQNj35qdvGi 5sdEkIn7TR+FtSzi81M8ZbsqvKi4CK5TEtis1ZZ7l2pW10E3a9EDpGXp/gPOSn4kCmBS PRvYHeDkjO192X2t2le0lojDNk20x1MmMrAaQ4zIGqDLfxc/g7aPiSxfSvdY1iLOkUY+ nM3AcHDW1A2p05Cr8SlrDS4wY1FlPOkpgooicnN+08ft1d7bSQINpa/R7aPer6HqWEYE 6P5pgis7h9FnEBg5GEKw13ti0LIPVc65TT4U7Mje+kUGLdIbksls4/rsWFsB8actKpFL nHtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684737833; x=1687329833; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wY12k1F5dOPmIa0ikykHN2ccarTwqFRAmkOKXrH13wU=; b=EFNFngq84SXiAXD8mOQZOdAVxiTzZvipJ1DLlBIfUrgN/TCmvnaE1VLCgiXz7YMXB2 sgU7dtYRpGaHCEbitjVR2WZVTyx4GWuIdHQhgANDBwk/JUrMyBgAGg6U16ymYUBnviiP 4IimJFtk3yxjGsAdM1kjKYtKIkY8LLE+WKrIHZUOXfLjXzxw2PvNXiGA+bE4Y1D78d4Q uC5dIqJshVG1xRtAnvUNmnIoLLv3q+g5YLM0RV5ZWz/yjh6j5K5CTmeHyYxtD1KrtRHg bAf54vkfUi7afn0H+v8pGEv4pEqoVSl8lE4G7ZDAVIMmo6/jAyXmwE42O6J5dDiacOoq 12/Q== X-Gm-Message-State: AC+VfDwh1dGYwRvx2/aYcK6KgMko06mGGkDgR0V2QYV6IlcEcApPXg5s 51WAp8Ni0UsxHatbeDYDPReigkaRpcyI X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:48d9:8c21:e099:7301]) (user=irogers job=sendgmr) by 2002:a17:903:710:b0:1ac:921c:87f6 with SMTP id kk16-20020a170903071000b001ac921c87f6mr2268283plb.8.1684737833230; Sun, 21 May 2023 23:43:53 -0700 (PDT) Date: Sun, 21 May 2023 23:43:15 -0700 In-Reply-To: <20230522064330.189127-1-irogers@google.com> Message-Id: <20230522064330.189127-9-irogers@google.com> Mime-Version: 1.0 References: <20230522064330.189127-1-irogers@google.com> X-Mailer: git-send-email 2.40.1.698.g37aff9b760-goog Subject: [PATCH v2 08/23] perf pmu: Rewrite perf_pmu__has_hybrid to avoid list From: Ian Rogers To: Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Kajol Jain , Jing Zhang , Kan Liang , Zhengjun Xing , Ravi Bangoria , Madhavan Srinivasan , Athira Rajeev , Ming Wang , Huacai Chen , Sandipan Das , Dmitrii Dolgov <9erthalion6@gmail.com>, Sean Christopherson , Ali Saidi , Rob Herring , Thomas Richter , Kang Minchul , linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 Rather than list empty on perf_pmu__hybrid_pmus, detect if any core PMUs match the hybrid name. Computed values held in statics to avoid recomputation. Signed-off-by: Ian Rogers --- tools/perf/util/pmu.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 930ec3786964..2da28739e0d3 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -60,8 +60,6 @@ struct perf_pmu_format { struct list_head list; }; -static bool hybrid_scanned; - static struct perf_pmu *perf_pmu__find2(int dirfd, const char *name); /* @@ -2026,12 +2024,20 @@ void perf_pmu__warn_invalid_config(struct perf_pmu *pmu, __u64 config, bool perf_pmu__has_hybrid(void) { + static bool hybrid_scanned, has_hybrid; + if (!hybrid_scanned) { + struct perf_pmu *pmu = NULL; + + while ((pmu = perf_pmu__scan(pmu)) != NULL) { + if (pmu->is_core && is_pmu_hybrid(pmu->name)) { + has_hybrid = true; + break; + } + } hybrid_scanned = true; - perf_pmu__scan(NULL); } - - return !list_empty(&perf_pmu__hybrid_pmus); + return has_hybrid; } int perf_pmu__match(char *pattern, char *name, char *tok) -- 2.40.1.698.g37aff9b760-goog