提交 d77ade9f 编写于 作者: A Andi Kleen 提交者: Arnaldo Carvalho de Melo

perf pmu: Extract function to get JSON alias map

Extract the code to get the per cpu JSON alias into a separate function
for reuse. No behavior changes.
Signed-off-by: NAndi Kleen <ak@linux.intel.com>
Acked-by: NJiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20170831194036.30146-6-andi@firstfloor.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 4ed962eb
...@@ -516,16 +516,8 @@ char * __weak get_cpuid_str(void) ...@@ -516,16 +516,8 @@ char * __weak get_cpuid_str(void)
return NULL; return NULL;
} }
/* static char *perf_pmu__getcpuid(void)
* 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.
*/
static void pmu_add_cpu_aliases(struct list_head *head, const char *name)
{ {
int i;
struct pmu_events_map *map;
struct pmu_event *pe;
char *cpuid; char *cpuid;
static bool printed; static bool printed;
...@@ -535,22 +527,50 @@ static void pmu_add_cpu_aliases(struct list_head *head, const char *name) ...@@ -535,22 +527,50 @@ static void pmu_add_cpu_aliases(struct list_head *head, const char *name)
if (!cpuid) if (!cpuid)
cpuid = get_cpuid_str(); cpuid = get_cpuid_str();
if (!cpuid) if (!cpuid)
return; return NULL;
if (!printed) { if (!printed) {
pr_debug("Using CPUID %s\n", cpuid); pr_debug("Using CPUID %s\n", cpuid);
printed = true; printed = true;
} }
return cpuid;
}
struct pmu_events_map *perf_pmu__find_map(void)
{
struct pmu_events_map *map;
char *cpuid = perf_pmu__getcpuid();
int i;
i = 0; i = 0;
while (1) { for (;;) {
map = &pmu_events_map[i++]; map = &pmu_events_map[i++];
if (!map->table) if (!map->table) {
goto out; map = NULL;
break;
}
if (!strcmp(map->cpuid, cpuid)) if (!strcmp(map->cpuid, cpuid))
break; break;
} }
free(cpuid);
return map;
}
/*
* 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.
*/
static void pmu_add_cpu_aliases(struct list_head *head, const char *name)
{
int i;
struct pmu_events_map *map;
struct pmu_event *pe;
map = perf_pmu__find_map();
if (!map)
return;
/* /*
* Found a matching PMU events table. Create aliases * Found a matching PMU events table. Create aliases
...@@ -575,9 +595,6 @@ static void pmu_add_cpu_aliases(struct list_head *head, const char *name) ...@@ -575,9 +595,6 @@ static void pmu_add_cpu_aliases(struct list_head *head, const char *name)
(char *)pe->metric_expr, (char *)pe->metric_expr,
(char *)pe->metric_name); (char *)pe->metric_name);
} }
out:
free(cpuid);
} }
struct perf_event_attr * __weak struct perf_event_attr * __weak
......
...@@ -90,4 +90,6 @@ int perf_pmu__test(void); ...@@ -90,4 +90,6 @@ int perf_pmu__test(void);
struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu); struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu);
struct pmu_events_map *perf_pmu__find_map(void);
#endif /* __PMU_H */ #endif /* __PMU_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册