• Peter Zijlstra (Intel)'s avatar
    perf/x86: Fix full width counter, counter overflow · 7f612a7f
    Peter Zijlstra (Intel) authored
    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.
    
    However commit:
    
      069e0c3c ("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
    again.
    Reported-by: default avatarLukasz Odzioba <lukasz.odzioba@intel.com>
    Tested-by: default avatarLiang, Kan <kan.liang@intel.com>
    Tested-by: default avatarOdzioba, Lukasz <lukasz.odzioba@intel.com>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Vince Weaver <vincent.weaver@maine.edu>
    Cc: stable@vger.kernel.org
    Fixes: 069e0c3c ("perf/x86/intel: Support full width counting")
    Signed-off-by: Ingo Molnar's avatarIngo Molnar <mingo@kernel.org>
    7f612a7f
core.c 58 KB