Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf pmu: Cache JSON events table

Cache the JSON events table so that finding it isn't done per
event/alias.

Change the events table find so that when the PMU is given, if the PMU
has no JSON events return null.

Update usage to always use the PMU variable.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Gaosheng Cui <cuigaosheng1@huawei.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20230824041330.266337-13-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
7c52f10c f63a536f

+25 -11
+12 -2
tools/perf/pmu-events/jevents.py
··· 948 948 { 949 949 const struct pmu_events_table *table = NULL; 950 950 char *cpuid = perf_pmu__getcpuid(pmu); 951 - int i; 951 + size_t i; 952 952 953 953 /* on some platforms which uses cpus map, cpuid can be NULL for 954 954 * PMUs other than CORE PMUs. ··· 968 968 } 969 969 } 970 970 free(cpuid); 971 - return table; 971 + if (!pmu) 972 + return table; 973 + 974 + for (i = 0; i < table->num_pmus; i++) { 975 + const struct pmu_table_entry *table_pmu = &table->pmus[i]; 976 + const char *pmu_name = &big_c_string[table_pmu->pmu_name.offset]; 977 + 978 + if (pmu__name_match(pmu, pmu_name)) 979 + return table; 980 + } 981 + return NULL; 972 982 } 973 983 974 984 const struct pmu_metrics_table *perf_pmu__find_metrics_table(struct perf_pmu *pmu)
+2
tools/perf/tests/pmu-events.c
··· 544 544 INIT_LIST_HEAD(&pmu->list); 545 545 pmu->name = strdup(pmu_name); 546 546 547 + pmu->events_table = table; 547 548 pmu_add_cpu_aliases_table(pmu, table); 548 549 549 550 res = pmu_events_table__find_event(table, pmu, "bp_l1_btb_correct", NULL, NULL); ··· 584 583 events_table = find_core_events_table("testarch", "testcpu"); 585 584 if (!events_table) 586 585 return -1; 586 + pmu->events_table = events_table; 587 587 pmu_add_cpu_aliases_table(pmu, events_table); 588 588 pmu_add_sys_aliases(pmu); 589 589
+7 -9
tools/perf/util/pmu.c
··· 522 522 } 523 523 if (!pe) { 524 524 /* Update an event from sysfs with json data. */ 525 - const struct pmu_events_table *table = perf_pmu__find_events_table(pmu); 526 - 527 - if (table) 528 - pmu_events_table__find_event(table, pmu, name, update_alias, alias); 525 + if (pmu->events_table) { 526 + pmu_events_table__find_event(pmu->events_table, pmu, name, 527 + update_alias, alias); 528 + } 529 529 } 530 530 531 531 /* Scan event and remove leading zeroes, spaces, newlines, some ··· 875 875 876 876 static void pmu_add_cpu_aliases(struct perf_pmu *pmu) 877 877 { 878 - const struct pmu_events_table *table; 879 - 880 - table = perf_pmu__find_events_table(pmu); 881 - if (!table) 878 + if (!pmu->events_table) 882 879 return; 883 880 884 - pmu_add_cpu_aliases_table(pmu, table); 881 + pmu_add_cpu_aliases_table(pmu, pmu->events_table); 885 882 } 886 883 887 884 static int pmu_add_sys_aliases_iter_fn(const struct pmu_event *pe, ··· 989 992 if (pmu->is_uncore) 990 993 pmu->id = pmu_id(name); 991 994 pmu->max_precise = pmu_max_precise(dirfd, pmu); 995 + pmu->events_table = perf_pmu__find_events_table(pmu); 992 996 pmu_add_cpu_aliases(pmu); 993 997 pmu_add_sys_aliases(pmu); 994 998 list_add_tail(&pmu->list, pmus);
+4
tools/perf/util/pmu.h
··· 114 114 * from json events in pmu-events.c. 115 115 */ 116 116 struct list_head aliases; 117 + /** 118 + * @events_table: The events table for json events in pmu-events.c. 119 + */ 120 + const struct pmu_events_table *events_table; 117 121 /** @caps_initialized: Has the list caps been initialized? */ 118 122 bool caps_initialized; 119 123 /** @nr_caps: The length of the list caps. */