From nobody Mon Feb 9 03:13:05 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 ARC-Seal: i=1; a=rsa-sha256; t=1582541268; cv=none; d=zohomail.com; s=zohoarc; b=M6ORJWduRww4WMyIuLkrpznAcO7mhHbJmi59T+jvQ6E6ZzCc+frhwMWm4K7QpL+kQyaA3tQta/4mrikUt3rK6DVecfkX8e7Qwie3g0ZBzIz5OBlTw8/MfmWkeIFQM/9+PJxHPh7HMolVwAJnR8hhFfZxYYhyFcsuh0F8M3cRzEk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582541268; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=j6CpBZxPVVL43X1FPyTitBfDrrlhLikHieAW/BxOXVY=; b=bMDnIUypaLch1xu5atZg2VFOuFQOIJtHAewGTsEBlL9k56oK0DYuIdjuB4nxwt7pw4T3SQNLSdI6eL50CgI7Mps1unsnA1UiiUxhiiKazmEd3KZHskLERjELE9p3qjE8mEs1iZj+dS4S3ULr7/+kda4eIz0DWhBb81hXmdT4bJk= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 158254126870750.75940670670252; Mon, 24 Feb 2020 02:47:48 -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 1j6BGY-0004tV-J1; Mon, 24 Feb 2020 10:47:10 +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 1j6BGX-0004tO-E4 for xen-devel@lists.xenproject.org; Mon, 24 Feb 2020 10:47:09 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id fead051e-56f2-11ea-8ae3-12813bfff9fa; Mon, 24 Feb 2020 10:47:04 +0000 (UTC) X-Inumbo-ID: fead051e-56f2-11ea-8ae3-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1582541224; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EDk1YsLUMLWJVjWkclCXKphxOd2VjHLbCU+LUCWGXDM=; b=B/0jdhqfWbQjmlhBZVkAjNrqwR43aQ+BF/vftGMVuNg4yc0ncYX8EGcy jUayV58HClKYs8enaaLCTs9Pu+sIeSMhlDtSStyYGJDgMZ3sIGz5oinZX Zz/q9DAQr5VFuIXzbkk3ztpIlcOS4Bwtf5Utqt6yJk17eOxmaKpulmdg/ Q=; Authentication-Results: esa4.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 (esa4.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=esa4.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.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=esa4.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 (esa4.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=esa4.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: B5hLawbR4HB9Pr7f13fsNoWoltvdpm5NHqWqNLF8nNM2yVHxq1MXXdaGLgsKFLyWNEUxgQ/FsE KOpUi8Ay5Ram+pp+1b2xee9om5baeZbGN5nn09b/M+2mXw37nZhSYE0FsJTGrrMQSqN3Pjchsz hWHuigXOCpok5iPCibWaSGhQdSr7pe5XESjUNpoXCz5TmiH/Y5/abNSSrvPISN2duDt8lUDPjC TM/j7PImt6ZjB7vhHGblx4wcJyw+2vbBFm8c+Y89maed6vjmnBmFUhgBAraPMreqyoWKPqzPG4 aII= X-SBRS: 2.7 X-MesageID: 13524163 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,479,1574139600"; d="scan'208";a="13524163" From: Roger Pau Monne To: Date: Mon, 24 Feb 2020 11:46:41 +0100 Message-ID: <20200224104645.96381-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200224104645.96381-1-roger.pau@citrix.com> References: <20200224104645.96381-1-roger.pau@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 1/5] 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 a69b91a924..c3f92ed231 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 ( cpu ) - printk("%3u\t%3u\n", cpu, nmi_count(cpu)); + printk("%3u\t%3u\n", cpu, per_cpu(nmi_count, cpu)); =20 if ( !hardware_domain || !(v =3D domain_vcpu(hardware_domain, 0)) ) return; 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