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

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>

authored by

Cody P Schafer and committed by
Michael Ellerman
fd979c01 fe12545e

+15
+3
include/linux/perf_event.h
··· 897 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 903 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \ 901 904 static struct perf_pmu_events_attr _var = { \ 902 905 .attr = __ATTR(_name, 0444, _show, NULL), \
+12
kernel/events/core.c
··· 8276 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 8291 static int __init perf_event_sysfs_init(void) 8280 8292 { 8281 8293 struct pmu *pmu;