x86: Basic AMD Support for performance counters
Hello Ingo,
These patches added basic AMD (K7 and later) support for performance counters:
[jaswinder@hpdv5 linux-2.6-tip]$ perfstat -e 0,1,2,3,4,5,-1,-2,-3,-4,-5 ls -lR > /dev/null
Performance counter stats for 'ls':
2723.203821 task clock ticks (msecs)
1812527794 CPU cycles (events)
1121688997 instructions (events)
569836744 cache references (events)
15934598 cache misses (events)
57313261 branches (events)
4243201 branch misses (events)
2639.682866 cpu clock ticks (msecs)
2723.203821 task clock ticks (msecs)
647 pagefaults (events)
2401 context switches (events)
3 CPU migrations (events)Wall-clock time elapsed: 6813.030975 msecs
The following changes since commit f39e09b3b2c11ad1b008518a05bc2b7c25eabc7d:
Ingo Molnar (1):
Merge branch 'tracing/ftrace'
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/jaswinder/linux-2.6-tip.git master
Jaswinder Singh Rajput (2):
x86: prepare perf_counter to add more cpus
x86: AMD Support for perf_counter
arch/x86/kernel/cpu/amd.c | 4 + arch/x86/kernel/cpu/perf_counter.c | 189 ++++++++++++++++++++++++++++++------ 2 files changed, 163 insertions(+), 30 deletions(-)
Complete diff:
arch/x86/kernel/cpu/amd.c +4 -0
@@ -368,6 +368,10 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)if (c->x86 >=6 )set_cpu_cap (c,X86_FEATURE_FXSAVE_LEAK ); +/* Enable Performance counter for K7 and later */ +if (c->x86 >6 && c->x86 <=0x11 ) +set_cpu_cap (c,X86_FEATURE_ARCH_PERFMON ); +if (!c->x86_model_id[0 ]) {switch (c->x86) {case 0xf :
arch/x86/kernel/cpu/perf_counter.c +159 -30
317 lines not on this page · raw message
Quoted 22 lines · Jaswinder Singh Rajput
Hello Ingo,
These patches added basic AMD (K7 and later) support for performance counters:
[jaswinder@hpdv5 linux-2.6-tip]$ perfstat -e 0,1,2,3,4,5,-1,-2,-3,-4,-5 ls -lR >
/dev/nullPerformance counter stats for 'ls':
2723.203821 task clock ticks (msecs) 1812527794 CPU cycles (events) 1121688997 instructions (events) 569836744 cache references (events) 15934598 cache misses (events) 57313261 branches (events) 4243201 branch misses (events) 2639.682866 cpu clock ticks (msecs) 2723.203821 task clock ticks (msecs) 647 pagefaults (events) 2401 context switches (events) 3 CPU migrations (events)
Quoted 1 line
Wall-clock time elapsed: 6813.030975 msecs
Very nice feature!
The AMD patches look much cleaner than i feared they would be. It seems you were able to keep pretty generic x86 code in arch/x86/kernel/cpu/perf_counters.c, sharing most of the logic between Intel and AMD perfcounters.
Quoted 8 lines
The following changes since commit
f39e09b3b2c11ad1b008518a05bc2b7c25eabc7d:
Ingo Molnar (1):
Merge branch 'tracing/ftrace'are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/jaswinder/linux-2.6-tip.gitmaster
Quoted 7 lines
Jaswinder Singh Rajput (2):
x86: prepareperf_counterto add more cpus
x86: AMD Support forperf_counterarch/x86/kernel/cpu/amd.c | 4 + arch/x86/kernel/cpu/perf_counter.c | 189 ++++++++++++++++++++++++++++++------ 2 files changed, 163 insertions(+), 30 deletions(-)
Pulled into tip:perfcounters/core, thanks Jaswinder!
Ingo
Quoted 24 lines · Ingo Molnar
Quoted 22 lines · Jaswinder Singh Rajput
Hello Ingo,
These patches added basic AMD (K7 and later) support for performance counters:
[jaswinder@hpdv5 linux-2.6-tip]$ perfstat -e 0,1,2,3,4,5,-1,-2,-3,-4,-5 ls -lR >
/dev/nullPerformance counter stats for 'ls':
2723.203821 task clock ticks (msecs) 1812527794 CPU cycles (events) 1121688997 instructions (events) 569836744 cache references (events) 15934598 cache misses (events) 57313261 branches (events) 4243201 branch misses (events) 2639.682866 cpu clock ticks (msecs) 2723.203821 task clock ticks (msecs) 647 pagefaults (events) 2401 context switches (events) 3 CPU migrations (events)
Quoted 8 lines
Quoted 1 line
Wall-clock time elapsed: 6813.030975 msecs
Very nice feature!
The AMD patches look much cleaner than i feared they would be. It seems you were able to keep pretty generic x86 code in
arch/x86/kernel/cpu/perf_counters.c, sharing most of the logic between Intel and AMD perfcounters.
Seems to be working fine, here's the output from an Athlon 64 3200+ (Sempron) box:
Performance counter stats for 'ls':
17.420811 task clock ticks (msecs)
0 CPU migrations (events)
12 context switches (events)
583 pagefaults (events)
29760299 CPU cycles (events)
29401642 instructions (events)
12698498 cache references (events)
66269 cache misses (events)
Wall-clock time elapsed: 687.999988 msecs
Ingo
Quoted 15 lines · Ingo Molnar
Seems to be working fine, here's the output from an Athlon 64 3200+ (Sempron) box:
Performance counter stats for 'ls':
17.420811 task clock ticks (msecs)
0 CPU migrations (events)
12 context switches (events)
583 pagefaults (events)
29760299 CPU cycles (events)
29401642 instructions (events)
12698498 cache references (events)
66269 cache misses (events)
Quoted 1 line
Wall-clock time elapsed: 687.999988 msecs
The patches cause a crash on another system - an Opteron system spontaneous reboots at this point during early bootup:
CPU 0/0x4 -> Node 0
tseg: 00cfe00000
CPU: Physical Processor ID: 0
CPU: Processor Core ID: 0
using C1E aware idle routine
AMD Performance Monitoring support detected.
... num counters: 4 ... value mask: 0000000000000000 ... fixed counters: 0 ... counter mask: 000000000000000f
ACPI: Core revision 20081204
ftrace: converting mcount calls to 0f 1f 44 00 00
ftrace: allocating 16365 entries in 129 pages
Setting APIC routing to physical flat
masked ExtINT on CPU#0
ENABLING IO
[reboot]
this is the CPU type:
processor : 15vendor_id : AuthenticAMD
cpu family : 16
model : 2
model name : Quad-Core AMD Opteron(tm) Processor 8356
stepping : 3
cpu MHz : 2300.000
cache size : 512 KB
physical id : 4
siblings : 4
core id : 3
cpu cores : 4
fpu : yesfpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep
mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc rep_good pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs
bogomips : 4622.47
TLB size : 1024 4K pages
clflush size : 64cache_alignment : 64
address sizes : 48 bits physical, 48 bits virtual
power management: ts ttp tm stc 100mhzsteps hwpstate
Ingo
Quoted 32 lines · Ingo Molnar
Quoted 15 lines · Ingo Molnar
Seems to be working fine, here's the output from an Athlon 64 3200+ (Sempron) box:
Performance counter stats for 'ls':
17.420811 task clock ticks (msecs)
0 CPU migrations (events)
12 context switches (events)
583 pagefaults (events)
29760299 CPU cycles (events)
29401642 instructions (events)
12698498 cache references (events)
66269 cache misses (events)Quoted 1 line
Wall-clock time elapsed: 687.999988 msecs
The patches cause a crash on another system - an Opteron system spontaneous reboots at this point during early bootup:
CPU 0/0x4 -> Node 0
tseg:00cfe00000
CPU: Physical Processor ID: 0
CPU: Processor Core ID: 0
using C1E aware idle routine
AMD Performance Monitoring support detected.... num counters: 4 ... value mask: 0000000000000000 ... fixed counters: 0 ... counter mask: 000000000000000f
Quoted 8 lines
ACPI: Core revision 20081204
ftrace: converting mcount calls to 0f 1f 44 00 00
ftrace: allocating 16365 entries in 129 pages
Setting APIC routing to physical flat
masked ExtINT on CPU#0
ENABLING IO
[reboot]
Can you please share your config file.
Thanks,
--
JSR
Quoted 42 lines · Jaswinder Singh Rajput
Quoted 32 lines · Ingo Molnar
Quoted 15 lines · Ingo Molnar
Seems to be working fine, here's the output from an Athlon 64 3200+ (Sempron) box:
Performance counter stats for 'ls':
17.420811 task clock ticks (msecs)
0 CPU migrations (events)
12 context switches (events)
583 pagefaults (events)
29760299 CPU cycles (events)
29401642 instructions (events)
12698498 cache references (events)
66269 cache misses (events)Quoted 1 line
Wall-clock time elapsed: 687.999988 msecs
The patches cause a crash on another system - an Opteron system spontaneous reboots at this point during early bootup:
CPU 0/0x4 -> Node 0
tseg:00cfe00000
CPU: Physical Processor ID: 0
CPU: Processor Core ID: 0
using C1E aware idle routine
AMD Performance Monitoring support detected.... num counters: 4 ... value mask: 0000000000000000 ... fixed counters: 0 ... counter mask: 000000000000000fQuoted 8 lines
ACPI: Core revision 20081204
ftrace: converting mcount calls to 0f 1f 44 00 00
ftrace: allocating 16365 entries in 129 pages
Setting APIC routing to physical flat
masked ExtINT on CPU#0
ENABLING IO
[reboot]
Quoted 1 line
Can you please share your config file.
any config file will crash that box. I used the 64-bit defconfig
- i.e. 'make ARCH=x86_64 defconfig'.
Ingo
Quoted 44 lines · Ingo Molnar
Quoted 42 lines · Jaswinder Singh Rajput
Quoted 40 lines · Ingo Molnar
Quoted 15 lines · Ingo Molnar
Seems to be working fine, here's the output from an Athlon 64 3200+ (Sempron) box:
Performance counter stats for 'ls':
17.420811 task clock ticks (msecs)
0 CPU migrations (events)
12 context switches (events)
583 pagefaults (events)
29760299 CPU cycles (events)
29401642 instructions (events)
12698498 cache references (events)
66269 cache misses (events)Quoted 1 line
Wall-clock time elapsed: 687.999988 msecs
The patches cause a crash on another system - an Opteron system spontaneous reboots at this point during early bootup:
CPU 0/0x4 -> Node 0
tseg:00cfe00000
CPU: Physical Processor ID: 0
CPU: Processor Core ID: 0
using C1E aware idle routine
AMD Performance Monitoring support detected.... num counters: 4 ... value mask: 0000000000000000 ... fixed counters: 0 ... counter mask: 000000000000000fACPI: Core revision 20081204
ftrace: converting mcount calls to 0f 1f 44 00 00
ftrace: allocating 16365 entries in 129 pages
Setting APIC routing to physical flat
masked ExtINT on CPU#0
ENABLING IO
[reboot]
Quoted 5 lines
Quoted 1 line
Can you please share your config file.
any config file will crash that box. I used the 64-bit defconfig
- i.e. 'make ARCH=x86_64 defconfig'.
Can you please try this patch:
arch/x86/kernel/cpu/perf_counter.c +3 -1
@@ -146,7 +146,9 @@ static int __hw_perf_counter_init(struct perf_counter *counter)* Generate PMC IRQs: * (keep 'enabled' bit clear for now) */ - hwc->config =ARCH_PERFMON_EVENTSEL_INT ; +/* Currently Interrupts are disabled on AMD */ +if (boot_cpu_data.x86_vendor !=X86_VENDOR_AMD ) + hwc->config =ARCH_PERFMON_EVENTSEL_INT ;/* * Count user and OS events unless requested not to.
Quoted 58 lines · Jaswinder Singh Rajput
Quoted 44 lines · Ingo Molnar
Quoted 42 lines · Jaswinder Singh Rajput
Quoted 40 lines · Ingo Molnar
Quoted 15 lines · Ingo Molnar
Seems to be working fine, here's the output from an Athlon 64 3200+ (Sempron) box:
Performance counter stats for 'ls':
17.420811 task clock ticks (msecs)
0 CPU migrations (events)
12 context switches (events)
583 pagefaults (events)
29760299 CPU cycles (events)
29401642 instructions (events)
12698498 cache references (events)
66269 cache misses (events)Quoted 1 line
Wall-clock time elapsed: 687.999988 msecs
The patches cause a crash on another system - an Opteron system spontaneous reboots at this point during early bootup:
CPU 0/0x4 -> Node 0
tseg:00cfe00000
CPU: Physical Processor ID: 0
CPU: Processor Core ID: 0
using C1E aware idle routine
AMD Performance Monitoring support detected.... num counters: 4 ... value mask: 0000000000000000 ... fixed counters: 0 ... counter mask: 000000000000000fACPI: Core revision 20081204
ftrace: converting mcount calls to 0f 1f 44 00 00
ftrace: allocating 16365 entries in 129 pages
Setting APIC routing to physical flat
masked ExtINT on CPU#0
ENABLING IO
[reboot]Quoted 5 lines
Quoted 1 line
Can you please share your config file.
any config file will crash that box. I used the 64-bit defconfig
- i.e. 'make ARCH=x86_64 defconfig'.Can you please try this patch:
arch/x86/kernel/cpu/perf_counter.c +0
-0
arch/x86/kernel/cpu/perf_counter.c static int __hw_perf_counter_init(struct perf_counter *counter) · line 151
Quoted 7 lines
arch/x86/kernel/cpu/perf_counter.c +3
-1@@ -146,7 +146,9 @@ static int __hw_perf_counter_init(struct perf_counter *counter)* Generate PMC IRQs: * (keep 'enabled' bit clear for now) */ - hwc->config =ARCH_PERFMON_EVENTSEL_INT ; +/* Currently Interrupts are disabled on AMD */ +if (boot_cpu_data.x86_vendor !=X86_VENDOR_AMD ) + hwc->config =ARCH_PERFMON_EVENTSEL_INT ;
still crashes in a similar way.
hm, this box has nmi_watchdog=2, and the NMI watchdog uses the PMU too - will disable that.
Ingo
Quoted 71 lines · Ingo Molnar
Quoted 58 lines · Jaswinder Singh Rajput
Quoted 44 lines · Ingo Molnar
Quoted 42 lines · Jaswinder Singh Rajput
Quoted 40 lines · Ingo Molnar
Quoted 15 lines · Ingo Molnar
Seems to be working fine, here's the output from an Athlon 64 3200+ (Sempron) box:
Performance counter stats for 'ls':
17.420811 task clock ticks (msecs)
0 CPU migrations (events)
12 context switches (events)
583 pagefaults (events)
29760299 CPU cycles (events)
29401642 instructions (events)
12698498 cache references (events)
66269 cache misses (events)Quoted 1 line
Wall-clock time elapsed: 687.999988 msecs
The patches cause a crash on another system - an Opteron system spontaneous reboots at this point during early bootup:
CPU 0/0x4 -> Node 0
tseg:00cfe00000
CPU: Physical Processor ID: 0
CPU: Processor Core ID: 0
using C1E aware idle routine
AMD Performance Monitoring support detected.... num counters: 4 ... value mask: 0000000000000000 ... fixed counters: 0 ... counter mask: 000000000000000fACPI: Core revision 20081204
ftrace: converting mcount calls to 0f 1f 44 00 00
ftrace: allocating 16365 entries in 129 pages
Setting APIC routing to physical flat
masked ExtINT on CPU#0
ENABLING IO
[reboot]Quoted 5 lines
Quoted 1 line
Can you please share your config file.
any config file will crash that box. I used the 64-bit defconfig
- i.e. 'make ARCH=x86_64 defconfig'.Can you please try this patch:
arch/x86/kernel/cpu/perf_counter.c +0
-0arch/x86/kernel/cpu/perf_counter.c static int __hw_perf_counter_init(struct perf_counter *counter) · line 151
Quoted 7 lines
arch/x86/kernel/cpu/perf_counter.c +3
-1@@ -146,7 +146,9 @@ static int __hw_perf_counter_init(struct perf_counter *counter)* Generate PMC IRQs: * (keep 'enabled' bit clear for now) */ - hwc->config =ARCH_PERFMON_EVENTSEL_INT ; +/* Currently Interrupts are disabled on AMD */ +if (boot_cpu_data.x86_vendor !=X86_VENDOR_AMD ) + hwc->config =ARCH_PERFMON_EVENTSEL_INT ;still crashes in a similar way.
Quoted 2 lines
hm, this box has nmi_watchdog=2, and the NMI watchdog uses the PMU too - will disable that.
yep, nmi_watchdog=0 solves the regression. You ought to be able to reproduce the same problem by adding nmi_watchdog=2 on your testbox.
Ingo
Quoted 12 lines · Ingo Molnar
Quoted 5 lines · Ingo Molnar
still crashes in a similar way.
hm, this box has nmi_watchdog=2, and the NMI watchdog uses the PMU too - will disable that.
yep, nmi_watchdog=0 solves the regression. You ought to be able to reproduce the same problem by adding nmi_watchdog=2 on your testbox.
One of my AMD box is broken because of hot weather So now I have only one AMD box left.
By adding nmi_watchdog=2 does not effect my AMD 64 bit box. But any how I will fix the interrupt handler so that you can receive interrupts on your box.
Thanks,
--
JSR