Skip to contentSkip to conversation

perf: Add missing PEBS frontend support to Skylake

PATCH New Andi Kleen 2 participants 4 messages Sep 9, 2015 – Sep 18, 2015

Subsystems (2)
lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

Hi Peter,

I noticed that tip/perf/core is missing the Skylake PEBS Frontend extrareg support. At some point you had signed off on it, but then Stephane found another issue which was fixed with an follow-on patch.

It would be good if that could be merged this cycle too, as that would make the Skylake core perf support complete. The new frontend profiling support is very useful to identify frontend bound issues.

I'm resending the two patches here.

-Andi

author
#1 lore raw

PATCH 1/2 x86, perf: Add PEBS frontend profiling for Skylake

From: Andi Kleen <[email protected]>

Skylake has a new FRONTEND_LATENCY PEBS event to accurate profile frontend problems (like ITLB or decoding issues)

The new event is configured through a separate MSR, which selects a range of sub events.

Define the extra MSR as a extra reg and export support for it through sysfs. To avoid duplicating the existing tables use a new function to add new entries to existing tables.

v2: Don't use custom test value.

---
 arch/x86/include/asm/msr-index.h       |  2 ++
 arch/x86/kernel/cpu/perf_event.h       |  1 +
 arch/x86/kernel/cpu/perf_event_intel.c | 11 ++++++++++-
 3 files changed, 13 insertions(+), 1 deletion(-)
arch/x86/include/asm/msr-index.h +2 -0
index fcd17c1..8c5237b 100644
@@ -141,6 +141,8 @@
 #define DEBUGCTLMSR_BTS_OFF_USR		(1UL << 10)
 #define DEBUGCTLMSR_FREEZE_LBRS_ON_PMI	(1UL << 11)
 
+#define MSR_PEBS_FRONTEND		0x000003f7
+
 #define MSR_IA32_POWER_CTL		0x000001fc
 
 #define MSR_IA32_MC0_CTL		0x00000400
arch/x86/kernel/cpu/perf_event.h +1 -0
index 5edf6d8..165be83 100644
@@ -47,6 +47,7 @@ enum extra_reg_type {
 	EXTRA_REG_RSP_1 = 1,	/* offcore_response_1 */
 	EXTRA_REG_LBR   = 2,	/* lbr_select */
 	EXTRA_REG_LDLAT = 3,	/* ld_lat_threshold */
+	EXTRA_REG_FE    = 4,    /* fe_* */
 
 	EXTRA_REG_MAX		/* number of entries needed */
 };
arch/x86/kernel/cpu/perf_event_intel.c +10 -1
index 3f124d5..3c4d6e3 100644
@@ -205,6 +205,7 @@ static struct extra_reg intel_skl_extra_regs[] __read_mostly = {
 	INTEL_UEVENT_EXTRA_REG(0x01b7, MSR_OFFCORE_RSP_0, 0x3fffff8fffull, RSP_0),
 	INTEL_UEVENT_EXTRA_REG(0x01bb, MSR_OFFCORE_RSP_1, 0x3fffff8fffull, RSP_1),
 	INTEL_UEVENT_PEBS_LDLAT_EXTRA_REG(0x01cd),
+	INTEL_UEVENT_EXTRA_REG(0x01c6, MSR_PEBS_FRONTEND, 0x3fff17, FE),
 	EVENT_EXTRA_END
 };
 
@@ -2888,6 +2889,8 @@ PMU_FORMAT_ATTR(offcore_rsp, "config1:0-63");
 
 PMU_FORMAT_ATTR(ldlat, "config1:0-15");
 
