Commit c7168325 authored by Hendrik Brueckner's avatar Hendrik Brueckner Committed by Martin Schwidefsky

s390/cpum_cf: Export event names in sysfs

Provide PMU event attributes for supported counters and export their symbolic
names to the sysfs "events" directory.

See the /sys/devices/cpum_cf/events/ directory for a list of available counters.
Note that you might require counter set authorizations for the LPAR to use them.
Signed-off-by: default avatarHendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent cf48ad83
/*
* Performance event support - s390 specific definitions.
*
* Copyright IBM Corp. 2009, 2012
* Copyright IBM Corp. 2009, 2013
* Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
* Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
*/
#ifndef _ASM_S390_PERF_EVENT_H
#define _ASM_S390_PERF_EVENT_H
#ifdef CONFIG_64BIT
#include <linux/perf_event.h>
#include <linux/device.h>
#include <asm/cpu_mf.h>
/* CPU-measurement counter facility */
......@@ -15,7 +22,18 @@
#define PMU_F_RESERVED 0x1000
#define PMU_F_ENABLED 0x2000
#ifdef CONFIG_64BIT
/* Perf defintions for PMU event attributes in sysfs */
extern __init const struct attribute_group **cpumf_cf_event_group(void);
extern ssize_t cpumf_events_sysfs_show(struct device *dev,
struct device_attribute *attr,
char *page);
#define EVENT_VAR(_cat, _name) event_attr_##_cat##_##_name
#define EVENT_PTR(_cat, _name) (&EVENT_VAR(_cat, _name).attr.attr)
#define CPUMF_EVENT_ATTR(cat, name, id) \
PMU_EVENT_ATTR(name, EVENT_VAR(cat, name), id, cpumf_events_sysfs_show)
#define CPUMF_EVENT_PTR(cat, name) EVENT_PTR(cat, name)
/* Perf callbacks */
struct pt_regs;
......@@ -24,3 +42,4 @@ extern unsigned long perf_misc_flags(struct pt_regs *regs);
#define perf_misc_flags(regs) perf_misc_flags(regs)
#endif /* CONFIG_64BIT */
#endif /* _ASM_S390_PERF_EVENT_H */
......@@ -60,7 +60,8 @@ obj-$(CONFIG_FTRACE_SYSCALLS) += ftrace.o
obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
ifdef CONFIG_64BIT
obj-$(CONFIG_PERF_EVENTS) += perf_event.o perf_cpum_cf.o
obj-$(CONFIG_PERF_EVENTS) += perf_event.o perf_cpum_cf.o \
perf_cpum_cf_events.o
obj-y += runtime_instr.o cache.o
endif
......
......@@ -680,6 +680,7 @@ static int __init cpumf_pmu_init(void)
goto out;
}
cpumf_pmu.attr_groups = cpumf_cf_event_group();
rc = perf_pmu_register(&cpumf_pmu, "cpum_cf", PERF_TYPE_RAW);
if (rc) {
pr_err("Registering the cpum_cf PMU failed with rc=%i\n", rc);
......
This diff is collapsed.
......@@ -16,6 +16,7 @@
#include <linux/kvm_host.h>
#include <linux/percpu.h>
#include <linux/export.h>
#include <linux/sysfs.h>
#include <asm/irq.h>
#include <asm/cpu_mf.h>
#include <asm/lowcore.h>
......@@ -172,3 +173,14 @@ void perf_callchain_kernel(struct perf_callchain_entry *entry,
__store_trace(entry, head, S390_lowcore.thread_info,
S390_lowcore.thread_info + THREAD_SIZE);
}
/* Perf defintions for PMU event attributes in sysfs */
ssize_t cpumf_events_sysfs_show(struct device *dev,
struct device_attribute *attr, char *page)
{
struct perf_pmu_events_attr *pmu_attr;
pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr);
return sprintf(page, "event=0x%04llx,name=%s\n",
pmu_attr->id, attr->attr.name);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment