Skip to contentSkip to conversation

x86,perf: add cache events in p4 PMU

RFC PATCH In review Lin Ming 3 participants 5 messages Mar 18, 2010

Subsystems (2)
lore
Share & tools
lore

Lin Ming

author
#0 lore raw

RFC PATCH 2/2 x86,perf: add cache events in p4 PMU

Add cache events in p4 PMU.

Move the HT bit setting code from p4_pmu_event_map to p4_hw_config. So the cache events can get HT bit set correctly.

Tested on my P4 desktop, below 6 cache events work. L1-dcache-load-misses
LLC-load-misses
dTLB-load-misses
dTLB-store-misses
iTLB-loads
iTLB-load-misses

---
 arch/x86/include/asm/msr-index.h     |    2 +
 arch/x86/include/asm/perf_event_p4.h |   10 ++
 arch/x86/kernel/cpu/perf_event_p4.c  |  153 ++++++++++++++++++++++++++++++++--
 3 files changed, 159 insertions(+), 6 deletions(-)
arch/x86/include/asm/msr-index.h +2 -0
index 1cd58cd..aef562c 100644
@@ -357,6 +357,8 @@
 #define MSR_P4_U2L_ESCR0		0x000003b0
 #define MSR_P4_U2L_ESCR1		0x000003b1
 
+#define MSR_P4_PEBS_MATRIX_VERT		0x000003f2
+
 /* Intel Core-based CPU performance counters */
 #define MSR_CORE_PERF_FIXED_CTR0	0x00000309
 #define MSR_CORE_PERF_FIXED_CTR1	0x0000030a
arch/x86/include/asm/perf_event_p4.h +10 -0
index 7d3406a..871249c 100644
@@ -708,4 +708,14 @@ enum P4_EVENTS_ATTR {
 	P4_MAKE_EVENT_ATTR(P4_INSTR_COMPLETED, BOGUS, 1),
 };
 
+enum {
+	KEY_P4_L1D_OP_READ_RESULT_MISS,
+	KEY_P4_LL_OP_READ_RESULT_MISS,
+	KEY_P4_DTLB_OP_READ_RESULT_MISS,
+	KEY_P4_DTLB_OP_WRITE_RESULT_MISS,
+	KEY_P4_ITLB_OP_READ_RESULT_ACCESS,
+	KEY_P4_ITLB_OP_READ_RESULT_MISS,
+	KEY_P4_UOP_TYPE,
+};
+
 #endif /* PERF_EVENT_P4_H */
arch/x86/kernel/cpu/perf_event_p4.c +147 -6

198 lines not on this page · raw message

#1 lore raw
Quoted 13 lines · Lin Ming

Add cache events in p4 PMU.

Move the HT bit setting code from p4_pmu_event_map to p4_hw_config. So the cache events can get HT bit set correctly.

Tested on my P4 desktop, below 6 cache events work. L1-dcache-load-misses
LLC-load-misses
dTLB-load-misses
dTLB-store-misses
iTLB-loads
iTLB-load-misses

Quoted 6 lines
---
 arch/x86/include/asm/msr-index.h     |    2 +
 arch/x86/include/asm/perf_event_p4.h |   10 ++
 arch/x86/kernel/cpu/perf_event_p4.c  |  153 ++++++++++++++++++++++++++++++++--
 3 files changed, 159 insertions(+), 6 deletions(-)

i tried it on a Pentium-D box, and it works pretty well:

rhea:/home/mingo/tip> perf stat -a sleep 1

Performance counter stats for 'sleep 1':

    2003.237268  task-clock-msecs         #      2.000 CPUs 
             11  context-switches         #      0.000 M/sec
              2  CPU-migrations           #      0.000 M/sec
            174  page-faults              #      0.000 M/sec
          47361  cycles                   #      0.024 M/sec  (scaled from 52.83%)
            430  instructions             #      0.009 IPC    (scaled from 74.58%)
          23873  branches                 #      0.012 M/sec  (scaled from 96.70%)
            193  branch-misses            #      0.808 %      (scaled from 49.64%)
            867  cache-references         #      0.000 M/sec  (scaled from 49.69%)
            504  cache-misses             #      0.000 M/sec  (scaled from 49.58%)
    1.001411586  seconds time elapsed

So i've applied your patches. Cyrill, what do you think?

Ingo

Reviewed-by
#2 lore raw
Quoted 40 lines · Ingo Molnar
Quoted 13 lines · Lin Ming

Add cache events in p4 PMU.

Move the HT bit setting code from p4_pmu_event_map to p4_hw_config. So the cache events can get HT bit set correctly.

Tested on my P4 desktop, below 6 cache events work. L1-dcache-load-misses
LLC-load-misses
dTLB-load-misses
dTLB-store-misses
iTLB-loads
iTLB-load-misses

Quoted 6 lines
---
 arch/x86/include/asm/msr-index.h     |    2 +
 arch/x86/include/asm/perf_event_p4.h |   10 ++
 arch/x86/kernel/cpu/perf_event_p4.c  |  153 ++++++++++++++++++++++++++++++++--
 3 files changed, 159 insertions(+), 6 deletions(-)

