perf/x86/amd: Fix sampling Large Increment per Cycle events
authorKim Phillips <kim.phillips@amd.com>
Tue, 8 Sep 2020 21:47:35 +0000 (16:47 -0500)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 10 Sep 2020 09:19:35 +0000 (11:19 +0200)
commit26e52558ead4b39c0e0fe7bf08f82f5a9777a412
tree2e4097b26a6149fe62bd2a96b2f5c227db3d507c
parentc8fe99d0701fec9fb849ec880a86bc5592530496
perf/x86/amd: Fix sampling Large Increment per Cycle events

Commit 5738891229a2 ("perf/x86/amd: Add support for Large Increment
per Cycle Events") mistakenly zeroes the upper 16 bits of the count
in set_period().  That's fine for counting with perf stat, but not
sampling with perf record when only Large Increment events are being
sampled.  To enable sampling, we sign extend the upper 16 bits of the
merged counter pair as described in the Family 17h PPRs:

"Software wanting to preload a value to a merged counter pair writes the
high-order 16-bit value to the low-order 16 bits of the odd counter and
then writes the low-order 48-bit value to the even counter. Reading the
even counter of the merged counter pair returns the full 64-bit value."

Fixes: 5738891229a2 ("perf/x86/amd: Add support for Large Increment per Cycle Events")
Signed-off-by: Kim Phillips <kim.phillips@amd.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Link: https://bugzilla.kernel.org/show_bug.cgi?id=206537
arch/x86/events/core.c