Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp149453rwd; Wed, 24 May 2023 15:46:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ41Xde0vKVbFPJjJYqq3gKr3g1EvvtASkCuXrv+j+SgfMmMHf6hDoq33vGvz0tzbXkjtToF X-Received: by 2002:a05:6a20:c791:b0:106:25b3:2f92 with SMTP id hk17-20020a056a20c79100b0010625b32f92mr17997201pzb.52.1684968406768; Wed, 24 May 2023 15:46:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684968406; cv=none; d=google.com; s=arc-20160816; b=hIo5oGz/+m6Q9Z1Qf/umWKyK6n5J5y2EG2MHnm8r2td3t1W4NiK6N1SYQ4mwE4a7a+ dtgRkan3ctHkDmD89M3D/kTDDqR1EbhLoQwjxXQHu20aYhhYsHw4B+quDeywl15rg2+E ocnx80QKAMCkkDJ13Iwe6WmGZCnYaUgmRJVxDUFmFx5VGeRNd3I+CuypRe8go6yJNzq4 cDYilMV10BCQxAxAoR9w37TCOOBbNL9x+vS92Cqd6mai0CyxRSnKjb+030d/RjiURBuO U5DHw1qy5c3HNxYNVL77ui0S1wDrkr5XpJ/KaCvkFa9uLS/4dlgclmMPexEp2lmW5PVN XPLQ== 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=dtfIK0Ng/M2Pg4C34SglSHaqm2V1d201IwuIsvGzJ2Y=; b=Emg+SML8zTC2dyzF1D4nX+uf7L2FrV+VFS244aahR9e6P9fbWZof+JOAYRjgr81XiA PSDnmsyE72QpLt9YLRMjVU+hYJFVaGUbhWDektHXWb86e4lRRotZuffDqbro8hJIyU6+ M7NAwfn+ioB2wEMrnj4ntuAbkMlItCQ2ELBGapbv1CHTir0sVoO2uZwfp7+PFR3w58Tc whSbvDG/fwn7EiezOgaZ9dgzCrVnT5TJ1zsH8P7oSro6eNm0wzChK6LrxlBdTOSoJr0H pypG7d1lI6eUhyiYy719OSIjljSk0xC8BYpcZ+A/3qAoKQa/mE0YjNGFaAsbQH5ZA+uz ctpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=jZqOUs4k; 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 g71-20020a636b4a000000b00502f0d858e9si7529448pgc.174.2023.05.24.15.46.34; Wed, 24 May 2023 15:46:46 -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=jZqOUs4k; 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 S238427AbjEXWWc (ORCPT + 99 others); Wed, 24 May 2023 18:22:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238307AbjEXWWH (ORCPT ); Wed, 24 May 2023 18:22:07 -0400 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D29DE6F for ; Wed, 24 May 2023 15:21:13 -0700 (PDT) Received: by mail-pj1-x1049.google.com with SMTP id 98e67ed59e1d1-255dfed764dso765811a91.1 for ; Wed, 24 May 2023 15:21:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684966792; x=1687558792; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=dtfIK0Ng/M2Pg4C34SglSHaqm2V1d201IwuIsvGzJ2Y=; b=jZqOUs4khalhefWZA9ZH5Cd3Ak1pZuDgONShr5OBFfs90o9+6fZ+v/uPtshEsqbn5D cSeOiEQMwnIcIpdU4Q9uR4gXcwb67sUxfNNC6qgG8f+UFz+3ChzROoXCnoGdMTgpHS5j fKudJ7McBlaqp4uNamm9fScATnN3d//SXLTOCFVT2WAAIzGn+4ffUzdWYkIw+VZB5O55 aAq3mAUfDSxUhzH00Y5i8001CewqddXbVpPRVEXJrQaq9Ij2DKPsdrDvX992n2uziLlo qW/TBZCbnVYFlkw+ZvwdbbEFnTlA+wBYepun9M9kdevhU8ALCHQ19BTnnoJBQ4rWdozH CXzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684966792; x=1687558792; 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=dtfIK0Ng/M2Pg4C34SglSHaqm2V1d201IwuIsvGzJ2Y=; b=YCAFO3eSEj9RfW9Uhgx87rt9u/1/qlbIiuxRG2WHIoSUyPDpt+W91m9MkKm9dxjqDd zw4TCwFdEJZznp9OuiWfK1LmTvuiyskbYsdPmGry6cMroFDPzeOkbpOJhRlRaEiaU4rQ 86tGL8HGp0r2FdQ9RN+6g7VPbmdoyg3GSQrxBiO4R042n9ZkIjfpxFxyN1bGnuT5Wwjx ylzGGHyAqCyj9yAZUCQtXnsNM9Ig7v5HVoWQrHDSVBwUeDr+csp+vyKvam7WftidD12C rIwpY2Hh64P9FuzoJDw84UaoHrpbDu8ps67p/S5SKXfeWmTdPlbTw3jJZZx05YRhejIl Fgvg== X-Gm-Message-State: AC+VfDx/K+4cUMppeJx1BaLkjmqmmpBbziwp+9ne7m7/md7nsO3Vv4Vj 39Gj1cIvvnbs/TUSas0E3VvQManG6N93 X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:7aa7:3d2d:76ae:8e96]) (user=irogers job=sendgmr) by 2002:a17:90a:2e12:b0:253:2388:9d44 with SMTP id q18-20020a17090a2e1200b0025323889d44mr4425400pjd.9.1684966791898; Wed, 24 May 2023 15:19:51 -0700 (PDT) Date: Wed, 24 May 2023 15:18:29 -0700 In-Reply-To: <20230524221831.1741381-1-irogers@google.com> Message-Id: <20230524221831.1741381-34-irogers@google.com> Mime-Version: 1.0 References: <20230524221831.1741381-1-irogers@google.com> X-Mailer: git-send-email 2.40.1.698.g37aff9b760-goog Subject: [PATCH v3 33/35] perf pmus: Add function to return count of core PMUs 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 Add perf_pmus__num_core_pmus that will count core PMUs holding the result in a static. Reuse for perf_pmus__num_mem_pmus. Signed-off-by: Ian Rogers --- tools/perf/util/pmus.c | 21 ++++++++++++++------- tools/perf/util/pmus.h | 1 + 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/tools/perf/util/pmus.c b/tools/perf/util/pmus.c index 6ecccb5ad03e..bf927aed162e 100644 --- a/tools/perf/util/pmus.c +++ b/tools/perf/util/pmus.c @@ -229,14 +229,8 @@ const struct perf_pmu *perf_pmus__pmu_for_pmu_filter(const char *str) int perf_pmus__num_mem_pmus(void) { - struct perf_pmu *pmu = NULL; - int count = 0; - /* All core PMUs are for mem events. */ - while ((pmu = perf_pmus__scan_core(pmu)) != NULL) - count++; - - return count; + return perf_pmus__num_core_pmus(); } /** Struct for ordering events as output in perf list. */ @@ -488,6 +482,19 @@ bool perf_pmus__has_hybrid(void) return has_hybrid; } +int perf_pmus__num_core_pmus(void) +{ + static int count; + + if (!count) { + struct perf_pmu *pmu = NULL; + + while ((pmu = perf_pmus__scan_core(pmu)) != NULL) + count++; + } + return count; +} + struct perf_pmu *evsel__find_pmu(const struct evsel *evsel) { struct perf_pmu *pmu = evsel->pmu; diff --git a/tools/perf/util/pmus.h b/tools/perf/util/pmus.h index 9de0222ed52b..27400a027d41 100644 --- a/tools/perf/util/pmus.h +++ b/tools/perf/util/pmus.h @@ -19,5 +19,6 @@ int perf_pmus__num_mem_pmus(void); void perf_pmus__print_pmu_events(const struct print_callbacks *print_cb, void *print_state); bool perf_pmus__have_event(const char *pname, const char *name); bool perf_pmus__has_hybrid(void); +int perf_pmus__num_core_pmus(void); #endif /* __PMUS_H */ -- 2.40.1.698.g37aff9b760-goog