+PMU_FORMAT_ATTR(frontend, "config1:0-23");
+
 static struct attribute *intel_arch3_formats_attr[] = {
 	&format_attr_event.attr,
 	&format_attr_umask.attr,
@@ -2904,6 +2907,11 @@ static struct attribute *intel_arch3_formats_attr[] = {
 	NULL,
 };
 
+static struct attribute *skl_format_attr[] = {
+	&format_attr_frontend.attr,
+	NULL,
+};
+
 static __initconst const struct x86_pmu core_pmu = {
 	.name			= "core",
 	.handle_irq		= x86_pmu_handle_irq,
@@ -3513,7 +3521,8 @@ __init int intel_pmu_init(void)
 
 		x86_pmu.hw_config = hsw_hw_config;
 		x86_pmu.get_event_constraints = hsw_get_event_constraints;
-		x86_pmu.cpu_events = hsw_events_attrs;
+		x86_pmu.format_attrs = merge_attr(intel_arch3_formats_attr,
+						  skl_format_attr);
 		WARN_ON(!x86_pmu.format_attrs);
 		x86_pmu.cpu_events = hsw_events_attrs;
 		pr_cont("Skylake events, ");
Signature · 1 line
2.4.3
author
#2 lore raw

PATCH 2/2 x86, perf: Fix Skylake FRONTEND MSR extrareg mask

In reply to Andi Kleen

From: Andi Kleen <[email protected]>

Stephane pointed out that the extrareg mask was one bit too short. The bubble width field was truncated by one bit. Fix that here. Also add some extra comments on the reserved bits inside the event select code.

---
 arch/x86/kernel/cpu/perf_event_intel.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/perf_event_intel.c +5 -1
index 3c4d6e3..42a0fef 100644
@@ -205,7 +205,11 @@ static struct extra_reg intel_skl_extra_regs[] __read_mostly = {
 	INTEL_UEVENT_EXTRA_REG(0x01b7, MSR_OFFCORE_RSP_0, 0x3fffff8fffull, RSP_0),
 	INTEL_UEVENT_EXTRA_REG(0x01bb, MSR_OFFCORE_RSP_1, 0x3fffff8fffull, RSP_1),
 	INTEL_UEVENT_PEBS_LDLAT_EXTRA_REG(0x01cd),
-	INTEL_UEVENT_EXTRA_REG(0x01c6, MSR_PEBS_FRONTEND, 0x3fff17, FE),
+	/*
+	 * Note the low 8 bits eventsel code is not a continuous field, containing
+	 * some #GPing bits. These are masked out.
+	 */
+	INTEL_UEVENT_EXTRA_REG(0x01c6, MSR_PEBS_FRONTEND, 0x7fff17, FE),
 	EVENT_EXTRA_END
 };
 
Signature · 1 line
2.4.3
#3 lore raw

[tip:perf/core] perf/x86/intel: Fix Skylake FRONTEND MSR extrareg mask

perf/x86/intel: Fix Skylake FRONTEND MSR extrareg mask
Commit-ID:  dfe1f3cb312624928052413928d88b0ee3492216
Gitweb:     http://git.kernel.org/tip/dfe1f3cb312624928052413928d88b0ee3492216
Author:     Andi Kleen <[email protected]>
AuthorDate: Wed, 9 Sep 2015 14:54:00 -0700
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 18 Sep 2015 09:20:23 +0200

perf/x86/intel: Fix Skylake FRONTEND MSR extrareg mask

Stephane pointed out that the extrareg mask was one bit too short. The bubble width field was truncated by one bit. Fix that here. Also add some extra comments on the reserved bits inside the event select code.

---
 arch/x86/kernel/cpu/perf_event_intel.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/perf_event_intel.c +5 -1
index ef74c9d..f63360b 100644
@@ -205,7 +205,11 @@ static struct extra_reg intel_skl_extra_regs[] __read_mostly = {
 	INTEL_UEVENT_EXTRA_REG(0x01b7, MSR_OFFCORE_RSP_0, 0x3fffff8fffull, RSP_0),
 	INTEL_UEVENT_EXTRA_REG(0x01bb, MSR_OFFCORE_RSP_1, 0x3fffff8fffull, RSP_1),
 	INTEL_UEVENT_PEBS_LDLAT_EXTRA_REG(0x01cd),
-	INTEL_UEVENT_EXTRA_REG(0x01c6, MSR_PEBS_FRONTEND, 0x3fff17, FE),
+	/*
+	 * Note the low 8 bits eventsel code is not a continuous field, containing
+	 * some #GPing bits. These are masked out.
+	 */
+	INTEL_UEVENT_EXTRA_REG(0x01c6, MSR_PEBS_FRONTEND, 0x7fff17, FE),
 	EVENT_EXTRA_END
 };