Skip to content

Commit 3a4ac12

Browse files
CodyYao-ocPeter Zijlstra
authored andcommitted
x86/perf: Add hardware performance events support for Zhaoxin CPU.
Zhaoxin CPU has provided facilities for monitoring performance via PMU (Performance Monitor Unit), but the functionality is unused so far. Therefore, add support for zhaoxin pmu to make performance related hardware events available. The PMU is mostly an Intel Architectural PerfMon-v2 with a novel errata for the ZXC line. It supports the following events: ----------------------------------------------------------------------------------------------------------------------------------- Event | Event | Umask | Description | Select | | ----------------------------------------------------------------------------------------------------------------------------------- cpu-cycles | 82h | 00h | unhalt core clock instructions | 00h | 00h | number of instructions at retirement. cache-references | 15h | 05h | number of fillq pushs at the current cycle. cache-misses | 1ah | 05h | number of l2 miss pushed by fillq. branch-instructions | 28h | 00h | counts the number of branch instructions retired. branch-misses | 29h | 00h | mispredicted branch instructions at retirement. bus-cycles | 83h | 00h | unhalt bus clock stalled-cycles-frontend | 01h | 01h | Increments each cycle the # of Uops issued by the RAT to RS. stalled-cycles-backend | 0fh | 04h | RS0/1/2/3/45 empty L1-dcache-loads | 68h | 05h | number of retire/commit load. L1-dcache-load-misses | 4bh | 05h | retired load uops whose data source followed an L1 miss. L1-dcache-stores | 69h | 06h | number of retire/commit Store,no LEA L1-dcache-store-misses | 62h | 05h | cache lines in M state evicted out of L1D due to Snoop HitM or dirty line replacement. L1-icache-loads | 00h | 03h | number of l1i cache access for valid normal fetch,including un-cacheable access. L1-icache-load-misses | 01h | 03h | number of l1i cache miss for valid normal fetch,including un-cacheable miss. L1-icache-prefetches | 0ah | 03h | number of prefetch. L1-icache-prefetch-misses | 0bh | 03h | number of prefetch miss. dTLB-loads | 68h | 05h | number of retire/commit load dTLB-load-misses | 2ch | 05h | number of load operations miss all level tlbs and cause a tablewalk. dTLB-stores | 69h | 06h | number of retire/commit Store,no LEA dTLB-store-misses | 30h | 05h | number of store operations miss all level tlbs and cause a tablewalk. dTLB-prefetches | 64h | 05h | number of hardware pte prefetch requests dispatched out of the prefetch FIFO. dTLB-prefetch-misses | 65h | 05h | number of hardware pte prefetch requests miss the l1d data cache. iTLB-load | 00h | 00h | actually counter instructions. iTLB-load-misses | 34h | 05h | number of code operations miss all level tlbs and cause a tablewalk. ----------------------------------------------------------------------------------------------------------------------------------- Reported-by: kbuild test robot <[email protected]> Signed-off-by: CodyYao-oc <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 87cfeb1 commit 3a4ac12

File tree

6 files changed

+639
-0
lines changed

6 files changed

+639
-0
lines changed

arch/x86/events/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ obj-y += core.o probe.o
33
obj-y += amd/
44
obj-$(CONFIG_X86_LOCAL_APIC) += msr.o
55
obj-$(CONFIG_CPU_SUP_INTEL) += intel/
6+
obj-$(CONFIG_CPU_SUP_CENTAUR) += zhaoxin/
7+
obj-$(CONFIG_CPU_SUP_ZHAOXIN) += zhaoxin/

arch/x86/events/core.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,6 +1839,10 @@ static int __init init_hw_perf_events(void)
18391839
err = amd_pmu_init();
18401840
x86_pmu.name = "HYGON";
18411841
break;
1842+
case X86_VENDOR_ZHAOXIN:
1843+
case X86_VENDOR_CENTAUR:
1844+
err = zhaoxin_pmu_init();
1845+
break;
18421846
default:
18431847
err = -ENOTSUPP;
18441848
}

arch/x86/events/perf_event.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ struct x86_pmu {
618618

619619
/* PMI handler bits */
620620
unsigned int late_ack :1,
621+
enabled_ack :1,
621622
counter_freezing :1;
622623
/*
623624
* sysfs attrs
@@ -1133,3 +1134,12 @@ static inline int is_ht_workaround_enabled(void)
11331134
return 0;
11341135
}
11351136
#endif /* CONFIG_CPU_SUP_INTEL */
1137+
1138+
#if ((defined CONFIG_CPU_SUP_CENTAUR) || (defined CONFIG_CPU_SUP_ZHAOXIN))
1139+
int zhaoxin_pmu_init(void);
1140+
#else
1141+
static inline int zhaoxin_pmu_init(void)
1142+
{
1143+
return 0;
1144+
}
1145+
#endif /*CONFIG_CPU_SUP_CENTAUR or CONFIG_CPU_SUP_ZHAOXIN*/

arch/x86/events/zhaoxin/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
obj-y += core.o

0 commit comments

Comments
 (0)