From: Cyrill Gorcunov <gorcunov@gmail.com>
To: mingo@elte.hu, tglx@linutronix.de, hpa@zytor.com, macro@linux-mips.org
Cc: Cyrill Gorcunov <gorcunov@gmail.com>, linux-kernel@vger.kernel.org
Subject: [patch 5/5] x86: nmi_watchdog - introduce nmi_watchdog_active() helper
Date: Thu, 01 Jan 1970 03:00:05 +0300 [thread overview]
Message-ID: <48611ec5.2435440a.32c4.1a96@mx.google.com> (raw)
In-Reply-To: 20080624161624.124913675@gmail.com
[-- Attachment #1: nmi-watchdog-active --]
[-- Type: text/plain, Size: 2325 bytes --]
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
Index: linux-2.6.git/include/asm-x86/nmi.h
====================================================================
--- linux-2.6.git.orig/include/asm-x86/nmi.h 2008-06-24 19:32:44.000000000 +0400
+++ linux-2.6.git/include/asm-x86/nmi.h 2008-06-24 19:45:13.000000000 +0400
@@ -56,6 +56,19 @@ static inline void localise_nmi_watchdog
if (nmi_watchdog == NMI_IO_APIC)
nmi_watchdog = NMI_LOCAL_APIC;
}
+
+/* check if nmi_watchdog is active (ie was specified at boot) */
+static inline int nmi_watchdog_active(void)
+{
+ /*
+ * actually it should be:
+ * return (nmi_watchdog == NMI_LOCAL_APIC ||
+ * nmi_watchdog == NMI_IO_APIC)
+ * but since they are power of two we could use a
+ * cheaper way --cvg
+ */
+ return nmi_watchdog & 0x3;
+}
#endif
void lapic_watchdog_stop(void);
Index: linux-2.6.git/arch/x86/kernel/nmi.c
====================================================================
--- linux-2.6.git.orig/arch/x86/kernel/nmi.c 2008-06-24 19:32:09.000000000 +0400
+++ linux-2.6.git/arch/x86/kernel/nmi.c 2008-06-24 19:34:16.000000000 +0400
@@ -116,10 +116,7 @@ int __init check_nmi_watchdog(void)
unsigned int *prev_nmi_count;
int cpu;
- if (nmi_watchdog == NMI_NONE)
- return 0;
-
- if (!atomic_read(&nmi_active))
+ if (!nmi_watchdog_active() || !atomic_read(&nmi_active))
return 0;
prev_nmi_count = kmalloc(nr_cpu_ids * sizeof(int), GFP_KERNEL);
@@ -316,8 +313,7 @@ void setup_apic_nmi_watchdog(void *unuse
void stop_apic_nmi_watchdog(void *unused)
{
/* only support LOCAL and IO APICs for now */
- if (nmi_watchdog != NMI_LOCAL_APIC &&
- nmi_watchdog != NMI_IO_APIC)
+ if (!nmi_watchdog_active())
return;
if (__get_cpu_var(wd_enabled) == 0)
return;
@@ -347,8 +343,7 @@ static DEFINE_PER_CPU(int, nmi_touch);
void touch_nmi_watchdog(void)
{
- if (nmi_watchdog == NMI_LOCAL_APIC ||
- nmi_watchdog == NMI_IO_APIC) {
+ if (nmi_watchdog_active()) {
unsigned cpu;
/*
@@ -473,7 +468,7 @@ int proc_nmi_enabled(struct ctl_table *t
if (!!old_state == !!nmi_watchdog_enabled)
return 0;
- if (atomic_read(&nmi_active) < 0 || nmi_watchdog == NMI_NONE) {
+ if (atomic_read(&nmi_active) < 0 || !nmi_watchdog_active()) {
printk(KERN_WARNING
"NMI watchdog is permanently disabled\n");
return -EIO;
--
prev parent reply other threads:[~2008-06-24 16:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20080624161624.124913675@gmail.com>
1970-01-01 0:00 ` [patch 1/5] x86: perfctr-watchdog.c - coding style cleanup Cyrill Gorcunov
2008-06-24 16:36 ` Ingo Molnar
2008-06-24 16:45 ` Cyrill Gorcunov
2008-06-24 20:43 ` Ingo Molnar
2008-06-25 3:18 ` Cyrill Gorcunov
1970-01-01 0:00 ` [patch 2/5] x86: nmi_watchdog - use nmi_watchdog variable for printing Cyrill Gorcunov
1970-01-01 0:00 ` [patch 3/5] x86: nmi_watchdog - remove useless check Cyrill Gorcunov
1970-01-01 0:00 ` [patch 4/5] x86: nmi_watchdog - use NMI_NONE by default Cyrill Gorcunov
1970-01-01 0:00 ` Cyrill Gorcunov [this message]
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=48611ec5.2435440a.32c4.1a96@mx.google.com \
--to=gorcunov@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=macro@linux-mips.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
/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).