Skip to contentSkip to conversation

x86, perf: Handle multiple umask bits for BDW CYCLE_ACTIVITY.*

PATCH New Andi Kleen 2 participants 2 messages Nov 17, 2015 – Nov 23, 2015

Subsystems (2)
lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 x86, perf: Handle multiple umask bits for BDW CYCLE_ACTIVITY.*

From: Andi Kleen <[email protected]>

The earlier constraint fix for Broadwell CYCLE_ACTIVITY.* forced umask 8 to counter 2. For this it used UEVENT, to match the complete umask.

The event list for Broadwell has an additional STALLS_L1D_PENDIND event that uses umask 8, but also sets other bits in the umask. The earlier strict umask match didn't handle this case.

Add a new UBIT_EVENT constraint macro that only matches the specified bits in the umask. Then use that macro to handle CYCLE_ACTIVITY.* on Broadwell.

The documented event also uses cmask, but there's no need to let the event scheduler know about the cmask, as the scheduling restriction is only tied to the umask.

[I'm resending the last patch. There were various discussions around it, but no better solutions came up. Also need a solution because it breaks various tools, such as toplev]

Reported-by Grant Ayers
---
 arch/x86/kernel/cpu/perf_event.h       | 4 ++++
 arch/x86/kernel/cpu/perf_event_intel.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/perf_event.h +4 -0
index 953a0e4..285fce3 100644
@@ -317,6 +317,10 @@ struct cpu_hw_events {
 #define INTEL_UEVENT_CONSTRAINT(c, n)	\
 	EVENT_CONSTRAINT(c, n, INTEL_ARCH_EVENT_MASK)
 
+/* Constraint on specific umask bit only + event */
+#define INTEL_UBIT_EVENT_CONSTRAINT(c, n)	\
+	EVENT_CONSTRAINT(c, n, ARCH_PERFMON_EVENTSEL_EVENT|(c))
+
 /* Like UEVENT_CONSTRAINT, but match flags too */
 #define INTEL_FLAGS_UEVENT_CONSTRAINT(c, n)	\
 	EVENT_CONSTRAINT(c, n, INTEL_ARCH_EVENT_MASK|X86_ALL_EVENT_FLAGS)
arch/x86/kernel/cpu/perf_event_intel.c +1 -1
index 1d84b41..7ebc594 100644
@@ -250,7 +250,7 @@ struct event_constraint intel_bdw_event_constraints[] = {
 	FIXED_EVENT_CONSTRAINT(0x003c, 1),	/* CPU_CLK_UNHALTED.CORE */
 	FIXED_EVENT_CONSTRAINT(0x0300, 2),	/* CPU_CLK_UNHALTED.REF */
 	INTEL_UEVENT_CONSTRAINT(0x148, 0x4),	/* L1D_PEND_MISS.PENDING */
-	INTEL_UEVENT_CONSTRAINT(0x8a3, 0x4),	/* CYCLE_ACTIVITY.CYCLES_L1D_MISS */
+	INTEL_UBIT_EVENT_CONSTRAINT(0x8a3, 0x4),	/* CYCLE_ACTIVITY.CYCLES_L1D_MISS */
 	EVENT_CONSTRAINT_END
 };
 
Signature · 1 line
2.4.3
#1 lore raw

[tip:perf/core] perf/x86: Handle multiple umask bits for BDW CYCLE_ACTIVITY.*

perf/x86: Handle multiple umask bits for BDW CYCLE_ACTIVITY.*
Commit-ID:  b7883a1c4f75edb62fc49da6000c59fb881e3c7b
Gitweb:     http://git.kernel.org/tip/b7883a1c4f75edb62fc49da6000c59fb881e3c7b
Author:     Andi Kleen <[email protected]>
AuthorDate: Mon, 16 Nov 2015 16:21:07 -0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 23 Nov 2015 09:58:27 +0100

perf/x86: Handle multiple umask bits for BDW CYCLE_ACTIVITY.*

The earlier constraint fix for Broadwell CYCLE_ACTIVITY.* forced umask 8 to counter 2. For this it used UEVENT, to match the complete umask.

The event list for Broadwell has an additional STALLS_L1D_PENDIND event that uses umask 8, but also sets other bits in the umask. The earlier strict umask match didn't handle this case.

Add a new UBIT_EVENT constraint macro that only matches the specified bits in the umask. Then use that macro to handle CYCLE_ACTIVITY.* on Broadwell.

The documented event also uses cmask, but there's no need to let the event scheduler know about the cmask, as the scheduling restriction is only tied to the umask.

Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vince Weaver <[email protected]>
[ Filled in the missing email address of Grant Ayers - hopefully I got the right one. ]
---
 arch/x86/kernel/cpu/perf_event.h       | 4 ++++
 arch/x86/kernel/cpu/perf_event_intel.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/perf_event.h +4 -0
index ab18b8a..58402f6 100644
@@ -318,6 +318,10 @@ struct cpu_hw_events {
 #define INTEL_UEVENT_CONSTRAINT(c, n)	\
 	EVENT_CONSTRAINT(c, n, INTEL_ARCH_EVENT_MASK)
 
+/* Constraint on specific umask bit only + event */
+#define INTEL_UBIT_EVENT_CONSTRAINT(c, n)	\
+	EVENT_CONSTRAINT(c, n, ARCH_PERFMON_EVENTSEL_EVENT|(c))
+
 /* Like UEVENT_CONSTRAINT, but match flags too */
 #define INTEL_FLAGS_UEVENT_CONSTRAINT(c, n)	\
 	EVENT_CONSTRAINT(c, n, INTEL_ARCH_EVENT_MASK|X86_ALL_EVENT_FLAGS)
arch/x86/kernel/cpu/perf_event_intel.c +1 -1
index f63360b..61f2577 100644
@@ -255,7 +255,7 @@ struct event_constraint intel_bdw_event_constraints[] = {
 	FIXED_EVENT_CONSTRAINT(0x003c, 1),	/* CPU_CLK_UNHALTED.CORE */
 	FIXED_EVENT_CONSTRAINT(0x0300, 2),	/* CPU_CLK_UNHALTED.REF */
 	INTEL_UEVENT_CONSTRAINT(0x148, 0x4),	/* L1D_PEND_MISS.PENDING */
-	INTEL_UEVENT_CONSTRAINT(0x8a3, 0x4),	/* CYCLE_ACTIVITY.CYCLES_L1D_MISS */
+	INTEL_UBIT_EVENT_CONSTRAINT(0x8a3, 0x4),	/* CYCLE_ACTIVITY.CYCLES_L1D_MISS */
 	EVENT_CONSTRAINT_END
 };