From patchwork Wed Feb 26 12:19:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roger Pau Monne X-Patchwork-Id: 11406373 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 71E4E92A for ; Wed, 26 Feb 2020 12:21:08 +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 4B1BF2084E for ; Wed, 26 Feb 2020 12:21:08 +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="epxwsUlc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4B1BF2084E 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 1j6vfX-0007iB-S2; Wed, 26 Feb 2020 12:20:03 +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 1j6vfW-0007a7-Ni for xen-devel@lists.xenproject.org; Wed, 26 Feb 2020 12:20:02 +0000 X-Inumbo-ID: 4f96bcb8-5892-11ea-9405-12813bfff9fa Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 4f96bcb8-5892-11ea-9405-12813bfff9fa; Wed, 26 Feb 2020 12:20:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1582719601; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wv/vxk0u0VbbLGUWa/SXKuvSSwAq6bOO4pDv/657Jok=; b=epxwsUlcsvlpxhAMce7eMT8mbwgp1uXmT9epXA80PvDe1gYbBEsue391 +Jr87OXVxuzzjvxLHNAyv7Yzi3uftkYkn7aZovedxqDVNOKvwZoOvtfJZ ynv5rRnB+56mETDyov3ShrYWliniHzm0XDHcRdlGXuF8Ek590oKZ2ocjb o=; Authentication-Results: esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.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=esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: Hdx9BAEX+6189xWIiTtwXHjOb7dSV/S3JvLXHOB0OxW/VZNSGQgv1pTbS/PXLBr0a08Al7pKlS lsgkZpfYxCWtVjkoEaFzeOg++vOOOmrdHR6OGpl+iD2LSiIEq2pKTKlefcfame1K0xIK0RelDD S6DKtXh8aOxm6vtoQLT4IiRY2m4NvHoC6e62HOjN9/gT51zaq5DaSAl5kZ50ty2CcK5yX9QWA0 oNaz1M9gXWCX7Pifmxubd0CtRkHiVubedO2exmFropfY+lUdXr4K96cRwsR49+EYxngvhZTyPd 9zU= X-SBRS: 2.7 X-MesageID: 13386968 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,488,1574139600"; d="scan'208";a="13386968" From: Roger Pau Monne To: Date: Wed, 26 Feb 2020 13:19:18 +0100 Message-ID: <20200226121921.28627-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200226121921.28627-1-roger.pau@citrix.com> References: <20200226121921.28627-1-roger.pau@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 1/4] 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: Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , Andrew Cooper , Ian Jackson , George Dunlap , 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é Reviewed-by: Jan Beulich --- Changes since v3: - Remove nmi_count macro and __nmi_count field in irq_cpustat_t. --- xen/arch/x86/nmi.c | 11 +++++------ xen/arch/x86/traps.c | 4 +++- xen/include/asm-x86/hardirq.h | 1 - xen/include/asm-x86/nmi.h | 2 ++ xen/include/xen/irq_cpustat.h | 1 - 5 files changed, 10 insertions(+), 9 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; 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 ( cpu ) - printk("%3u\t%3u\n", cpu, nmi_count(cpu)); + printk("%3u\t%3u\n", cpu, per_cpu(nmi_count, cpu)); if ( !hardware_domain || !(v = 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) 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/hardirq.h b/xen/include/asm-x86/hardirq.h index 34e1b49260..802f91cfdf 100644 --- a/xen/include/asm-x86/hardirq.h +++ b/xen/include/asm-x86/hardirq.h @@ -7,7 +7,6 @@ typedef struct { unsigned int __softirq_pending; unsigned int __local_irq_count; - unsigned int __nmi_count; bool_t __mwait_wakeup; } __cacheline_aligned irq_cpustat_t; 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 */ diff --git a/xen/include/xen/irq_cpustat.h b/xen/include/xen/irq_cpustat.h index 73629f6ec8..b9629f25c2 100644 --- a/xen/include/xen/irq_cpustat.h +++ b/xen/include/xen/irq_cpustat.h @@ -24,7 +24,6 @@ extern irq_cpustat_t irq_stat[]; /* arch independent irq_stat fields */ #define softirq_pending(cpu) __IRQ_STAT((cpu), __softirq_pending) #define local_irq_count(cpu) __IRQ_STAT((cpu), __local_irq_count) -#define nmi_count(cpu) __IRQ_STAT((cpu), __nmi_count) #define mwait_wakeup(cpu) __IRQ_STAT((cpu), __mwait_wakeup) #endif /* __irq_cpustat_h */