Skip to contentSkip to conversation

x86,perf: add a key to simplify template lookup in p4 PMU

RFC PATCH In review Lin Ming 1 participant 2 messages Mar 18, 2010

Subsystems (2)
lore
Share & tools
lore

Lin Ming

author
#0 lore raw

RFC PATCH 1/2 x86,perf: add a key to simplify template lookup in p4 PMU

Currently, we use opcode(Event and Event-Selector) + emask to look up template in p4_templates.

But cache events (L1-dcache-load-misses, LLC-load-misses, etc) use the same event(P4_REPLAY_EVENT) to do the counting, ie, they have the same opcode and emask. So we can not use current lookup mechanism to find the template for cache events.

This patch introduces a "key", which is the index into p4_templates. The low 12 bits of CCCR are reserved, so we can hide the "key" in the low 12 bits of hwc->config.

We extract the key from hwc->config and then quickly find the template.

---
 arch/x86/include/asm/perf_event_p4.h |    5 ++-
 arch/x86/kernel/cpu/perf_event_p4.c  |   86 +++++++++++++--------------------
 2 files changed, 38 insertions(+), 53 deletions(-)
arch/x86/include/asm/perf_event_p4.h +4 -1
index b842b32..7d3406a 100644
@@ -65,6 +65,7 @@
 #define P4_CCCR_THREAD_SINGLE		0x00010000U
 #define P4_CCCR_THREAD_BOTH		0x00020000U
 #define P4_CCCR_THREAD_ANY		0x00030000U
+#define P4_CCCR_RESERVED		0x00000fffU
 
 /* Non HT mask */
 #define P4_CCCR_MASK				\
@@ -116,7 +117,7 @@
 #define p4_config_pack_escr(v)		(((u64)(v)) << 32)
 #define p4_config_pack_cccr(v)		(((u64)(v)) & 0xffffffffULL)
 #define p4_config_unpack_escr(v)	(((u64)(v)) >> 32)
-#define p4_config_unpack_cccr(v)	(((u64)(v)) & 0xffffffffULL)
+#define p4_config_unpack_cccr(v)	(((u64)(v)) & 0xfffff000ULL)
 
 #define p4_config_unpack_emask(v)			\
 	({						\
@@ -126,6 +127,8 @@
 		t;					\
 	})
 
+#define p4_config_unpack_key(v)		(((u64)(v)) & P4_CCCR_RESERVED)
+
 #define P4_CONFIG_HT_SHIFT		63
 #define P4_CONFIG_HT			(1ULL << P4_CONFIG_HT_SHIFT)
 
arch/x86/kernel/cpu/perf_event_p4.c +34 -52

187 lines not on this page · raw message

#1 lore raw

[tip:perf/core] perf, x86: Add a key to simplify template lookup in Pentium-4 PMU

Commit-ID:  f34edbc1cdb0f8f83d94e1d668dd6e41abf0defb
Gitweb:     http://git.kernel.org/tip/f34edbc1cdb0f8f83d94e1d668dd6e41abf0defb
Author:     Lin Ming <[email protected]>
AuthorDate: Thu, 18 Mar 2010 18:33:07 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 18 Mar 2010 17:03:51 +0100

perf, x86: Add a key to simplify template lookup in Pentium-4 PMU

Currently, we use opcode(Event and Event-Selector) + emask to look up template in p4_templates.

But cache events (L1-dcache-load-misses, LLC-load-misses, etc) use the same event(P4_REPLAY_EVENT) to do the counting, ie, they have the same opcode and emask. So we can not use current lookup mechanism to find the template for cache events.

This patch introduces a "key", which is the index into p4_templates. The low 12 bits of CCCR are reserved, so we can hide the "key" in the low 12 bits of hwc->config.

We extract the key from hwc->config and then quickly find the template.

LKML-Reference: <[email protected]>

---
 arch/x86/include/asm/perf_event_p4.h |    5 ++-
 arch/x86/kernel/cpu/perf_event_p4.c  |   86 +++++++++++++--------------------
 2 files changed, 38 insertions(+), 53 deletions(-)
arch/x86/include/asm/perf_event_p4.h +4 -1
index b842b32..7d3406a 100644
@@ -65,6 +65,7 @@
 #define P4_CCCR_THREAD_SINGLE		0x00010000U
 #define P4_CCCR_THREAD_BOTH		0x00020000U
 #define P4_CCCR_THREAD_ANY		0x00030000U
+#define P4_CCCR_RESERVED		0x00000fffU
 
 /* Non HT mask */
 #define P4_CCCR_MASK				\
@@ -116,7 +117,7 @@
 #define p4_config_pack_escr(v)		(((u64)(v)) << 32)
 #define p4_config_pack_cccr(v)		(((u64)(v)) & 0xffffffffULL)
 #define p4_config_unpack_escr(v)	(((u64)(v)) >> 32)
-#define p4_config_unpack_cccr(v)	(((u64)(v)) & 0xffffffffULL)
+#define p4_config_unpack_cccr(v)	(((u64)(v)) & 0xfffff000ULL)
 
 #define p4_config_unpack_emask(v)			\
 	({						\
@@ -126,6 +127,8 @@
 		t;					\
 	})
 
+#define p4_config_unpack_key(v)		(((u64)(v)) & P4_CCCR_RESERVED)
+
 #define P4_CONFIG_HT_SHIFT		63
 #define P4_CONFIG_HT			(1ULL << P4_CONFIG_HT_SHIFT)
 
arch/x86/kernel/cpu/perf_event_p4.c +34 -52

187 lines not on this page · raw message