From: David Vrabel <david.vrabel@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
David Vrabel <david.vrabel@citrix.com>,
Jan Beulich <jbeulich@suse.com>
Subject: [PATCHv2] x86: only check for two watchdog NMIs
Date: Mon, 1 Feb 2016 17:09:52 +0000 [thread overview]
Message-ID: <1454346592-27067-1-git-send-email-david.vrabel@citrix.com> (raw)
Since the NMI handler can now recognize watchdog NMIs, make
check_nmi_watchdog() only check for at least two watchdog NMIs. This
prevents false negatives caused by other processors (which may be
being power managed by the BIOS) running at reduced clock frequencies.
We check for more than one NMI since there are apparently systems
where the NMI works only once.
This will also slightly speed up boot times since we only wait the
full 10 ticks if the NMI watchdog on one or more CPUs is not working.
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
---
v2:
- Check for two watchdog NMIs.
---
xen/arch/x86/nmi.c | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/xen/arch/x86/nmi.c b/xen/arch/x86/nmi.c
index b1195a1..426c24e 100644
--- a/xen/arch/x86/nmi.c
+++ b/xen/arch/x86/nmi.c
@@ -139,7 +139,18 @@ int nmi_active;
static void __init wait_for_nmis(void *p)
{
- mdelay((10*1000)/nmi_hz); /* wait 10 ticks */
+ unsigned int cpu = smp_processor_id();
+ unsigned int start_count = nmi_count(cpu);
+ 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 )
+ break;
+ e = rdtsc();
+ } while( e - s < ticks );
}
int __init check_nmi_watchdog (void)
@@ -156,15 +167,16 @@ int __init check_nmi_watchdog (void)
for_each_online_cpu ( cpu )
prev_nmi_count[cpu] = nmi_count(cpu);
- /* Wait for 10 ticks. Busy-wait on all CPUs: the LAPIC counter that
- * the NMI watchdog uses only runs while the core's not halted */
- if ( nmi_watchdog == NMI_LOCAL_APIC )
- smp_call_function(wait_for_nmis, NULL, 0);
- wait_for_nmis(NULL);
+ /*
+ * Wait at most 10 ticks for 2 watchdog NMIs on each CPU.
+ * Busy-wait on all CPUs: the LAPIC counter that the NMI watchdog
+ * uses only runs while the core's not halted
+ */
+ on_selected_cpus(&cpu_online_map, wait_for_nmis, NULL, 1);
for_each_online_cpu ( cpu )
{
- if ( nmi_count(cpu) - prev_nmi_count[cpu] <= 5 )
+ if ( nmi_count(cpu) - prev_nmi_count[cpu] < 2 )
{
printk(" %d", cpu);
ok = 0;
--
2.1.4
next reply other threads:[~2016-02-01 17:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-01 17:09 David Vrabel [this message]
2016-02-01 17:33 ` [PATCHv2] x86: only check for two watchdog NMIs Andrew Cooper
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=1454346592-27067-1-git-send-email-david.vrabel@citrix.com \
--to=david.vrabel@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).