From patchwork Mon Feb 17 18:43:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 11387191 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5E60E17F0 for ; Mon, 17 Feb 2020 18:45:00 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3A6AD222D9 for ; Mon, 17 Feb 2020 18:45:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="JWbJCZkT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3A6AD222D9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j3lMq-0000eb-Jf; Mon, 17 Feb 2020 18:43:40 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j3lMp-0000eT-94 for xen-devel@lists.xenproject.org; Mon, 17 Feb 2020 18:43:39 +0000 X-Inumbo-ID: 672916a2-51b5-11ea-8038-12813bfff9fa Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 672916a2-51b5-11ea-8038-12813bfff9fa; Mon, 17 Feb 2020 18:43:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1581965016; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zvSnCknfcw7YwjGcS2Fu6izRD7hCBJjuL0aQoYB/Cq0=; b=JWbJCZkTAoYjqxnx+iCBVXM2L8NMxO8ZwzCEXr2nWn4P5++bIS4tje56 iI8tbKDSvfayrQOG1wPiV+pxJRhQAXWrbc447izXE0BnVRwIIBTBZSYHn oRK4g1/zdzgP3ArfdDVPiDRlasoNwz4yaZEqFayr5gguXRZQmUGwy44MK 8=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=roger.pau@citrix.com; spf=Pass smtp.mailfrom=roger.pau@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of roger.pau@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.hc3370-68.iphmx.com: domain of roger.pau@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: yg13t0l5wLPmiFeYL3AQZb3ZEgw0q1lgLQjYqKL3aU/E5J0IoWpVEaP2ZNzYkmyewUozvcurf+ VzHTCsZf+9pFtKhgS30BcdKZxXI1kxRreChDXt1gg/AiamkC+XjPyAoDOQGtTsd5P7nkttU8nM TEvIrEWM0YM9tkvpV3wqlKDMJOWboAlLGdkeX0+38q3uYPG24NzNwlx76qIFovtftepMEa7jHV 0uTuoxVK/uxM3EtKxwbTLp+BmQP4t2rRBPLEonR+4HpjPKXmAc6oLv+B24QRHCYqVM2B/mW0G7 pXY= X-SBRS: 2.7 X-MesageID: 12569856 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,453,1574139600"; d="scan'208";a="12569856" From: Roger Pau Monne To: Date: Mon, 17 Feb 2020 19:43:20 +0100 Message-ID: <20200217184324.73762-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200217184324.73762-1-roger.pau@citrix.com> References: <20200217184324.73762-1-roger.pau@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 2/6] x86: introduce a nmi_count tracking variable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , Roger Pau Monne Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This is modeled after the irq_count variable, and is used to account for all the NMIs handled by the system. This will allow to repurpose the nmi_count() helper so it can be used in a similar manner as local_irq_count(): account for the NMIs currently in service. Signed-off-by: Roger Pau Monné --- xen/arch/x86/nmi.c | 11 +++++------ xen/arch/x86/traps.c | 4 +++- xen/include/asm-x86/nmi.h | 2 ++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/nmi.c b/xen/arch/x86/nmi.c index a5c6bdd0ce..e286ceeb40 100644 --- a/xen/arch/x86/nmi.c +++ b/xen/arch/x86/nmi.c @@ -151,15 +151,14 @@ int nmi_active; static void __init wait_for_nmis(void *p) { - unsigned int cpu = smp_processor_id(); - unsigned int start_count = nmi_count(cpu); + unsigned int start_count = this_cpu(nmi_count); 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 ) + if ( this_cpu(nmi_count) >= start_count + 2 ) break; e = rdtsc(); } while( e - s < ticks ); @@ -177,7 +176,7 @@ void __init check_nmi_watchdog(void) printk("Testing NMI watchdog on all CPUs:"); for_each_online_cpu ( cpu ) - prev_nmi_count[cpu] = nmi_count(cpu); + prev_nmi_count[cpu] = per_cpu(nmi_count, cpu); /* * Wait at most 10 ticks for 2 watchdog NMIs on each CPU. @@ -188,7 +187,7 @@ void __init check_nmi_watchdog(void) for_each_online_cpu ( cpu ) { - if ( nmi_count(cpu) - prev_nmi_count[cpu] < 2 ) + if ( per_cpu(nmi_count, cpu) - prev_nmi_count[cpu] < 2 ) { printk(" %d", cpu); ok = false; @@ -593,7 +592,7 @@ static void do_nmi_stats(unsigned char key) printk("CPU\tNMI\n"); for_each_online_cpu ( i ) - printk("%3d\t%3d\n", i, nmi_count(i)); + printk("%3d\t%3u\n", i, per_cpu(nmi_count, i)); if ( ((d = hardware_domain) == NULL) || (d->vcpu == NULL) || ((v = d->vcpu[0]) == NULL) ) diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 56067f85d1..3dbc66bb64 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -1683,13 +1683,15 @@ static int dummy_nmi_callback(const struct cpu_user_regs *regs, int cpu) static nmi_callback_t *nmi_callback = dummy_nmi_callback; +DEFINE_PER_CPU(unsigned int, nmi_count); + void do_nmi(const struct cpu_user_regs *regs) { unsigned int cpu = smp_processor_id(); unsigned char reason = 0; bool handle_unknown = false; - ++nmi_count(cpu); + this_cpu(nmi_count)++; if ( nmi_callback(regs, cpu) ) return; diff --git a/xen/include/asm-x86/nmi.h b/xen/include/asm-x86/nmi.h index f9dfca6afb..a288f02a50 100644 --- a/xen/include/asm-x86/nmi.h +++ b/xen/include/asm-x86/nmi.h @@ -31,5 +31,7 @@ nmi_callback_t *set_nmi_callback(nmi_callback_t *callback); * Remove the handler previously set. */ void unset_nmi_callback(void); + +DECLARE_PER_CPU(unsigned int, nmi_count); #endif /* ASM_NMI_H */