lkml.org 
[lkml]   [2024]   [May]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] perf pmu: Fix num_events calculation
Date
When pe is NULL in the function perf_pmu__new_alias(), the total number
of events is added to loaded_json_aliases. However, if pmu->events_table
is NULL and cpu_aliases_added is false, the calculation for the events
number in perf_pmu__num_events() is incorrect.

Then cause the error report after "perf list":
Unexpected event smmuv3_pmcg_3f062/smmuv3_pmcg_3f062/transaction//

Fix it by adding loaded_json_aliases in the calculation under the
mentioned conditions.

Test it also with "perf bench internals pmu-scan" and there is no
regression.

Fixes: e6ff1eed3584 ("perf pmu: Lazily add JSON events")
Signed-off-by: Jia He <justin.he@arm.com>
---
tools/perf/util/pmu.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index a1eef7b2e389..a53224e2ce7e 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -1639,6 +1639,8 @@ size_t perf_pmu__num_events(struct perf_pmu *pmu)
nr += pmu->loaded_json_aliases;
else if (pmu->events_table)
nr += pmu_events_table__num_events(pmu->events_table, pmu) - pmu->loaded_json_aliases;
+ else
+ nr += pmu->loaded_json_aliases;

return pmu->selectable ? nr + 1 : nr;
}
--
2.34.1

\
 
 \ /
  Last update: 2024-05-27 18:23    [W:0.074 / U:0.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site