Skip to content
  • Alexander Shishkin's avatar
    perf/x86/intel: Fix PMI handling for Intel PT · 1b7b938f
    Alexander Shishkin authored and Ingo Molnar's avatar Ingo Molnar committed
    
    
    Intel PT is a separate PMU and it is not using any of the x86_pmu
    code paths, which means in particular that the active_events counter
    remains intact when new PT events are created.
    
    However, PT uses the generic x86_pmu PMI handler for its PMI handling needs.
    
    The problem here is that the latter checks active_events and in case of it
    being zero, exits without calling the actual x86_pmu.handle_nmi(), which
    results in unknown NMI errors and massive data loss for PT.
    
    The effect is not visible if there are other perf events in the system
    at the same time that keep active_events counter non-zero, for instance
    if the NMI watchdog is running, so one needs to disable it to reproduce
    the problem.
    
    At the same time, the active_events counter besides doing what the name
    suggests also implicitly serves as a PMC hardware and DS area reference
    counter.
    
    This patch adds a separate reference counter for the PMC hardware, leaving
    active_events for actually counting the events and makes sure it also
    counts PT and BTS events.
    
    Signed-off-by: default avatarAlexander Shishkin <alexander.shishkin@linux.intel.com>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Andy Lutomirski <luto@amacapital.net>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: Brian Gerst <brgerst@gmail.com>
    Cc: Denys Vlasenko <dvlasenk@redhat.com>
    Cc: H. Peter Anvin <hpa@zytor.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Oleg Nesterov <oleg@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: acme@infradead.org
    Cc: adrian.hunter@intel.com
    Link: http://lkml.kernel.org/r/87k2v92t0s.fsf@ashishki-desk.ger.corp.intel.com
    
    
    Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
    1b7b938f