Commit 84c7991059c9c4530cc911137c5bf508a41ed129

Authored by Matt Fleming
Committed by Robert Richter
1 parent 3bf101ba42

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>

Showing 3 changed files with 15 additions and 0 deletions Side-by-side Diff

arch/sh/kernel/perf_event.c
... ... @@ -59,6 +59,15 @@
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)
include/linux/perf_event.h
... ... @@ -850,6 +850,7 @@
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);
... ... @@ -85,6 +85,11 @@
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)