mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-27 04:22:58 +00:00
perf pmus: Add notion of default PMU for JSON events
JSON events created in pmu-events.c by jevents.py may not specify a PMU they are associated with, in which case it is implied that it is the first core PMU. Care is needed to select this for regular 'cpu', s390 'cpum_cf' and ARMs many names as at the point the name is first needed the core PMUs list hasn't been initialized. Add a helper in perf_pmus to create this value, in the worst case by scanning sysfs. v2. Add missing close if fdopendir fails. Signed-off-by: Ian Rogers <irogers@google.com> Tested-by: Thomas Richter <tmricht@linux.ibm.com> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: James Clark <james.clark@arm.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Thomas Richter <tmricht@linux.ibm.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Ingo Molnar <mingo@redhat.com> Link: https://lore.kernel.org/r/20230623043843.4080180-1-irogers@google.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
This commit is contained in:
@@ -741,9 +741,11 @@ out:
|
||||
}
|
||||
|
||||
struct pmu_add_cpu_aliases_map_data {
|
||||
/* List being added to. */
|
||||
struct list_head *head;
|
||||
const char *name;
|
||||
const char *cpu_name;
|
||||
/* If a pmu_event lacks a given PMU the default used. */
|
||||
char *default_pmu_name;
|
||||
/* The PMU that we're searching for events for. */
|
||||
struct perf_pmu *pmu;
|
||||
};
|
||||
|
||||
@@ -752,37 +754,32 @@ static int pmu_add_cpu_aliases_map_callback(const struct pmu_event *pe,
|
||||
void *vdata)
|
||||
{
|
||||
struct pmu_add_cpu_aliases_map_data *data = vdata;
|
||||
const char *pname = pe->pmu ? pe->pmu : data->cpu_name;
|
||||
const char *pname = pe->pmu ?: data->default_pmu_name;
|
||||
|
||||
if (data->pmu->is_uncore && pmu_uncore_alias_match(pname, data->name))
|
||||
goto new_alias;
|
||||
|
||||
if (strcmp(pname, data->name))
|
||||
return 0;
|
||||
|
||||
new_alias:
|
||||
/* need type casts to override 'const' */
|
||||
__perf_pmu__new_alias(data->head, -1, (char *)pe->name, (char *)pe->desc,
|
||||
(char *)pe->event, pe);
|
||||
if (!strcmp(pname, data->pmu->name) ||
|
||||
(data->pmu->is_uncore && pmu_uncore_alias_match(pname, data->pmu->name))) {
|
||||
/* need type casts to override 'const' */
|
||||
__perf_pmu__new_alias(data->head, -1, (char *)pe->name, (char *)pe->desc,
|
||||
(char *)pe->event, pe);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* From the pmu_events_map, find the table of PMU events that corresponds
|
||||
* to the current running CPU. Then, add all PMU events from that table
|
||||
* as aliases.
|
||||
* From the pmu_events_table, find the events that correspond to the given
|
||||
* PMU and add them to the list 'head'.
|
||||
*/
|
||||
void pmu_add_cpu_aliases_table(struct list_head *head, struct perf_pmu *pmu,
|
||||
const struct pmu_events_table *table)
|
||||
const struct pmu_events_table *table)
|
||||
{
|
||||
struct pmu_add_cpu_aliases_map_data data = {
|
||||
.head = head,
|
||||
.name = pmu->name,
|
||||
.cpu_name = is_sysfs_pmu_core(pmu->name) ? pmu->name : "cpu",
|
||||
.default_pmu_name = perf_pmus__default_pmu_name(),
|
||||
.pmu = pmu,
|
||||
};
|
||||
|
||||
pmu_events_table_for_each_event(table, pmu_add_cpu_aliases_map_callback, &data);
|
||||
free(data.default_pmu_name);
|
||||
}
|
||||
|
||||
static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
|
||||
|
||||
Reference in New Issue
Block a user