issues with hwpmc and athlon XP

From: Adrian Chadd <adrian_at_freebsd.org>
Date: Mon, 10 Mar 2008 01:46:03 +0900
Between my Athlon XP box giving me no useful pmc stats and my new Core
2 duo box not even working with pmc, I decided to poke at the Athlon
XP support a bit to see if I could figure out what was going on.

It seems that at least my revision of the Athlon XP has 48 bit
performance counters (AMD Athlon Processor x86 Code Optimisation
Guide, page 235 (Performance-Monitoring Counters: Overview) and the
top 16 bits read back 0x0000.

Since the code is taking the 2's compliment of the stored PMC value
(which is so the value is incremented to 0xffffffffffffffff and wraps
over, generating an NMI - mentioned on page 240), negating the value
gives humerous results:

Mar  9 16:09:43 jacinta kernel: hwpmc: TSC/1/0x20<REA>
K7/4/0x1ff<INT,USR,SYS,EDG,THR,REA,WRI,INV,QUA>
Mar  9 16:10:02 jacinta kernel: MDP:SWO:1: pc=0xc5814180 pp=0 enable-msr=0
Mar  9 16:10:02 jacinta kernel: local initial: ri 1: 65536
Mar  9 16:10:02 jacinta kernel: MDP:SWO:1: pc=0xc5814180 pp=0xc576a780
enable-msr=0
Mar  9 16:10:02 jacinta kernel: csw_in: ri 1; pmcval 65536
Mar  9 16:10:02 jacinta kernel: MDP:WRI:1: amd-write cpu=0 ri=1
v=ffffffffffff0000
Mar  9 16:10:02 jacinta kernel: MDP:SWI:1: pc=0xc5814180 pp=0xc576a780
enable-msr=0
Mar  9 16:10:02 jacinta kernel: MDP:REA:1: amd-read id=1 class=1
Mar  9 16:10:02 jacinta kernel: MDP:REA:2: amd-read id=1 -> ffff00000000ff01
Mar  9 16:10:02 jacinta kernel: read: ffff00000000ff01; saved 10000;
diff -281474976710911
Mar  9 16:10:02 jacinta kernel: csw_out: ri 1: pp_pmcval 65536..
Mar  9 16:10:02 jacinta kernel: csw_out: ... ri 1: pp_pmcval now
281474976710911..
Mar  9 16:10:02 jacinta kernel: MDP:SWO:1: pc=0xc5814180 pp=0xc576a780
enable-msr=0
Mar  9 16:10:02 jacinta kernel: csw_in: ri 1; pmcval 281474976710911
Mar  9 16:10:02 jacinta kernel: MDP:WRI:1: amd-write cpu=0 ri=1
v=fffeffffffffff01
Mar  9 16:10:02 jacinta kernel: MDP:SWI:1: pc=0xc5814180 pp=0xc576a780
enable-msr=0
Mar  9 16:10:02 jacinta kernel: MDP:REA:1: amd-read id=1 class=1
Mar  9 16:10:02 jacinta kernel: MDP:REA:2: amd-read id=1 -> ffff00000000f47f
Mar  9 16:10:02 jacinta kernel: read: ffff00000000f47f; saved
10000000000ff; diff -562949953358976
Mar  9 16:10:02 jacinta kernel: csw_out: ri 1: pp_pmcval 281474976710911..
Mar  9 16:10:02 jacinta kernel: csw_out: ... ri 1: pp_pmcval now
844424930004351..

The machine is currently updating to the latest -current (which has
the same codepath, so I'm guessing it'll fail the same way here) so I
can't provide any further accurate testing just yet. Fixing the
amd_read_pmc() routine started providing per-process statistics but I
still couldn't see anything relating to the current process.

(Oh and whilst I'm at it; maybe some documentation relating to your
pmc debugging features would be nice. :)


Adrian


-- 
Adrian Chadd - adrian_at_freebsd.org
Received on Sun Mar 09 2008 - 16:10:22 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:28 UTC