From nobody Mon Feb 9 15:11:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1581965070318710.4507687932315; Mon, 17 Feb 2020 10:44:30 -0800 (PST) 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 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) X-Inumbo-ID: 672916a2-51b5-11ea-8038-12813bfff9fa 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 (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9 --- 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; =20 static void __init wait_for_nmis(void *p) { - unsigned int cpu =3D smp_processor_id(); - unsigned int start_count =3D nmi_count(cpu); + unsigned int start_count =3D this_cpu(nmi_count); unsigned long ticks =3D 10 * 1000 * cpu_khz / nmi_hz; unsigned long s, e; =20 s =3D rdtsc(); do { cpu_relax(); - if ( nmi_count(cpu) >=3D start_count + 2 ) + if ( this_cpu(nmi_count) >=3D start_count + 2 ) break; e =3D rdtsc(); } while( e - s < ticks ); @@ -177,7 +176,7 @@ void __init check_nmi_watchdog(void) printk("Testing NMI watchdog on all CPUs:"); =20 for_each_online_cpu ( cpu ) - prev_nmi_count[cpu] =3D nmi_count(cpu); + prev_nmi_count[cpu] =3D per_cpu(nmi_count, cpu); =20 /* * Wait at most 10 ticks for 2 watchdog NMIs on each CPU. @@ -188,7 +187,7 @@ void __init check_nmi_watchdog(void) =20 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 =3D false; @@ -593,7 +592,7 @@ static void do_nmi_stats(unsigned char key) =20 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)); =20 if ( ((d =3D hardware_domain) =3D=3D NULL) || (d->vcpu =3D=3D NULL) || ((v =3D d->vcpu[0]) =3D=3D 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) =20 static nmi_callback_t *nmi_callback =3D dummy_nmi_callback; =20 +DEFINE_PER_CPU(unsigned int, nmi_count); + void do_nmi(const struct cpu_user_regs *regs) { unsigned int cpu =3D smp_processor_id(); unsigned char reason =3D 0; bool handle_unknown =3D false; =20 - ++nmi_count(cpu); + this_cpu(nmi_count)++; =20 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); =20 #endif /* ASM_NMI_H */ --=20 2.25.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel