perf/x86: Fix full width counter, counter overflow
commit 7f612a7f0bc13a2361a152862435b7941156b6af upstream.
Lukasz reported that perf stat counters overflow handling is broken on KNL/SLM.
Both these parts have full_width_write set, and that does indeed have
a problem. In order to deal with counter wrap, we must sample the
counter at at least half the counter period (see also the sampling
theorem) such that we can unambiguously reconstruct the count.
069e0c3c4058 ("perf/x86/intel: Support full width counting")
sets the sampling interval to the full period, not half.
Fixing that exposes another issue, in that we must not sign extend the
delta value when we shift it right; the counter cannot have
decremented after all.
With both these issues fixed, counter overflow functions correctly
Reported-by: Lukasz Odzioba <email@example.com>
Tested-by: Liang, Kan <firstname.lastname@example.org>
Tested-by: Odzioba, Lukasz <email@example.com>
Signed-off-by: Peter Zijlstra (Intel) <firstname.lastname@example.org>
Cc: Alexander Shishkin <email@example.com>
Cc: Arnaldo Carvalho de Melo <firstname.lastname@example.org>
Cc: Jiri Olsa <email@example.com>
Cc: Linus Torvalds <firstname.lastname@example.org>
Cc: Peter Zijlstra <email@example.com>
Cc: Stephane Eranian <firstname.lastname@example.org>
Cc: Thomas Gleixner <email@example.com>
Cc: Vince Weaver <firstname.lastname@example.org>
Fixes: 069e0c3c4058 ("perf/x86/intel: Support full width counting")
Signed-off-by: Ingo Molnar <email@example.com>
Signed-off-by: Greg Kroah-Hartman <firstname.lastname@example.org>
2 files changed