[PATCH] perf pmu: Filter out search events table of software pmu in perf_pmu__lookup()

From: Yang Jihong
Date: Mon Oct 16 2023 - 05:35:02 EST


For software pmu, the events_table is empty, reducing unnecessary search.

Signed-off-by: Yang Jihong <yangjihong1@xxxxxxxxxx>
---
tools/perf/util/pmu.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 6428e2648289..59c8394a4efa 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -1033,7 +1033,8 @@ struct perf_pmu *perf_pmu__lookup(struct list_head *pmus, int dirfd, const char
pmu->id = pmu_id(name);
pmu->max_precise = pmu_max_precise(dirfd, pmu);
pmu->alias_name = pmu_find_alias_name(pmu, dirfd);
- pmu->events_table = perf_pmu__find_events_table(pmu);
+ if (!perf_pmu__is_software(pmu))
+ pmu->events_table = perf_pmu__find_events_table(pmu);
pmu_add_sys_aliases(pmu);
list_add_tail(&pmu->list, pmus);

--
2.34.1