From patchwork Mon Feb 1 17:09:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Vrabel X-Patchwork-Id: 8181501 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 30DC89F38B for ; Mon, 1 Feb 2016 17:12:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 54FA42039C for ; Mon, 1 Feb 2016 17:12:37 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7846C20306 for ; Mon, 1 Feb 2016 17:12:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aQHzG-0004om-QQ; Mon, 01 Feb 2016 17:10:02 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aQHzF-0004nz-Bi for xen-devel@lists.xenproject.org; Mon, 01 Feb 2016 17:10:01 +0000 Received: from [85.158.139.211] by server-2.bemta-5.messagelabs.com id E4/9A-21594-8619FA65; Mon, 01 Feb 2016 17:10:00 +0000 X-Env-Sender: prvs=832a900a8=david.vrabel@citrix.com X-Msg-Ref: server-4.tower-206.messagelabs.com!1454346598!19558419!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 56960 invoked from network); 1 Feb 2016 17:09:59 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-4.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 1 Feb 2016 17:09:59 -0000 X-IronPort-AV: E=Sophos;i="5.22,381,1449532800"; d="scan'208";a="335323901" From: David Vrabel To: Date: Mon, 1 Feb 2016 17:09:52 +0000 Message-ID: <1454346592-27067-1-git-send-email-david.vrabel@citrix.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 X-DLP: MIA1 Cc: Andrew Cooper , David Vrabel , Jan Beulich Subject: [Xen-devel] [PATCHv2] x86: only check for two watchdog NMIs X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since the NMI handler can now recognize watchdog NMIs, make check_nmi_watchdog() only check for at least two watchdog NMIs. This prevents false negatives caused by other processors (which may be being power managed by the BIOS) running at reduced clock frequencies. We check for more than one NMI since there are apparently systems where the NMI works only once. This will also slightly speed up boot times since we only wait the full 10 ticks if the NMI watchdog on one or more CPUs is not working. Signed-off-by: David Vrabel Reviewed-by: Andrew Cooper --- v2: - Check for two watchdog NMIs. --- xen/arch/x86/nmi.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/nmi.c b/xen/arch/x86/nmi.c index b1195a1..426c24e 100644 --- a/xen/arch/x86/nmi.c +++ b/xen/arch/x86/nmi.c @@ -139,7 +139,18 @@ int nmi_active; static void __init wait_for_nmis(void *p) { - mdelay((10*1000)/nmi_hz); /* wait 10 ticks */ + unsigned int cpu = smp_processor_id(); + unsigned int start_count = nmi_count(cpu); + unsigned long ticks = 10 * 1000 * cpu_khz / nmi_hz; + unsigned long s, e; + + s = rdtsc(); + do { + cpu_relax(); + if ( nmi_count(cpu) >= start_count + 2 ) + break; + e = rdtsc(); + } while( e - s < ticks ); } int __init check_nmi_watchdog (void) @@ -156,15 +167,16 @@ int __init check_nmi_watchdog (void) for_each_online_cpu ( cpu ) prev_nmi_count[cpu] = nmi_count(cpu); - /* Wait for 10 ticks. Busy-wait on all CPUs: the LAPIC counter that - * the NMI watchdog uses only runs while the core's not halted */ - if ( nmi_watchdog == NMI_LOCAL_APIC ) - smp_call_function(wait_for_nmis, NULL, 0); - wait_for_nmis(NULL); + /* + * Wait at most 10 ticks for 2 watchdog NMIs on each CPU. + * Busy-wait on all CPUs: the LAPIC counter that the NMI watchdog + * uses only runs while the core's not halted + */ + on_selected_cpus(&cpu_online_map, wait_for_nmis, NULL, 1); for_each_online_cpu ( cpu ) { - if ( nmi_count(cpu) - prev_nmi_count[cpu] <= 5 ) + if ( nmi_count(cpu) - prev_nmi_count[cpu] < 2 ) { printk(" %d", cpu); ok = 0;