• Peter Zijlstra's avatar
    perf/x86: Fix NMI measurements · e8a923cc
    Peter Zijlstra authored
    OK, so what I'm actually seeing on my WSM is that sched/clock.c is
    'broken' for the purpose we're using it for.
    
    What triggered it is that my WSM-EP is broken :-(
    
      [    0.001000] tsc: Fast TSC calibration using PIT
      [    0.002000] tsc: Detected 2533.715 MHz processor
      [    0.500180] TSC synchronization [CPU#0 -> CPU#6]:
      [    0.505197] Measured 3 cycles TSC warp between CPUs, turning off TSC clock.
      [    0.004000] tsc: Marking TSC unstable due to check_tsc_sync_source failed
    
    For some reason it consistently detects TSC skew, even though NHM+
    should have a single clock domain for 'reasonable' systems.
    
    This marks sched_clock_stable=0, which means that we do fancy stuff to
    try and get a 'sane' clock. Part of this fancy stuff relies on the tick,
    clearly that's gone when NOHZ=y. So for idle cpus time gets stuck, until
    it either wakes up or gets kicked by another cpu.
    
    While this is perfectly fine for the scheduler -- it only cares about
    actually running stuff, and when we're running stuff we're obviously not
    idle. This does somewhat break down for perf which can trigger events
    just fine on an otherwise idle cpu.
    
    So I've got NMIs get get 'measured' as taking ~1ms, which actually
    don't last nearly that long:
    
              <idle>-0     [013] d.h.   886.311970: rcu_nmi_enter <-do_nmi
      ...
              <idle>-0     [013] d.h.   886.311997: perf_sample_event_took: HERE!!! : 1040990
    
    So ftrace (which uses sched_clock(), not the fancy bits) only sees
    ~27us, but we measure ~1ms !!
    
    Now since all this measurement stuff lives in x86 code, we can actually
    fix it.
    Signed-off-by: default avatarPeter Zijlstra <peterz@infradead.org>
    Cc: mingo@kernel.org
    Cc: dave.hansen@linux.intel.com
    Cc: eranian@google.com
    Cc: Don Zickus <dzickus@redhat.com>
    Cc: jmario@redhat.com
    Cc: acme@infradead.org
    Link: http://lkml.kernel.org/r/20131017133350.GG3364@laptop.programming.kicks-ass.netSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
    e8a923cc
perf_event.c 48.2 KB