aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2012-10-10 08:53:13 -0400
committerIngo Molnar <mingo@kernel.org>2012-10-24 04:41:24 -0400
commit43c032febde48aabcf6d59f47cdcb7b5debbdc63 (patch)
tree0e6e260eeb8d979195ee0cbcf9d8c7458c051cca
parent8300daa26755c9a194776778bd822acf1fa2dbf6 (diff)
perf/x86: Add hardware events translations for Intel cpus
Add support for Intel processors to display 'events' sysfs directory (/sys/devices/cpu/events/) with hw event translations: # ls /sys/devices/cpu/events/ branch-instructions branch-misses bus-cycles cache-misses cache-references cpu-cycles instructions ref-cycles stalled-cycles-backend stalled-cycles-frontend Suggested-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Jiri Olsa <jolsa@redhat.com> Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> Cc: Paul Mackerras <paulus@samba.org> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Stephane Eranian <eranian@google.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1349873598-12583-4-git-send-email-jolsa@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/kernel/cpu/perf_event.c40
-rw-r--r--arch/x86/kernel/cpu/perf_event.h2
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel.c2
3 files changed, 44 insertions, 0 deletions
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 39737a678a86..8a1fa23452d6 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -1392,6 +1392,46 @@ static struct attribute_group x86_pmu_events_group = {
1392 .attrs = events_attr, 1392 .attrs = events_attr,
1393}; 1393};
1394 1394
1395ssize_t x86_event_sysfs_show(char *page, u64 config)
1396{
1397 u64 event = (config & ARCH_PERFMON_EVENTSEL_EVENT);
1398 u64 umask = (config & ARCH_PERFMON_EVENTSEL_UMASK) >> 8;
1399 u64 cmask = (config & ARCH_PERFMON_EVENTSEL_CMASK) >> 24;
1400 bool edge = (config & ARCH_PERFMON_EVENTSEL_EDGE);
1401 bool pc = (config & ARCH_PERFMON_EVENTSEL_PIN_CONTROL);
1402 bool any = (config & ARCH_PERFMON_EVENTSEL_ANY);
1403 bool inv = (config & ARCH_PERFMON_EVENTSEL_INV);
1404 ssize_t ret;
1405
1406 /*
1407 * We have whole page size to spend and just little data
1408 * to write, so we can safely use sprintf.
1409 */
1410 ret = sprintf(page, "event=0x%02llx", event);
1411
1412 if (umask)
1413 ret += sprintf(page + ret, ",umask=0x%02llx", umask);
1414
1415 if (edge)
1416 ret += sprintf(page + ret, ",edge");
1417
1418 if (pc)
1419 ret += sprintf(page + ret, ",pc");
1420
1421 if (any)
1422 ret += sprintf(page + ret, ",any");
1423
1424 if (inv)
1425 ret += sprintf(page + ret, ",inv");
1426
1427 if (cmask)
1428 ret += sprintf(page + ret, ",cmask=0x%02llx", cmask);
1429
1430 ret += sprintf(page + ret, "\n");
1431
1432 return ret;
1433}
1434
1395static int __init init_hw_perf_events(void) 1435static int __init init_hw_perf_events(void)
1396{ 1436{
1397 struct x86_pmu_quirk *quirk; 1437 struct x86_pmu_quirk *quirk;
diff --git a/arch/x86/kernel/cpu/perf_event.h b/arch/x86/kernel/cpu/perf_event.h
index 6f75b6a7f37c..f8aa2f6677f2 100644
--- a/arch/x86/kernel/cpu/perf_event.h
+++ b/arch/x86/kernel/cpu/perf_event.h
@@ -538,6 +538,8 @@ static inline void set_linear_ip(struct pt_regs *regs, unsigned long ip)
538 regs->ip = ip; 538 regs->ip = ip;
539} 539}
540 540
541ssize_t x86_event_sysfs_show(char *page, u64 config);
542
541#ifdef CONFIG_CPU_SUP_AMD 543#ifdef CONFIG_CPU_SUP_AMD
542 544
543int amd_pmu_init(void); 545int amd_pmu_init(void);
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index 324bb523d9d9..6106d3b44aa1 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -1628,6 +1628,7 @@ static __initconst const struct x86_pmu core_pmu = {
1628 .event_constraints = intel_core_event_constraints, 1628 .event_constraints = intel_core_event_constraints,
1629 .guest_get_msrs = core_guest_get_msrs, 1629 .guest_get_msrs = core_guest_get_msrs,
1630 .format_attrs = intel_arch_formats_attr, 1630 .format_attrs = intel_arch_formats_attr,
1631 .events_sysfs_show = x86_event_sysfs_show,
1631}; 1632};
1632 1633
1633struct intel_shared_regs *allocate_shared_regs(int cpu) 1634struct intel_shared_regs *allocate_shared_regs(int cpu)
@@ -1766,6 +1767,7 @@ static __initconst const struct x86_pmu intel_pmu = {
1766 .pebs_aliases = intel_pebs_aliases_core2, 1767 .pebs_aliases = intel_pebs_aliases_core2,
1767 1768
1768 .format_attrs = intel_arch3_formats_attr, 1769 .format_attrs = intel_arch3_formats_attr,
1770 .events_sysfs_show = x86_event_sysfs_show,
1769 1771
1770 .cpu_prepare = intel_pmu_cpu_prepare, 1772 .cpu_prepare = intel_pmu_cpu_prepare,
1771 .cpu_starting = intel_pmu_cpu_starting, 1773 .cpu_starting = intel_pmu_cpu_starting,