Skip to content

Commit 0434410

Browse files
captain5050acmel
authored andcommitted
perf jevents: Add map_for_cpu()
The PMU is no longer part of the map finding process and for metrics doesn't make sense as they lack a PMU. Reviewed-by: James Clark <[email protected]> Signed-off-by: Ian Rogers <[email protected]> Tested-by: Xu Yang <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Albert Ou <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Alexandre Ghiti <[email protected]> Cc: Athira Rajeev <[email protected]> Cc: Ben Zong-You Xie <[email protected]> Cc: Benjamin Gray <[email protected]> Cc: Bibo Mao <[email protected]> Cc: Clément Le Goffic <[email protected]> Cc: Dima Kogan <[email protected]> Cc: Dr. David Alan Gilbert <[email protected]> Cc: Huacai Chen <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: John Garry <[email protected]> Cc: Kan Liang <[email protected]> Cc: Leo Yan <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Mike Leach <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Ravi Bangoria <[email protected]> Cc: Sandipan Das <[email protected]> Cc: Will Deacon <[email protected]> Cc: Yicong Yang <[email protected]> Cc: [email protected] Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 494c403 commit 0434410

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

tools/perf/pmu-events/empty-pmu-events.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -503,27 +503,24 @@ int pmu_metrics_table__for_each_metric(const struct pmu_metrics_table *table,
503503
return 0;
504504
}
505505

506-
static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu)
506+
static const struct pmu_events_map *map_for_cpu(struct perf_cpu cpu)
507507
{
508508
static struct {
509509
const struct pmu_events_map *map;
510-
struct perf_pmu *pmu;
510+
struct perf_cpu cpu;
511511
} last_result;
512512
static struct {
513513
const struct pmu_events_map *map;
514514
char *cpuid;
515515
} last_map_search;
516516
static bool has_last_result, has_last_map_search;
517517
const struct pmu_events_map *map = NULL;
518-
struct perf_cpu cpu = {-1};
519518
char *cpuid = NULL;
520519
size_t i;
521520

522-
if (has_last_result && last_result.pmu == pmu)
521+
if (has_last_result && last_result.cpu.cpu == cpu.cpu)
523522
return last_result.map;
524523

525-
if (pmu)
526-
cpu = perf_cpu_map__min(pmu->cpus);
527524
cpuid = get_cpuid_allow_env_override(cpu);
528525

529526
/*
@@ -555,12 +552,21 @@ static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu)
555552
has_last_map_search = true;
556553
}
557554
out_update_last_result:
558-
last_result.pmu = pmu;
555+
last_result.cpu = cpu;
559556
last_result.map = map;
560557
has_last_result = true;
561558
return map;
562559
}
563560

561+
static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu)
562+
{
563+
struct perf_cpu cpu = {-1};
564+
565+
if (pmu)
566+
cpu = perf_cpu_map__min(pmu->cpus);
567+
return map_for_cpu(cpu);
568+
}
569+
564570
const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu)
565571
{
566572
const struct pmu_events_map *map = map_for_pmu(pmu);

tools/perf/pmu-events/jevents.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,27 +1019,24 @@ def print_system_mapping_table() -> None:
10191019
return 0;
10201020
}
10211021
1022-
static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu)
1022+
static const struct pmu_events_map *map_for_cpu(struct perf_cpu cpu)
10231023
{
10241024
static struct {
10251025
const struct pmu_events_map *map;
1026-
struct perf_pmu *pmu;
1026+
struct perf_cpu cpu;
10271027
} last_result;
10281028
static struct {
10291029
const struct pmu_events_map *map;
10301030
char *cpuid;
10311031
} last_map_search;
10321032
static bool has_last_result, has_last_map_search;
10331033
const struct pmu_events_map *map = NULL;
1034-
struct perf_cpu cpu = {-1};
10351034
char *cpuid = NULL;
10361035
size_t i;
10371036
1038-
if (has_last_result && last_result.pmu == pmu)
1037+
if (has_last_result && last_result.cpu.cpu == cpu.cpu)
10391038
return last_result.map;
10401039
1041-
if (pmu)
1042-
cpu = perf_cpu_map__min(pmu->cpus);
10431040
cpuid = get_cpuid_allow_env_override(cpu);
10441041
10451042
/*
@@ -1071,12 +1068,21 @@ def print_system_mapping_table() -> None:
10711068
has_last_map_search = true;
10721069
}
10731070
out_update_last_result:
1074-
last_result.pmu = pmu;
1071+
last_result.cpu = cpu;
10751072
last_result.map = map;
10761073
has_last_result = true;
10771074
return map;
10781075
}
10791076
1077+
static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu)
1078+
{
1079+
struct perf_cpu cpu = {-1};
1080+
1081+
if (pmu)
1082+
cpu = perf_cpu_map__min(pmu->cpus);
1083+
return map_for_cpu(cpu);
1084+
}
1085+
10801086
const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu)
10811087
{
10821088
const struct pmu_events_map *map = map_for_pmu(pmu);

0 commit comments

Comments
 (0)