Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf: New helper function for pmu name

Introduce perf_pmu_name() helper function that returns the name of the
pmu. This gives us a generic way to get the name of a pmu regardless of
how an architecture identifies it internally.

Signed-off-by: Matt Fleming <matt@console-pimps.org>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: Robert Richter <robert.richter@amd.com>

authored by

Matt Fleming and committed by
Robert Richter
84c79910 3bf101ba

+15
+9
arch/sh/kernel/perf_event.c
··· 59 59 return !!sh_pmu; 60 60 } 61 61 62 + const char *perf_pmu_name(void) 63 + { 64 + if (!sh_pmu) 65 + return NULL; 66 + 67 + return sh_pmu->name; 68 + } 69 + EXPORT_SYMBOL_GPL(perf_pmu_name); 70 + 62 71 int perf_num_counters(void) 63 72 { 64 73 if (!sh_pmu)
+1
include/linux/perf_event.h
··· 850 850 extern const struct pmu *hw_perf_event_init(struct perf_event *event); 851 851 852 852 extern int perf_num_counters(void); 853 + extern const char *perf_pmu_name(void); 853 854 extern void perf_event_task_sched_in(struct task_struct *task); 854 855 extern void perf_event_task_sched_out(struct task_struct *task, struct task_struct *next); 855 856 extern void perf_event_task_tick(struct task_struct *task);
+5
kernel/perf_event.c
··· 85 85 86 86 void __weak perf_event_print_debug(void) { } 87 87 88 + extern __weak const char *perf_pmu_name(void) 89 + { 90 + return "pmu"; 91 + } 92 + 88 93 static DEFINE_PER_CPU(int, perf_disable_count); 89 94 90 95 void perf_disable(void)