[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d25f9ef8-b9b7-d632-8ecf-d60f2b255c8b@huawei.com>
Date: Mon, 16 Oct 2023 17:50:10 +0800
From: Yang Jihong <yangjihong1@...wei.com>
To: Ian Rogers <irogers@...gle.com>,
Suzuki K Poulose <suzuki.poulose@....com>,
Mike Leach <mike.leach@...aro.org>,
James Clark <james.clark@....com>,
Leo Yan <leo.yan@...aro.org>,
John Garry <john.g.garry@...cle.com>,
Will Deacon <will@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Adrian Hunter <adrian.hunter@...el.com>,
Thomas Richter <tmricht@...ux.ibm.com>,
Ravi Bangoria <ravi.bangoria@....com>,
Kajol Jain <kjain@...ux.ibm.com>,
Jing Zhang <renyu.zj@...ux.alibaba.com>,
Kan Liang <kan.liang@...ux.intel.com>,
<coresight@...ts.linaro.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-perf-users@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 6/7] perf pmu-events: Remember the perf_events_map for
a PMU
Hello,
On 2023/10/13 1:56, Ian Rogers wrote:
> strcmp_cpuid_str performs regular expression comparisons and so per
> CPUID linear searches over the perf_events_map are expensive. Add a
> helper function called map_for_pmu that does the search but also
> caches the map specific to a PMU. As the PMU may differ, also cache
> the CPUID string so that PMUs with the same CPUID string don't require
> the linear search and regular expression comparisons. This speeds
> loading PMUs as the search is done once per PMU to find the
> appropriate tables.
>
> Signed-off-by: Ian Rogers <irogers@...gle.com>
> ---
> tools/perf/pmu-events/jevents.py | 109 ++++++++++++++++++++-----------
> 1 file changed, 70 insertions(+), 39 deletions(-)
>
> diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
> index 96dc74c90b20..3c091ab75305 100755
> --- a/tools/perf/pmu-events/jevents.py
> +++ b/tools/perf/pmu-events/jevents.py
> @@ -976,68 +976,99 @@ int pmu_metrics_table__for_each_metric(const struct pmu_metrics_table *table,
> return 0;
> }
>
> -const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu)
> +static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu)
> {
> - const struct pmu_events_table *table = NULL;
> - char *cpuid = perf_pmu__getcpuid(pmu);
> + static struct {
> + const struct pmu_events_map *map;
> + struct perf_pmu *pmu;
> + } last_result;
> + static struct {
> + const struct pmu_events_map *map;
> + char *cpuid;
> + } last_map_search;
> + static bool has_last_result, has_last_map_search;
> + const struct pmu_events_map *map = NULL;
> + char *cpuid = NULL;
> size_t i;
>
> - /* on some platforms which uses cpus map, cpuid can be NULL for
> + if (has_last_result && last_result.pmu == pmu)
> + return last_result.map;
> +
> + cpuid = perf_pmu__getcpuid(pmu);
For the software pmu, we do not need to look for the events table.
It seems that the software pmu can be filtered out in perf_pmu__lookup()
to reduce unnecessary perf_pmu__find_events_table() calls.
I tried to submit a patch, please see if it helps:
https://lore.kernel.org/all/20231016093309.726436-1-yangjihong1@huawei.com/
Thanks,
Yang
Powered by blists - more mailing lists