Message ID | 20230524221831.1741381-34-irogers@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BCA35C77B7C for <linux-arm-kernel@archiver.kernel.org>; Wed, 24 May 2023 22:45:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version :Message-Id:In-Reply-To:Date:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rty3uYojfhlFSnOXoGwun3Ym2m0VlyV9JuKd3yKhFc4=; b=09DCIJrh436mat sEIKy739sf31uOmsGfGyZUmNOYzL0Ks1b/05fVoPOtJHPq9Y6uktdVP4BdP1WG0yCrBdFxF3Cq3xb b+E2JnUrlLsPlWRplouxNmRvGOYn4ZSO1VSzrJaqvGswjQKyW+IzNrKd1T6yRGbbXJyLe07bkowhA BnYQOKcBI1SiZJ4CMwiubqfhsuPqvwy5zIBolQU9GrKsUGIg0qrLjNe2HmkgWdP7XZpd6caef+N0L /64lNFzFwXxDc9BcsdfehCZT4fOLv8D/HxylkF8228vPpGLCS6cbjjE6UZQLlLTAnNZV2ypmmcGFT yze1dhm47ykz/ZfVuNqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q1xDh-00EqPb-2M; Wed, 24 May 2023 22:44:37 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q1xDf-00EqP0-1h for linux-arm-kernel@bombadil.infradead.org; Wed, 24 May 2023 22:44:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:To:From:Subject:References :Mime-Version:Message-Id:In-Reply-To:Date:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description; bh=dtfIK0Ng/M2Pg4C34SglSHaqm2V1d201IwuIsvGzJ2Y=; b=AnaRsP1wRBcKuCGKtUhU3fGGjI M1WYTdCixuSuQLxclq7orkd5SQvu0VCWo8AtH5GqNKNnSvO0xiN5oZ3PpVm/N3qyAsGhaiQKUz7La bImoZWBH46ZI+oqNJ2a1wlYxaHkpZPw4J4lwx1WWjYCPDyLMOVNPKuGd7YXK9pW87YCc/5EBWFhg7 Jb4Jp3UnGM3kGD6LkCgeZwSIW8adOajdRW9aKoy/R2MJ013prKRxGkVockRZmibR+4+2TyVnTh0hw hBNPZgdvopmssV34RjFioG2tNpt+nVdCeeyM1BlxuTjzISeebOBYeRxzeNcI0ROVd81zHuysw6qD+ a7jnwQnw==; Received: from mail-pj1-x1049.google.com ([2607:f8b0:4864:20::1049]) by casper.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1q1wpp-00BavT-CX for linux-arm-kernel@lists.infradead.org; Wed, 24 May 2023 22:19:59 +0000 Received: by mail-pj1-x1049.google.com with SMTP id 98e67ed59e1d1-25533eb3e84so776390a91.0 for <linux-arm-kernel@lists.infradead.org>; Wed, 24 May 2023 15:19:56 -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=dqy/Sl+U/cLlUo7Ef8KL79jrCXMOJZWStEAL+YBMZ0LpubLyO2NMOVsXhdJh3h/WJT dOkn3lrnVUQRVYmGAWqtZiuqCi8jQlD2HxjpVlryI5qseYUljb774sc0mMmF0jri7OQh Xg7poImefsrxJWtDjwlIY8z1Qp8Buxphk1Ud7Pueekh9nZ+JcpAfM3dH9gnUvffprD8P LeTnFVFBF6ThwOL3TKqqE0psx+dCtwlfbsptusQqnU3IYRiA7cwRFJNB7ldODDVhY1Tx FVk2RaiCI1/Rt8DaguHjHFgzrz4F0QfBlQKEI255UEM7ZTQoI9JDSqD4TDi7xT0ybM59 q17A== X-Gm-Message-State: AC+VfDxungA5klsnkkt/dxSMnTLOWv1RImyywT7mc4VJvv9APcOzNVrY Vm0rNSYnmuyzrQN0ujG9Wf2OVLQqu+Pv X-Google-Smtp-Source: ACHHUZ4Gz3sOCvjHJxUs0XNMvaqhY/GCtlI3yryh2ai00McLuG0za9EWtTnr4ygxbEv+fbo273yNoWXm8EPG 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 <irogers@google.com> To: Suzuki K Poulose <suzuki.poulose@arm.com>, Mike Leach <mike.leach@linaro.org>, Leo Yan <leo.yan@linaro.org>, John Garry <john.g.garry@oracle.com>, Will Deacon <will@kernel.org>, James Clark <james.clark@arm.com>, Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@redhat.com>, Arnaldo Carvalho de Melo <acme@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>, Ian Rogers <irogers@google.com>, Adrian Hunter <adrian.hunter@intel.com>, Kajol Jain <kjain@linux.ibm.com>, Jing Zhang <renyu.zj@linux.alibaba.com>, Kan Liang <kan.liang@linux.intel.com>, Zhengjun Xing <zhengjun.xing@linux.intel.com>, Ravi Bangoria <ravi.bangoria@amd.com>, Madhavan Srinivasan <maddy@linux.ibm.com>, Athira Rajeev <atrajeev@linux.vnet.ibm.com>, Ming Wang <wangming01@loongson.cn>, Huacai Chen <chenhuacai@kernel.org>, Sandipan Das <sandipan.das@amd.com>, Dmitrii Dolgov <9erthalion6@gmail.com>, Sean Christopherson <seanjc@google.com>, Ali Saidi <alisaidi@amazon.com>, Rob Herring <robh@kernel.org>, Thomas Richter <tmricht@linux.ibm.com>, Kang Minchul <tegongkang@gmail.com>, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230524_231957_475510_E45EC09E X-CRM114-Status: GOOD ( 13.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
PMU refactoring and improvements
|
expand
|
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 */
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 <irogers@google.com> --- tools/perf/util/pmus.c | 21 ++++++++++++++------- tools/perf/util/pmus.h | 1 + 2 files changed, 15 insertions(+), 7 deletions(-)