From: Roger Pau Monne <roger.pau@citrix.com>
To: <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>, Wei Liu <wl@xen.org>,
Jan Beulich <jbeulich@suse.com>,
Roger Pau Monne <roger.pau@citrix.com>
Subject: [Xen-devel] [PATCH v3 1/5] x86: introduce a nmi_count tracking variable
Date: Mon, 24 Feb 2020 11:46:41 +0100 [thread overview]
Message-ID: <20200224104645.96381-2-roger.pau@citrix.com> (raw)
In-Reply-To: <20200224104645.96381-1-roger.pau@citrix.com>
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é <roger.pau@citrix.com>
---
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;
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/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 */
--
2.25.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2020-02-24 10:47 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-24 10:46 [Xen-devel] [PATCH v3 0/5] x86: fixes/improvements for scratch cpumask Roger Pau Monne
2020-02-24 10:46 ` Roger Pau Monne [this message]
2020-02-25 16:39 ` [Xen-devel] [PATCH v3 1/5] x86: introduce a nmi_count tracking variable Jan Beulich
2020-02-24 10:46 ` [Xen-devel] [PATCH v3 2/5] x86: track when in #NMI context Roger Pau Monne
2020-02-25 16:49 ` Jan Beulich
2020-02-25 16:51 ` Jan Beulich
2020-02-24 10:46 ` [Xen-devel] [PATCH v3 3/5] x86: track when in #MC context Roger Pau Monne
2020-02-25 17:06 ` Jan Beulich
2020-02-24 10:46 ` [Xen-devel] [PATCH v3 4/5] x86/smp: use a dedicated scratch cpumask in send_IPI_mask Roger Pau Monne
2020-02-26 10:07 ` Jan Beulich
2020-02-26 10:18 ` Roger Pau Monné
2020-02-26 10:45 ` Jan Beulich
2020-02-26 10:51 ` Roger Pau Monné
2020-02-24 10:46 ` [Xen-devel] [PATCH v3 5/5] x86: add accessors for scratch cpu mask Roger Pau Monne
2020-02-26 10:36 ` Jan Beulich
2020-02-27 17:54 ` Roger Pau Monné
2020-02-28 8:48 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200224104645.96381-2-roger.pau@citrix.com \
--to=roger.pau@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.