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: Prefer passing pmu to aliases list

The aliases list is part of the PMU. Rather than pass the aliases
list, pass the full PMU simplifying some callbacks.

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-11-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
f26d22f1 edb217ff

+16 -28
+16 -28
tools/perf/util/pmu.c
··· 435 435 /* Merge an alias, search in alias list. If this name is already 436 436 * present merge both of them to combine all information. 437 437 */ 438 - static bool perf_pmu_merge_alias(struct perf_pmu_alias *newalias, 439 - struct list_head *alist) 438 + static bool perf_pmu_merge_alias(struct perf_pmu *pmu, 439 + struct perf_pmu_alias *newalias) 440 440 { 441 441 struct perf_pmu_alias *a; 442 442 443 - list_for_each_entry(a, alist, list) { 443 + list_for_each_entry(a, &pmu->aliases, list) { 444 444 if (!strcasecmp(newalias->name, a->name)) { 445 445 if (newalias->pmu_name && a->pmu_name && 446 446 !strcasecmp(newalias->pmu_name, a->pmu_name)) { ··· 454 454 return false; 455 455 } 456 456 457 - static int perf_pmu__new_alias(struct list_head *list, int dirfd, const char *name, 457 + static int perf_pmu__new_alias(struct perf_pmu *pmu, int dirfd, const char *name, 458 458 const char *desc, const char *val, FILE *val_fd, 459 459 const struct pmu_event *pe) 460 460 { ··· 536 536 alias->str = strdup(newval); 537 537 alias->pmu_name = pmu_name ? strdup(pmu_name) : NULL; 538 538 539 - if (!perf_pmu_merge_alias(alias, list)) 540 - list_add_tail(&alias->list, list); 539 + if (!perf_pmu_merge_alias(pmu, alias)) 540 + list_add_tail(&alias->list, &pmu->aliases); 541 541 542 542 return 0; 543 543 } ··· 563 563 * Process all the sysfs attributes located under the directory 564 564 * specified in 'dir' parameter. 565 565 */ 566 - static int pmu_aliases_parse(int dirfd, struct list_head *head) 566 + static int pmu_aliases_parse(struct perf_pmu *pmu, int dirfd) 567 567 { 568 568 struct dirent *evt_ent; 569 569 DIR *event_dir; ··· 597 597 continue; 598 598 } 599 599 600 - if (perf_pmu__new_alias(head, dirfd, name, /*desc=*/ NULL, 600 + if (perf_pmu__new_alias(pmu, dirfd, name, /*desc=*/ NULL, 601 601 /*val=*/ NULL, file, /*pe=*/ NULL) < 0) 602 602 pr_debug("Cannot set up %s\n", name); 603 603 fclose(file); ··· 620 620 return 0; 621 621 622 622 /* it'll close the fd */ 623 - if (pmu_aliases_parse(fd, &pmu->aliases)) 623 + if (pmu_aliases_parse(pmu, fd)) 624 624 return -1; 625 625 626 626 return 0; ··· 848 848 const struct pmu_events_table *table __maybe_unused, 849 849 void *vdata) 850 850 { 851 - struct list_head *head = vdata; 851 + struct perf_pmu *pmu = vdata; 852 852 853 - /* need type casts to override 'const' */ 854 - perf_pmu__new_alias(head, -1, pe->name, pe->desc, pe->event, /*val_fd=*/ NULL, pe); 853 + perf_pmu__new_alias(pmu, -1, pe->name, pe->desc, pe->event, /*val_fd=*/ NULL, pe); 855 854 return 0; 856 855 } 857 856 ··· 860 861 */ 861 862 void pmu_add_cpu_aliases_table(struct perf_pmu *pmu, const struct pmu_events_table *table) 862 863 { 863 - pmu_events_table__for_each_event(table, pmu, pmu_add_cpu_aliases_map_callback, &pmu->aliases); 864 + pmu_events_table__for_each_event(table, pmu, pmu_add_cpu_aliases_map_callback, pmu); 864 865 } 865 866 866 867 static void pmu_add_cpu_aliases(struct perf_pmu *pmu) ··· 874 875 pmu_add_cpu_aliases_table(pmu, table); 875 876 } 876 877 877 - struct pmu_sys_event_iter_data { 878 - struct list_head *head; 879 - struct perf_pmu *pmu; 880 - }; 881 - 882 878 static int pmu_add_sys_aliases_iter_fn(const struct pmu_event *pe, 883 879 const struct pmu_events_table *table __maybe_unused, 884 - void *data) 880 + void *vdata) 885 881 { 886 - struct pmu_sys_event_iter_data *idata = data; 887 - struct perf_pmu *pmu = idata->pmu; 882 + struct perf_pmu *pmu = vdata; 888 883 889 884 if (!pe->compat || !pe->pmu) 890 885 return 0; 891 886 892 887 if (!strcmp(pmu->id, pe->compat) && 893 888 pmu_uncore_alias_match(pe->pmu, pmu->name)) { 894 - perf_pmu__new_alias(idata->head, -1, 889 + perf_pmu__new_alias(pmu, -1, 895 890 pe->name, 896 891 pe->desc, 897 892 pe->event, ··· 898 905 899 906 void pmu_add_sys_aliases(struct perf_pmu *pmu) 900 907 { 901 - struct pmu_sys_event_iter_data idata = { 902 - .head = &pmu->aliases, 903 - .pmu = pmu, 904 - }; 905 - 906 908 if (!pmu->id) 907 909 return; 908 910 909 - pmu_for_each_sys_event(pmu_add_sys_aliases_iter_fn, &idata); 911 + pmu_for_each_sys_event(pmu_add_sys_aliases_iter_fn, pmu); 910 912 } 911 913 912 914 struct perf_event_attr * __weak