diff options
author | adrian <adrian@FreeBSD.org> | 2008-03-18 08:39:11 +0000 |
---|---|---|
committer | adrian <adrian@FreeBSD.org> | 2008-03-18 08:39:11 +0000 |
commit | 63f525812cee08ddad6461a0acdb49f9ea31ef2f (patch) | |
tree | 622c4f699cb3263ced49fbf0620fb29bdc394a0e /sys/dev/hwpmc | |
parent | 26e3101bd970c1bf9ffd781cd07ea7a57c1c2554 (diff) | |
download | FreeBSD-src-63f525812cee08ddad6461a0acdb49f9ea31ef2f.zip FreeBSD-src-63f525812cee08ddad6461a0acdb49f9ea31ef2f.tar.gz |
Sign-extend the 48-bit AMD PMC counter before treating it to a 64-bit
2's compliment.
The 2's compliment transform is done so a "count down" sampling interval
can be converted into a "count up" PMC value. a 2's complimented 'count down'
value is written to the PMC counter; then the read-back counter is reverted
via another 2's compliment.
PR: kern/121660
Reviewed by: jkoshy
Approved by: jkoshy
MFC after: 1 week
Diffstat (limited to 'sys/dev/hwpmc')
-rw-r--r-- | sys/dev/hwpmc/hwpmc_amd.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/dev/hwpmc/hwpmc_amd.c b/sys/dev/hwpmc/hwpmc_amd.c index 26216be..8f8641e 100644 --- a/sys/dev/hwpmc/hwpmc_amd.c +++ b/sys/dev/hwpmc/hwpmc_amd.c @@ -302,12 +302,15 @@ amd_read_pmc(int cpu, int ri, pmc_value_t *v) #endif tmp = rdmsr(pd->pm_perfctr); /* RDMSR serializes */ - if (PMC_IS_SAMPLING_MODE(mode)) - *v = AMD_PERFCTR_VALUE_TO_RELOAD_COUNT(tmp); - else - *v = tmp; + PMCDBG(MDP,REA,2,"amd-read (pre-munge) id=%d -> %jd", ri, tmp); + if (PMC_IS_SAMPLING_MODE(mode)) { + /* Sign extend 48 bit value to 64 bits. */ + tmp = (pmc_value_t) (((int64_t) tmp << 16) >> 16); + tmp = AMD_PERFCTR_VALUE_TO_RELOAD_COUNT(tmp); + } + *v = tmp; - PMCDBG(MDP,REA,2,"amd-read id=%d -> %jd", ri, *v); + PMCDBG(MDP,REA,2,"amd-read (post-munge) id=%d -> %jd", ri, *v); return 0; } |