diff options
author | Cody P Schafer <cody@linux.vnet.ibm.com> | 2015-01-30 16:45:57 -0500 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2015-02-02 01:56:36 -0500 |
commit | fd979c0132074856975a6e79bc2226b99435ec5b (patch) | |
tree | ad01ab6039dec30b6e1180759b435f84cd2780b0 | |
parent | fe12545e7650de5332b5522a62686fab8bafc733 (diff) |
perf: provide sysfs_show for struct perf_pmu_events_attr
(struct perf_pmu_events_attr) is defined in include/linux/perf_event.h,
but the only "show" for it is in x86 and contains x86 specific stuff.
Make a generic one for those of us who are just using the event_str.
Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com>
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r-- | include/linux/perf_event.h | 3 | ||||
-rw-r--r-- | kernel/events/core.c | 12 |
2 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 486e84ccb1f9..58f59bdb590b 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h | |||
@@ -897,6 +897,9 @@ struct perf_pmu_events_attr { | |||
897 | const char *event_str; | 897 | const char *event_str; |
898 | }; | 898 | }; |
899 | 899 | ||
900 | ssize_t perf_event_sysfs_show(struct device *dev, struct device_attribute *attr, | ||
901 | char *page); | ||
902 | |||
900 | #define PMU_EVENT_ATTR(_name, _var, _id, _show) \ | 903 | #define PMU_EVENT_ATTR(_name, _var, _id, _show) \ |
901 | static struct perf_pmu_events_attr _var = { \ | 904 | static struct perf_pmu_events_attr _var = { \ |
902 | .attr = __ATTR(_name, 0444, _show, NULL), \ | 905 | .attr = __ATTR(_name, 0444, _show, NULL), \ |
diff --git a/kernel/events/core.c b/kernel/events/core.c index 4c1ee7f2bebc..934687f8d51b 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -8276,6 +8276,18 @@ void __init perf_event_init(void) | |||
8276 | != 1024); | 8276 | != 1024); |
8277 | } | 8277 | } |
8278 | 8278 | ||
8279 | ssize_t perf_event_sysfs_show(struct device *dev, struct device_attribute *attr, | ||
8280 | char *page) | ||
8281 | { | ||
8282 | struct perf_pmu_events_attr *pmu_attr = | ||
8283 | container_of(attr, struct perf_pmu_events_attr, attr); | ||
8284 | |||
8285 | if (pmu_attr->event_str) | ||
8286 | return sprintf(page, "%s\n", pmu_attr->event_str); | ||
8287 | |||
8288 | return 0; | ||
8289 | } | ||
8290 | |||
8279 | static int __init perf_event_sysfs_init(void) | 8291 | static int __init perf_event_sysfs_init(void) |
8280 | { | 8292 | { |
8281 | struct pmu *pmu; | 8293 | struct pmu *pmu; |