Skip to content

Commit e45ad70

Browse files
John Garryacmel
authored andcommitted
perf pmu: Refactor pmu_add_cpu_aliases()
Create pmu_add_cpu_aliases_map() from pmu_add_cpu_aliases(), so the caller can pass the map; the pmu-events test would use this since there would be no CPUID matching to a mapfile there. Signed-off-by: John Garry <[email protected]> Acked-by: Jiri Olsa <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: James Clark <[email protected]> Cc: Joakim Zhang <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Will Deacon <[email protected]> Cc: [email protected] Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent d844780 commit e45ad70

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

tools/perf/util/pmu.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "pmu.h"
2222
#include "parse-events.h"
2323
#include "header.h"
24-
#include "pmu-events/pmu-events.h"
2524
#include "string2.h"
2625
#include "strbuf.h"
2726
#include "fncache.h"
@@ -744,16 +743,11 @@ static bool pmu_uncore_alias_match(const char *pmu_name, const char *name)
744743
* to the current running CPU. Then, add all PMU events from that table
745744
* as aliases.
746745
*/
747-
static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
746+
void pmu_add_cpu_aliases_map(struct list_head *head, struct perf_pmu *pmu,
747+
struct pmu_events_map *map)
748748
{
749749
int i;
750-
struct pmu_events_map *map;
751750
const char *name = pmu->name;
752-
753-
map = perf_pmu__find_map(pmu);
754-
if (!map)
755-
return;
756-
757751
/*
758752
* Found a matching PMU events table. Create aliases
759753
*/
@@ -788,6 +782,17 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
788782
}
789783
}
790784

785+
static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)
786+
{
787+
struct pmu_events_map *map;
788+
789+
map = perf_pmu__find_map(pmu);
790+
if (!map)
791+
return;
792+
793+
pmu_add_cpu_aliases_map(head, pmu, map);
794+
}
795+
791796
struct perf_event_attr * __weak
792797
perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused)
793798
{

tools/perf/util/pmu.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/perf_event.h>
88
#include <stdbool.h>
99
#include "parse-events.h"
10+
#include "pmu-events/pmu-events.h"
1011

1112
struct perf_evsel_config_term;
1213

@@ -97,6 +98,8 @@ int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt,
9798
int perf_pmu__test(void);
9899

99100
struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu);
101+
void pmu_add_cpu_aliases_map(struct list_head *head, struct perf_pmu *pmu,
102+
struct pmu_events_map *map);
100103

101104
struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu);
102105

0 commit comments

Comments
 (0)