i tried it on a Pentium-D box, and it works pretty well:

rhea:/home/mingo/tip> perf stat -a sleep 1

Performance counter stats for 'sleep 1':

    2003.237268  task-clock-msecs         #      2.000 CPUs 
             11  context-switches         #      0.000 M/sec
              2  CPU-migrations           #      0.000 M/sec
            174  page-faults              #      0.000 M/sec
          47361  cycles                   #      0.024 M/sec  (scaled from 52.83%)
            430  instructions             #      0.009 IPC    (scaled from 74.58%)
          23873  branches                 #      0.012 M/sec  (scaled from 96.70%)
            193  branch-misses            #      0.808 %      (scaled from 49.64%)
            867  cache-references         #      0.000 M/sec  (scaled from 49.69%)
            504  cache-misses             #      0.000 M/sec  (scaled from 49.58%)
Quoted 3 lines
    1.001411586  seconds time elapsed

So i've applied your patches. Cyrill, what do you think?

Sorry for a bit delay, yes, pick it up please. I found that we have an issue in escr binding (which is pretty mine error), hope to fix it up today. Also I hope to eventually implement raw events this weekend but better to base the new code on all this stuff merged. This will allow to "take a look" on code structure from a high point and find potential caveats.

All-in-one

Thanks a huge, Ming!

Quoted 3 lines

Ingo

-- Cyrill

#3 lore raw

On Thu, Mar 18, 2010 at 07:01:35PM +0300, Cyrill Gorcunov wrote:
[...]

Quoted 11 lines
Quoted 1 line

So i've applied your patches. Cyrill, what do you think?

Sorry for a bit delay, yes, pick it up please. I found that we have an issue in escr binding (which is pretty mine error), hope to fix it up today. Also I hope to eventually implement raw events this weekend but better to base the new code on all this stuff merged. This will allow to "take a look" on code structure from a high point and find potential caveats.

All-in-one

Quoted 8 lines

Thanks a huge, Ming!

Quoted 3 lines

Ingo

-- Cyrill

Ok, the issue I thought about not really exist. Misfire :)

-- Cyrill

#4 lore raw

[tip:perf/core] perf, x86: Add cache events for the Pentium-4 PMU

In reply to Lin Ming
Commit-ID:  cb7d6b5053e86598735d9af19930f5929f007b7f
Gitweb:     http://git.kernel.org/tip/cb7d6b5053e86598735d9af19930f5929f007b7f
Author:     Lin Ming <[email protected]>
AuthorDate: Thu, 18 Mar 2010 18:33:12 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 18 Mar 2010 17:04:02 +0100

perf, x86: Add cache events for the Pentium-4 PMU

Move the HT bit setting code from p4_pmu_event_map to p4_hw_config. So the cache events can get HT bit set correctly.

Tested on my P4 desktop, below 6 cache events work:

L1-dcache-load-misses
LLC-load-misses
dTLB-load-misses
dTLB-store-misses
iTLB-loads
iTLB-load-misses

LKML-Reference: <[email protected]>

---
 arch/x86/include/asm/msr-index.h     |    2 +
 arch/x86/include/asm/perf_event_p4.h |   10 ++
 arch/x86/kernel/cpu/perf_event_p4.c  |  153 ++++++++++++++++++++++++++++++++--
 3 files changed, 159 insertions(+), 6 deletions(-)
arch/x86/include/asm/msr-index.h +2 -0
index 1cd58cd..aef562c 100644
@@ -357,6 +357,8 @@
 #define MSR_P4_U2L_ESCR0		0x000003b0
 #define MSR_P4_U2L_ESCR1		0x000003b1
 
+#define MSR_P4_PEBS_MATRIX_VERT		0x000003f2
+
 /* Intel Core-based CPU performance counters */
 #define MSR_CORE_PERF_FIXED_CTR0	0x00000309
 #define MSR_CORE_PERF_FIXED_CTR1	0x0000030a
arch/x86/include/asm/perf_event_p4.h +10 -0
index 7d3406a..871249c 100644
@@ -708,4 +708,14 @@ enum P4_EVENTS_ATTR {
 	P4_MAKE_EVENT_ATTR(P4_INSTR_COMPLETED, BOGUS, 1),
 };
 
+enum {
+	KEY_P4_L1D_OP_READ_RESULT_MISS,
+	KEY_P4_LL_OP_READ_RESULT_MISS,
+	KEY_P4_DTLB_OP_READ_RESULT_MISS,
+	KEY_P4_DTLB_OP_WRITE_RESULT_MISS,
+	KEY_P4_ITLB_OP_READ_RESULT_ACCESS,
+	KEY_P4_ITLB_OP_READ_RESULT_MISS,
+	KEY_P4_UOP_TYPE,
+};
+
 #endif /* PERF_EVENT_P4_H */
arch/x86/kernel/cpu/perf_event_p4.c +147 -6

198 lines not on this page · raw message