• Stephane Eranian's avatar
    perf: Fix double start/stop in x86_pmu_start() · f39d47ff
    Stephane Eranian authored
    The following patch fixes a bug introduced by the following
    commit:
    
            e050e3f0 ("perf: Fix broken interrupt rate throttling")
    
    The patch caused the following warning to pop up depending on
    the sampling frequency adjustments:
    
      ------------[ cut here ]------------
      WARNING: at arch/x86/kernel/cpu/perf_event.c:995 x86_pmu_start+0x79/0xd4()
    
    It was caused by the following call sequence:
    
    perf_adjust_freq_unthr_context.part() {
         stop()
         if (delta > 0) {
              perf_adjust_period() {
                  if (period > 8*...) {
                      stop()
                      ...
                      start()
                  }
              }
          }
          start()
    }
    
    Which caused a double start and a double stop, thus triggering
    the assert in x86_pmu_start().
    
    The patch fixes the problem by avoiding the double calls. We
    pass a new argument to perf_adjust_period() to indicate whether
    or not the event is already stopped. We can't just remove the
    start/stop from that function because it's called from
    __perf_event_overflow where the event needs to be reloaded via a
    stop/start back-toback call.
    
    The patch reintroduces the assertion in x86_pmu_start() which
    was removed by commit:
    
    	84f2b9b2 ("perf: Remove deprecated WARN_ON_ONCE()")
    
    In this second version, we've added calls to disable/enable PMU
    during unthrottling or frequency adjustment based on bug report
    of spurious NMI interrupts from Eric Dumazet.
    Reported-and-tested-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
    Signed-off-by: default avatarStephane Eranian <eranian@google.com>
    Acked-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
    Cc: markus@trippelsdorf.de
    Cc: paulus@samba.org
    Link: http://lkml.kernel.org/r/20120207133956.GA4932@quad
    [ Minor edits to the changelog and to the code ]
    Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
    f39d47ff
core.c 161 KB