perf_counter, x86: Implement generalized cache event types, add AMD support
Commit-ID: d3ad70660a0bf6d1a3692093939d238fe8add498 Gitweb: http://git.kernel.org/tip/d3ad70660a0bf6d1a3692093939d238fe8add498 Author: Thomas Gleixner <[email protected]> AuthorDate: Mon, 8 Jun 2009 22:33:10 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 8 Jun 2009 22:33:10 +0200
perf_counter, x86: Implement generalized cache event types, add AMD support
Fill in amd_hw_cache_event_id[] with the AMD CPU specific events, for family 0x0f, 0x10 and 0x11.
There's apparently no distinction between load and store events, so we only fill in the load events.
LKML-Reference: <new-submission>
--- arch/x86/kernel/cpu/perf_counter.c | 102 ++++++++++++++++++++++++++++++++++++ 1 files changed, 102 insertions(+), 0 deletions(-)
arch/x86/kernel/cpu/perf_counter.c +102 -0
@@ -389,6 +389,97 @@ static u64 intel_pmu_raw_event(u64 event)return event &CORE_EVNTSEL_MASK ; } +static const u64 amd_0f_hw_cache_event_ids + [PERF_COUNT_HW_CACHE_MAX ] + [PERF_COUNT_HW_CACHE_OP_MAX ] + [PERF_COUNT_HW_CACHE_RESULT_MAX ] = +{ + [C (L1D ) ] = { + [C (OP_READ ) ] = { + [C (RESULT_ACCESS ) ] =0 , + [C (RESULT_MISS ) ] =0 , + }, + [C (OP_WRITE ) ] = { + [C (RESULT_ACCESS ) ] =0 , + [C (RESULT_MISS ) ] =0 , + }, + [C (OP_PREFETCH ) ] = { + [C (RESULT_ACCESS ) ] =0 , + [C (RESULT_MISS ) ] =0 , + }, + }, + [C (L1I ) ] = { + [C (OP_READ ) ] = { + [C (RESULT_ACCESS ) ] =0x0080 ,/* Instruction cache fetches */ + [C (RESULT_MISS ) ] =0x0081 ,/* Instruction cache misses */ + }, + [C (OP_WRITE ) ] = { + [C (RESULT_ACCESS ) ] =-1 , + [C (RESULT_MISS ) ] =-1 , + }, + [C (OP_PREFETCH ) ] = { + [C (RESULT_ACCESS ) ] =0 , + [C (RESULT_MISS ) ] =0 , + }, + }, + [C (L2 ) ] = { + [C (OP_READ ) ] = { + [C (RESULT_ACCESS ) ] =0 , + [C (RESULT_MISS ) ] =0 , + }, + [C (OP_WRITE ) ] = { + [C (RESULT_ACCESS ) ] =0 , + [C (RESULT_MISS ) ] =0 , + }, + [C (OP_PREFETCH ) ] = { + [C (RESULT_ACCESS ) ] =0 , + [C (RESULT_MISS ) ] =0 , + }, + }, + [C (DTLB ) ] = { + [C (OP_READ ) ] = { + [C (RESULT_ACCESS ) ] =0 , + [C (RESULT_MISS ) ] =0 , + }, + [C (OP_WRITE ) ] = { + [C (RESULT_ACCESS ) ] =0 , + [C (RESULT_MISS ) ] =0 , + }, + [C (OP_PREFETCH ) ] = { + [C (RESULT_ACCESS ) ] =0 , + [C (RESULT_MISS ) ] =0 , + }, + }, + [C (ITLB ) ] = { + [C (OP_READ ) ] = { + [C (RESULT_ACCESS ) ] =0x0080 ,/* Instruction fecthes */ + [C (RESULT_MISS ) ] =0x0085 ,/* Instr. fetch ITLB misses */ + }, + [C (OP_WRITE ) ] = { + [C (RESULT_ACCESS ) ] =-1 , + [C (RESULT_MISS ) ] =-1 , + }, + [C (OP_PREFETCH ) ] = { + [C (RESULT_ACCESS ) ] =-1 , + [C (RESULT_MISS ) ] =-1 , + }, + }, + [C (BPU ) ] = { + [C (OP_READ ) ] = { + [C (RESULT_ACCESS ) ] =0x00c2 ,/* Retired Branch Instr. */ + [C (RESULT_MISS ) ] =0x00c3 ,/* Retired Mispredicted BI */ + }, + [C (OP_WRITE ) ] = { + [C (RESULT_ACCESS ) ] =-1 , + [C (RESULT_MISS ) ] =-1 , + }, + [C (OP_PREFETCH ) ] = { + [C (RESULT_ACCESS ) ] =-1 , + [C (RESULT_MISS ) ] =-1 , + }, + }, +}; +/* * AMD Performance Monitor K7 and later. */
@@ -1345,6 +1436,17 @@ static int intel_pmu_init(void)static int amd_pmu_init (void ) { x86_pmu = amd_pmu; + +switch (boot_cpu_data.x86 >=0x0f ) { +case 0x0f : +case 0x10 : +case 0x11 : +memcpy (hw_cache_event_ids, amd_0f_hw_cache_event_ids, +sizeof (hw_cache_event_ids)); + +pr_cont ("AMD Family 0f/10/11 events, " ); +break ; + }return 0 ; }
Quoted 7 lines · tip-bot for Thomas Gleixner
Commit-ID: d3ad70660a0bf6d1a3692093939d238fe8add498 Gitweb: http://git.kernel.org/tip/d3ad70660a0bf6d1a3692093939d238fe8add498 Author: Thomas Gleixner <[email protected]> AuthorDate: Mon, 8 Jun 2009 22:33:10 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 8 Jun 2009 22:33:10 +0200
Quoted 7 lines
perf_counter, x86: Implement generalized cache event types, add AMD supportFill in amd_hw_cache_event_id[] with the AMD CPU specific events, for family
0x0f,0x10and0x11.There's apparently no distinction between load and store events, so we only fill in the load events.
Ah, that's what you did.. :-)
arch/x86/kernel/cpu/perf_counter.c static u64 intel_pmu_raw_event(u64 event) · line 400
Quoted 9 lines
arch/x86/kernel/cpu/perf_counter.c +9
-0+static const u64 amd_0f_hw_cache_event_ids + [PERF_COUNT_HW_CACHE_MAX ] + [PERF_COUNT_HW_CACHE_OP_MAX ] + [PERF_COUNT_HW_CACHE_RESULT_MAX ] = +{ + [C (L1D ) ] = { + [C (OP_READ ) ] = { + [C (RESULT_ACCESS ) ] =0 , + [C (RESULT_MISS ) ] =0 ,
0x40 - Data Cache Access0x41 - Data Cache Misses
arch/x86/kernel/cpu/perf_counter.c static u64 intel_pmu_raw_event(u64 event) · line 408
Quoted 8 lines
arch/x86/kernel/cpu/perf_counter.c +8
-0+ }, + [ C(OP_WRITE) ] = { + [ C(RESULT_ACCESS) ] = 0, + [ C(RESULT_MISS) ] = 0, + }, + [ C(OP_PREFETCH) ] = { + [ C(RESULT_ACCESS) ] = 0, + [ C(RESULT_MISS) ] = 0,
0x4B - unit 0x3 (load+store) Prefetch Dispatched
Quoted 5 lines
arch/x86/kernel/cpu/perf_counter.c +5
-0+ }, + }, + [ C(L1I ) ] = { + [ C(OP_READ) ] = { + [ C(RESULT_ACCESS) ] = 0x0080, /* Instruction cache fetches */
arch/x86/kernel/cpu/perf_counter.c static u64 intel_pmu_raw_event(u64 event) · line 423
Quoted 10 lines
arch/x86/kernel/cpu/perf_counter.c +10
-0+ [C (RESULT_MISS ) ] =0x0081 ,/* Instruction cache misses */ + }, + [ C(OP_WRITE) ] = { + [C (RESULT_ACCESS ) ] =-1 , + [C (RESULT_MISS ) ] =-1 , + }, + [C (OP_PREFETCH ) ] = { + [C (RESULT_ACCESS ) ] =0 , + [C (RESULT_MISS ) ] =0 , + },
0x81 L1I Miss0x82 L1I Miss, L2 Hit0x83 L1I Miss, L2 Miss
Quoted 4 lines
+ },
+ [ C(L2 ) ] = {arch/x86/kernel/cpu/perf_counter.c +2
-0+ [ C(OP_READ) ] = { + [ C(RESULT_ACCESS) ] = 0,
arch/x86/kernel/cpu/perf_counter.c static u64 intel_pmu_raw_event(u64 event) · line 409
Quoted 10 lines
arch/x86/kernel/cpu/perf_counter.c +10
-0+ [C (RESULT_MISS ) ] =0 , + }, + [ C(OP_WRITE) ] = { + [C (RESULT_ACCESS ) ] =0 , + [C (RESULT_MISS ) ] =0 , + }, + [C (OP_PREFETCH ) ] = { + [C (RESULT_ACCESS ) ] =0 , + [C (RESULT_MISS ) ] =0 , + },
0x42 unit 0x1e (shared|exclusive|owned|mod) L1 Miss L2 Hit0x43 unit 0x1e L2 Miss
0x7d unit 0x3 (IC|DC) L2 Hit 0x7e unit 0x3 (IC|DC) L2 Miss
arch/x86/kernel/cpu/perf_counter.c static u64 intel_pmu_raw_event(u64 event) · line 401
Quoted 6 lines
+ },
+ [ C(DTLB) ] = {arch/x86/kernel/cpu/perf_counter.c +4
-0+ [ C(OP_READ) ] = { + [ C(RESULT_ACCESS) ] = 0, + [ C(RESULT_MISS) ] = 0, + },
0x4D - unit 0x1 4k DTLB L1 Hit 0x45 - unit 0x1 4k DTLB L1 Miss L2 Hit 0x46 - unit 0x1 4k DTLB L1 Miss L2 Miss
Quoted 12 lines
arch/x86/kernel/cpu/perf_counter.c +12
-0+ [C (OP_WRITE ) ] = { + [C (RESULT_ACCESS ) ] =0 , + [C (RESULT_MISS ) ] =0 , + }, + [C (OP_PREFETCH ) ] = { + [C (RESULT_ACCESS ) ] =0 , + [C (RESULT_MISS ) ] =0 , + }, + }, + [ C(ITLB) ] = { + [C (OP_READ ) ] = { + [C (RESULT_ACCESS ) ] =0x0080 ,/* Instruction fecthes */
arch/x86/kernel/cpu/perf_counter.c static u64 intel_pmu_raw_event(u64 event) · line 465
Quoted 10 lines
arch/x86/kernel/cpu/perf_counter.c +10
-0+ [C (RESULT_MISS ) ] =0x0085 ,/* Instr. fetch ITLB misses */ + }, + [ C(OP_WRITE) ] = { + [C (RESULT_ACCESS ) ] =-1 , + [C (RESULT_MISS ) ] =-1 , + }, + [C (OP_PREFETCH ) ] = { + [C (RESULT_ACCESS ) ] =-1 , + [C (RESULT_MISS ) ] =-1 , + },
0x84 L1 ITLB Miss, L2 ITLB Hit0x85 Unit 0x1 (4k) L1 ITLB Miss, L2 Miss
arch/x86/kernel/cpu/perf_counter.c static u64 intel_pmu_raw_event(u64 event) · line 470
Quoted 5 lines
+ },
+ [ C(BPU ) ] = {arch/x86/kernel/cpu/perf_counter.c +3
-0+ [ C(OP_READ) ] = { + [ C(RESULT_ACCESS) ] = 0x00c2, /* Retired Branch Instr. */ + [ C(RESULT_MISS) ] = 0x00c3, /* Retired Mispredicted BI */
There's also Retired Taken in C4 and C5
Quoted 11 lines
arch/x86/kernel/cpu/perf_counter.c +11
-0+ }, + [ C(OP_WRITE) ] = { + [ C(RESULT_ACCESS) ] = -1, + [ C(RESULT_MISS) ] = -1, + }, + [ C(OP_PREFETCH) ] = { + [ C(RESULT_ACCESS) ] = -1, + [ C(RESULT_MISS) ] = -1, + }, + }, +};
Quoted 120 lines · Peter Zijlstra
Quoted 7 lines · tip-bot for Thomas Gleixner
Commit-ID: d3ad70660a0bf6d1a3692093939d238fe8add498 Gitweb: http://git.kernel.org/tip/d3ad70660a0bf6d1a3692093939d238fe8add498 Author: Thomas Gleixner <[email protected]> AuthorDate: Mon, 8 Jun 2009 22:33:10 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 8 Jun 2009 22:33:10 +0200Quoted 7 lines
perf_counter, x86: Implement generalized cache event types, add AMD supportFill in amd_hw_cache_event_id[] with the AMD CPU specific events, for family
0x0f,0x10and0x11.There's apparently no distinction between load and store events, so we only fill in the load events.
Ah, that's what you did.. :-)
arch/x86/kernel/cpu/perf_counter.c static u64 intel_pmu_raw_event(u64 event) · line 400
Quoted 9 lines
arch/x86/kernel/cpu/perf_counter.c +9
-0+static const u64 amd_0f_hw_cache_event_ids + [PERF_COUNT_HW_CACHE_MAX ] + [PERF_COUNT_HW_CACHE_OP_MAX ] + [PERF_COUNT_HW_CACHE_RESULT_MAX ] = +{ + [C (L1D ) ] = { + [C (OP_READ ) ] = { + [C (RESULT_ACCESS ) ] =0 , + [C (RESULT_MISS ) ] =0 ,
0x40- Data Cache Access0x41- Data Cache Missesarch/x86/kernel/cpu/perf_counter.c static u64 intel_pmu_raw_event(u64 event) · line 408
Quoted 8 lines
arch/x86/kernel/cpu/perf_counter.c +8
-0+ }, + [ C(OP_WRITE) ] = { + [ C(RESULT_ACCESS) ] = 0, + [ C(RESULT_MISS) ] = 0, + }, + [ C(OP_PREFETCH) ] = { + [ C(RESULT_ACCESS) ] = 0, + [ C(RESULT_MISS) ] = 0,
0x4B- unit0x3(load+store) Prefetch DispatchedQuoted 5 lines
arch/x86/kernel/cpu/perf_counter.c +5
-0+ }, + }, + [ C(L1I ) ] = { + [ C(OP_READ) ] = { + [ C(RESULT_ACCESS) ] = 0x0080, /* Instruction cache fetches */arch/x86/kernel/cpu/perf_counter.c static u64 intel_pmu_raw_event(u64 event) · line 423
Quoted 10 lines
arch/x86/kernel/cpu/perf_counter.c +10
-0+ [C (RESULT_MISS ) ] =0x0081 ,/* Instruction cache misses */ + }, + [ C(OP_WRITE) ] = { + [C (RESULT_ACCESS ) ] =-1 , + [C (RESULT_MISS ) ] =-1 , + }, + [C (OP_PREFETCH ) ] = { + [C (RESULT_ACCESS ) ] =0 , + [C (RESULT_MISS ) ] =0 , + },
0x81L1I Miss0x82L1I Miss, L2 Hit0x83L1I Miss, L2 MissQuoted 4 lines
+ },
+ [ C(L2 ) ] = {arch/x86/kernel/cpu/perf_counter.c +2
-0+ [ C(OP_READ) ] = { + [ C(RESULT_ACCESS) ] = 0,arch/x86/kernel/cpu/perf_counter.c static u64 intel_pmu_raw_event(u64 event) · line 409
Quoted 10 lines
arch/x86/kernel/cpu/perf_counter.c +10
-0+ [C (RESULT_MISS ) ] =0 , + }, + [ C(OP_WRITE) ] = { + [C (RESULT_ACCESS ) ] =0 , + [C (RESULT_MISS ) ] =0 , + }, + [C (OP_PREFETCH ) ] = { + [C (RESULT_ACCESS ) ] =0 , + [C (RESULT_MISS ) ] =0 , + },
0x42unit0x1e(shared|exclusive|owned|mod) L1 Miss L2 Hit0x43unit0x1eL2 Miss
0x7dunit0x3(IC|DC) L2 Hit0x7eunit0x3(IC|DC) L2 Missarch/x86/kernel/cpu/perf_counter.c static u64 intel_pmu_raw_event(u64 event) · line 401
Quoted 6 lines
+ },
+ [ C(DTLB) ] = {arch/x86/kernel/cpu/perf_counter.c +4
-0+ [ C(OP_READ) ] = { + [ C(RESULT_ACCESS) ] = 0, + [ C(RESULT_MISS) ] = 0, + },
0x4D- unit0x14k DTLB L1 Hit0x45- unit0x14k DTLB L1 Miss L2 Hit0x46- unit0x14k DTLB L1 Miss L2 MissQuoted 12 lines
arch/x86/kernel/cpu/perf_counter.c +12
-0+ [C (OP_WRITE ) ] = { + [C (RESULT_ACCESS ) ] =0 , + [C (RESULT_MISS ) ] =0 , + }, + [C (OP_PREFETCH ) ] = { + [C (RESULT_ACCESS ) ] =0 , + [C (RESULT_MISS ) ] =0 , + }, + }, + [ C(ITLB) ] = { + [C (OP_READ ) ] = { + [C (RESULT_ACCESS ) ] =0x0080 ,/* Instruction fecthes */ arch/x86/kernel/cpu/perf_counter.c static u64 intel_pmu_raw_event(u64 event) · line 465
Quoted 10 lines
arch/x86/kernel/cpu/perf_counter.c +10
-0+ [C (RESULT_MISS ) ] =0x0085 ,/* Instr. fetch ITLB misses */ + }, + [ C(OP_WRITE) ] = { + [C (RESULT_ACCESS ) ] =-1 , + [C (RESULT_MISS ) ] =-1 , + }, + [C (OP_PREFETCH ) ] = { + [C (RESULT_ACCESS ) ] =-1 , + [C (RESULT_MISS ) ] =-1 , + },
0x84L1 ITLB Miss, L2 ITLB Hit0x85Unit0x1(4k) L1 ITLB Miss, L2 Miss
Quoted 7 lines
arch/x86/kernel/cpu/perf_counter.c static u64 intel_pmu_raw_event(u64 event) · line 470
Quoted 5 lines
+ },
+ [ C(BPU ) ] = {arch/x86/kernel/cpu/perf_counter.c +3
-0+ [ C(OP_READ) ] = { + [ C(RESULT_ACCESS) ] = 0x00c2, /* Retired Branch Instr. */ + [ C(RESULT_MISS) ] = 0x00c3, /* Retired Mispredicted BI */There's also Retired Taken in C4 and C5
Mind turning this into a patch? You did the hard work already :-)
Ingo