Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752888Ab3DTTGd (ORCPT ); Sat, 20 Apr 2013 15:06:33 -0400 Received: from mga02.intel.com ([134.134.136.20]:28801 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751487Ab3DTTGb (ORCPT ); Sat, 20 Apr 2013 15:06:31 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.87,515,1363158000"; d="scan'208";a="321465033" From: Andi Kleen To: mingo@elte.hu Cc: linux-kernel@vger.kernel.org, Andi Kleen Subject: [PATCH 4/5] perf, x86: Move NMI clearing to end of PMI handler after the counter registers are reset Date: Sat, 20 Apr 2013 12:06:22 -0700 Message-Id: <1366484783-15613-5-git-send-email-andi@firstfloor.org> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1366484783-15613-1-git-send-email-andi@firstfloor.org> References: <1366484783-15613-1-git-send-email-andi@firstfloor.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1792 Lines: 57 From: Andi Kleen This avoids some problems with spurious PMIs on Haswell. Haswell seems to behave more like P4 in this regard. Do the same thing as the P4 perf handler by unmasking the NMI only at the end. Shouldn't make any difference for earlier family 6 cores. Tested on Haswell, IvyBridge, Westmere, Saltwell (Atom) Signed-off-by: Andi Kleen --- arch/x86/kernel/cpu/perf_event_intel.c | 16 ++++++---------- 1 files changed, 6 insertions(+), 10 deletions(-) diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c index 62b6872..4a78745 100644 --- a/arch/x86/kernel/cpu/perf_event_intel.c +++ b/arch/x86/kernel/cpu/perf_event_intel.c @@ -1172,16 +1172,6 @@ static int intel_pmu_handle_irq(struct pt_regs *regs) cpuc = &__get_cpu_var(cpu_hw_events); - /* - * Some chipsets need to unmask the LVTPC in a particular spot - * inside the nmi handler. As a result, the unmasking was pushed - * into all the nmi handlers. - * - * This handler doesn't seem to have any issues with the unmasking - * so it was left at the top. - */ - apic_write(APIC_LVTPC, APIC_DM_NMI); - intel_pmu_disable_all(); handled = intel_pmu_drain_bts_buffer(); status = intel_pmu_get_status(); @@ -1241,6 +1231,12 @@ again: done: intel_pmu_enable_all(0); + /* + * Only unmask the NMI after the overflow counters + * have been reset. This avoids spurious NMIs on + * Haswell CPUs. + */ + apic_write(APIC_LVTPC, APIC_DM_NMI); return handled; } -- 1.7.7.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/