powerpc/perf: Initialise PMU related regs on POWER9
PATCH 2/4 powerpc/perf: Add power9 event list macros for generic and cache events
In reply to Madhavan SrinivasanAdd macros for the generic and cache events on Power9
--- arch/powerpc/perf/power9-events-list.h | 55 ++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 arch/powerpc/perf/power9-events-list.h
arch/powerpc/perf/power9-events-list.h new file +55 -0
@@ -0,0 +1,55 @@ +/* +* Performance counter support for POWER9 processors. +* +* Copyright 2016 Madhavan Srinivasan, IBM Corporation. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +*/ + +/* +* Power9 event codes. +*/ +EVENT(PM_CYC, 0x0001e) +EVENT(PM_ICT_NOSLOT_CYC, 0x100f8) +EVENT(PM_CMPLU_STALL, 0x1e054) +EVENT(PM_INST_CMPL, 0x00002) +EVENT(PM_BRU_CMPL, 0x40060) +EVENT (PM_BR_MPRED_CMPL ,0x400f6 ) + +/* All L1 D cache load references counted at finish, gated by reject */ +EVENT (PM_LD_REF_L1 ,0x100fc ) +/* Load Missed L1 */ +EVENT (PM_LD_MISS_L1_FIN ,0x2c04e ) +/* Store Missed L1 */ +EVENT (PM_ST_MISS_L1 ,0x300f0 ) +/* L1 cache data prefetches */ +EVENT (PM_L1_PREF ,0x20054 ) +/* Instruction fetches from L1 */ +EVENT (PM_INST_FROM_L1 ,0x04080 ) +/* Demand iCache Miss */ +EVENT (PM_L1_ICACHE_MISS ,0x200fd ) +/* Instruction Demand sectors wriittent into IL1 */ +EVENT (PM_L1_DEMAND_WRITE ,0x0408c ) +/* Instruction prefetch written into IL1 */ +EVENT (PM_IC_PREF_WRITE ,0x0408e ) +/* The data cache was reloaded from local core's L3 due to a demand load */ +EVENT (PM_DATA_FROM_L3 ,0x4c042 ) +/* Demand LD - L3 Miss (not L2 hit and not L3 hit) */ +EVENT (PM_DATA_FROM_L3MISS ,0x300fe ) +/* All successful D-side store dispatches for this thread */ +EVENT (PM_L2_ST ,0x16081 ) +/* All successful D-side store dispatches for this thread that were L2 Miss */ +EVENT (PM_L2_ST_MISS ,0x26081 ) +/* Total HW L3 prefetches(Load+store) */ +EVENT (PM_L3_PREF_ALL ,0x4e052 ) +/* Data PTEG reload */ +EVENT (PM_DTLB_MISS ,0x300fc ) +/* ITLB Reloaded */ +EVENT (PM_ITLB_MISS ,0x400fc ) +/* Run_Instructions */ +EVENT (PM_RUN_INST_CMPL ,0x500fa ) +/* Run_cycles */ +EVENT (PM_RUN_CYC ,0x600f4 )
Signature · 1 line
1.9.1
PATCH 3/4 powerpc/perf: Power9 PMU support
In reply to Madhavan SrinivasanThis patch adds base enablement for the power9 PMU.
--- arch/powerpc/perf/Makefile | 2 +- arch/powerpc/perf/power9-pmu.c | 728 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 729 insertions(+), 1 deletion(-) create mode 100644 arch/powerpc/perf/power9-pmu.c
arch/powerpc/perf/Makefile +1 -1
@@ -5,7 +5,7 @@ obj-$(CONFIG_PERF_EVENTS) += callchain.o perf_regs.o obj-$(CONFIG_PPC_PERF_CTRS) += core-book3s.o bhrb.o obj64-$(CONFIG_PPC_PERF_CTRS) += power4-pmu.o ppc970-pmu.o power5-pmu.o \ power5+-pmu.o power6-pmu.o power7-pmu.o \ - power8-pmu.o + power8-pmu.o power9-pmu.o obj32-$(CONFIG_PPC_PERF_CTRS) += mpc7450-pmu.o obj-$(CONFIG_FSL_EMB_PERF_EVENT) += core-fsl-emb.o
arch/powerpc/perf/power9-pmu.c new file +728 -0
728 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 4/4 powerpc/perf: Export Power9 generic and cache events to sysfs
In reply to Madhavan SrinivasanExport the generic hardware and cache perf events for Power9 to sysfs, so users can determine the PMU event monitored.
--- arch/powerpc/perf/power9-pmu.c | 60 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+)
arch/powerpc/perf/power9-pmu.c +60 -0
@@ -489,6 +489,65 @@ static void power9_disable_pmc(unsigned int pmc, unsigned long mmcr[]) mmcr[1 ] &= ~(0xffUL <<MMCR1_PMCSEL_SHIFT (pmc +1 )); } +GENERIC_EVENT_ATTR (cpu-cycles,PM_CYC ); +GENERIC_EVENT_ATTR (stalled-cycles-frontend,PM_ICT_NOSLOT_CYC ); +GENERIC_EVENT_ATTR (stalled-cycles-backend,PM_CMPLU_STALL ); +GENERIC_EVENT_ATTR (instructions,PM_INST_CMPL ); +GENERIC_EVENT_ATTR (branch-instructions,PM_BRU_CMPL ); +GENERIC_EVENT_ATTR (branch-misses,PM_BR_MPRED_CMPL ); +GENERIC_EVENT_ATTR (cache-references,PM_LD_REF_L1 ); +GENERIC_EVENT_ATTR (cache-misses,PM_LD_MISS_L1_FIN ); + +CACHE_EVENT_ATTR (L1 -dcache-load-misses,PM_LD_MISS_L1_FIN ); +CACHE_EVENT_ATTR (L1 -dcache-loads,PM_LD_REF_L1 ); +CACHE_EVENT_ATTR (L1 -dcache-prefetches,PM_L1_PREF ); +CACHE_EVENT_ATTR (L1 -dcache-store-misses,PM_ST_MISS_L1 ); +CACHE_EVENT_ATTR (L1 -icache-load-misses,PM_L1_ICACHE_MISS ); +CACHE_EVENT_ATTR (L1 -icache-loads,PM_INST_FROM_L1 ); +CACHE_EVENT_ATTR (L1 -icache-prefetches,PM_IC_PREF_WRITE ); +CACHE_EVENT_ATTR (LLC -load-misses,PM_DATA_FROM_L3MISS ); +CACHE_EVENT_ATTR (LLC -loads,PM_DATA_FROM_L3 ); +CACHE_EVENT_ATTR (LLC -prefetches,PM_L3_PREF_ALL ); +CACHE_EVENT_ATTR (LLC -store-misses,PM_L2_ST_MISS ); +CACHE_EVENT_ATTR (LLC -stores,PM_L2_ST ); +CACHE_EVENT_ATTR (branch-load-misses,PM_BR_MPRED_CMPL ); +CACHE_EVENT_ATTR (branch-loads,PM_BRU_CMPL ); +CACHE_EVENT_ATTR (dTLB-load-misses,PM_DTLB_MISS ); +CACHE_EVENT_ATTR (iTLB-load-misses,PM_ITLB_MISS ); + +static struct attribute *power9_events_attr[] = { +GENERIC_EVENT_PTR (PM_CYC ), +GENERIC_EVENT_PTR (PM_ICT_NOSLOT_CYC ), +GENERIC_EVENT_PTR (PM_CMPLU_STALL ), +GENERIC_EVENT_PTR (PM_INST_CMPL ), +GENERIC_EVENT_PTR (PM_BRU_CMPL ), +GENERIC_EVENT_PTR (PM_BR_MPRED_CMPL ), +GENERIC_EVENT_PTR (PM_LD_REF_L1 ), +GENERIC_EVENT_PTR (PM_LD_MISS_L1_FIN ), +CACHE_EVENT_PTR (PM_LD_MISS_L1_FIN ), +CACHE_EVENT_PTR (PM_LD_REF_L1 ), +CACHE_EVENT_PTR (PM_L1_PREF ), +CACHE_EVENT_PTR (PM_ST_MISS_L1 ), +CACHE_EVENT_PTR (PM_L1_ICACHE_MISS ), +CACHE_EVENT_PTR (PM_INST_FROM_L1 ), +CACHE_EVENT_PTR (PM_IC_PREF_WRITE ), +CACHE_EVENT_PTR (PM_DATA_FROM_L3MISS ), +CACHE_EVENT_PTR (PM_DATA_FROM_L3 ), +CACHE_EVENT_PTR (PM_L3_PREF_ALL ), +CACHE_EVENT_PTR (PM_L2_ST_MISS ), +CACHE_EVENT_PTR (PM_L2_ST ), +CACHE_EVENT_PTR (PM_BR_MPRED_CMPL ), +CACHE_EVENT_PTR (PM_BRU_CMPL ), +CACHE_EVENT_PTR (PM_DTLB_MISS ), +CACHE_EVENT_PTR (PM_ITLB_MISS ), +NULL +}; + +static struct attribute_group power9_pmu_events_group = { + .name ="events" , + .attrs = power9_events_attr, +}; +PMU_FORMAT_ATTR (event,"config:0-49" );PMU_FORMAT_ATTR (pmcxsel,"config:0-7" );PMU_FORMAT_ATTR (mark,"config:8" );
@@ -525,6 +584,7 @@ struct attribute_group power9_pmu_format_group = {static const struct attribute_group *power9_pmu_attr_groups[] = { &power9_pmu_format_group, + &power9_pmu_events_group,NULL , };
Signature · 1 line
1.9.1
PATCH 1/4 powerpc/perf: Initialise PMU related regs on POWER9
Add two new init functions __init_PMU_300 and __init_PMU_HV_300 to initialise PMU related regs on POWER9.
--- arch/powerpc/kernel/cpu_setup_power.S | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
arch/powerpc/kernel/cpu_setup_power.S +17 -0
@@ -87,6 +87,7 @@ _GLOBAL(__restore_cpu_power8) _GLOBAL(__setup_cpu_power9) mflr r11 bl __init_FSCR + bl __init_PMU_300 bl __init_hvmode_206 mtlr r11 beqlr
@@ -97,12 +98,14 @@ _GLOBAL(__setup_cpu_power9) bl __init_LPCR bl __init_HFSCR bl __init_tlb_power9 + bl __init_PMU_HV_300 mtlr r11 blr _GLOBAL(__restore_cpu_power9) mflr r11 bl __init_FSCR + bl __init_PMU_300 mfmsr r3 rldicl. r0,r3,4,63 mtlr r11
@@ -114,6 +117,7 @@ _GLOBAL(__restore_cpu_power9) bl __init_LPCR bl __init_HFSCR bl __init_tlb_power9 + bl __init_PMU_HV_300 mtlr r11 blr
@@ -219,3 +223,16 @@ __init_PMU: mtspr SPRN_MMCR1,r5 mtspr SPRN_MMCR2,r5 blr + +__init_PMU_HV_300: + li r5,0 + mtspr SPRN_MMCRC,r5 + blr + +__init_PMU_300: + li r5,0 + mtspr SPRN_MMCRA,r5 + mtspr SPRN_MMCR0,r5 + mtspr SPRN_MMCR1,r5 + mtspr SPRN_MMCR2,r5 + blr
Signature · 1 line
1.9.1
Michael Ellerman
reviewerRe: [3/4] powerpc/perf: Power9 PMU support
In reply to Madhavan SrinivasanQuoted 1 line · Madhavan Srinivasan
This patch adds base enablement for the power9 PMU.
This is almost line-for-line identical to the Power8 code, with the exception of some things you haven't sent yet because they're not ready.
Can you try and factor out some of the common bits please?
Perhaps isa207-common.c ? But I don't really mind.
cheers
Michael Ellerman
reviewerQuoted 11 lines · Madhavan Srinivasan
arch/powerpc/kernel/cpu_setup_power.S +3
-0@@ -219,3 +223,16 @@ __init_PMU: mtspr SPRN_MMCR1,r5 mtspr SPRN_MMCR2,r5 blr + +__init_PMU_HV_300: + li r5,0
arch/powerpc/kernel/cpu_setup_power.S __init_PMU: · line 238
Quoted 10 lines
arch/powerpc/kernel/cpu_setup_power.S +10
-0+ mtspr SPRN_MMCRC,r5 + blr + +__init_PMU_300: + li r5,0 + mtspr SPRN_MMCRA,r5 + mtspr SPRN_MMCR0,r5 + mtspr SPRN_MMCR1,r5 + mtspr SPRN_MMCR2,r5 + blr
With the exception of MMCRS, these are the same as the Power8 code. So there should be able to be some common code.
cheers