linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: ShuoX Liu <shuox.liu@intel.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: Borislav Petkov <bp@alien8.de>,
	andi@firstfloor.org, Andrew Morton <akpm@linux-foundation.org>,
	Yanmin Zhang <yanmin_zhang@linux.intel.com>,
	Tony Luck <tony.luck@intel.com>, Ingo Molnar <mingo@elte.hu>
Subject: [PATCH v2] printk: ignore recursion_bug flag in HW error handle process
Date: Thu, 24 May 2012 13:59:38 +0800	[thread overview]
Message-ID: <4FBDCE4A.7050900@intel.com> (raw)
In-Reply-To: <20120523100138.GA13506@x1.osrc.amd.com>

From: ShuoX Liu <shuox.liu@intel.com>

When MCE happens in printk, we ignore recursion_bug to make sure MCE logs printed out.

According to Boris' suggestion, we add some helper functions.
1) hw_error_enter: Call it when specific arch begins to process a hardware error.
2) hw_error_exit: Call it when specific arch finishes the processing of a hardware error.
3) in_hw_error():indicates whether HW error handling is in processing.

Each arch could call the helpers in their arch-dependent HW error handlers.

Signed-off-by: Yanmin Zhang <yanmin_zhang@linux.intel.com>
Signed-off-by: ShuoX Liu <shuox.liu@intel.com>
---
 arch/x86/include/asm/mce.h       |    2 --
 arch/x86/kernel/cpu/mcheck/mce.c |    6 ++----
 include/linux/cpu.h              |   17 +++++++++++++++++
 kernel/cpu.c                     |    3 +++
 kernel/printk.c                  |    3 ++-
 5 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
index 441520e..aeda4cc 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -187,8 +187,6 @@ int mce_available(struct cpuinfo_x86 *c);
 DECLARE_PER_CPU(unsigned, mce_exception_count);
 DECLARE_PER_CPU(unsigned, mce_poll_count);
 
-extern atomic_t mce_entry;
-
 typedef DECLARE_BITMAP(mce_banks_t, MAX_NR_BANKS);
 DECLARE_PER_CPU(mce_banks_t, mce_poll_banks);
 
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 2afcbd2..aaf41d2 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -61,8 +61,6 @@ int mce_disabled __read_mostly;
 
 #define SPINUNIT 100	/* 100ns */
 
-atomic_t mce_entry;
-
 DEFINE_PER_CPU(unsigned, mce_exception_count);
 
 /*
@@ -1015,7 +1013,7 @@ void do_machine_check(struct pt_regs *regs, long error_code)
 	DECLARE_BITMAP(toclear, MAX_NR_BANKS);
 	char *msg = "Unknown";
 
-	atomic_inc(&mce_entry);
+	hw_error_enter();
 
 	this_cpu_inc(mce_exception_count);
 
@@ -1143,7 +1141,7 @@ void do_machine_check(struct pt_regs *regs, long error_code)
 		mce_report_event(regs);
 	mce_wrmsrl(MSR_IA32_MCG_STATUS, 0);
 out:
-	atomic_dec(&mce_entry);
+	hw_error_exit();
 	sync_core();
 }
 EXPORT_SYMBOL_GPL(do_machine_check);
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 7230bb5..beb56d0 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -210,4 +210,21 @@ static inline int disable_nonboot_cpus(void) { return 0; }
 static inline void enable_nonboot_cpus(void) {}
 #endif /* !CONFIG_PM_SLEEP_SMP */
 
+/* HW error handle status helpers */
+extern atomic_t hw_error;
+static inline void hw_error_enter(void)
+{
+	atomic_inc(&hw_error);
+}
+
+static inline void hw_error_exit(void)
+{
+	atomic_dec(&hw_error);
+}
+
+static inline int in_hw_error(void)
+{
+	return atomic_read(&hw_error);
+}
+
 #endif /* _LINUX_CPU_H_ */
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 0e6353c..54b9c1f 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -679,3 +679,6 @@ void init_cpu_online(const struct cpumask *src)
 {
 	cpumask_copy(to_cpumask(cpu_online_bits), src);
 }
+
+/* hardware error status */
+atomic_t hw_error __read_mostly = ATOMIC_INIT(0);
diff --git a/kernel/printk.c b/kernel/printk.c
index 32462d2..6f0f216 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -1295,7 +1295,8 @@ asmlinkage int vprintk_emit(int facility, int level,
 		 * recursion and return - but flag the recursion so that
 		 * it can be printed at the next appropriate moment:
 		 */
-		if (!oops_in_progress && !lockdep_recursing(current)) {
+		if (!oops_in_progress && !in_hw_error()
+				&& !lockdep_recursing(current)) {
 			recursion_bug = 1;
 			goto out_restore_irqs;
 		}
-- 
1.7.1

  parent reply	other threads:[~2012-05-24  6:01 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-23  1:58 [PATCH] printk: ignore recursion_bug flag when MCE in progress ShuoX Liu
2012-05-23 10:01 ` Borislav Petkov
2012-05-24  0:38   ` Yanmin Zhang
2012-05-24  5:59   ` ShuoX Liu [this message]
2012-05-24  6:11     ` [PATCH v2] printk: ignore recursion_bug flag in HW error handle process Borislav Petkov
2012-05-24 22:56       ` Andrew Morton
2012-05-25  0:30         ` Yanmin Zhang
2012-05-25  7:19           ` [PATCH 1/2] printk: add interface for disabling recursion check ShuoX Liu
2012-05-25  7:21             ` [PATCH 2/2] x86 mce: use new printk recursion disabling interface ShuoX Liu
2012-05-25  7:41               ` Borislav Petkov
2012-05-25  8:00                 ` ShuoX Liu
2012-05-28  2:07                 ` ShuoX Liu
2012-05-30  9:08                   ` Borislav Petkov
2012-05-31  0:30                     ` Yanmin Zhang
2012-06-04  3:04                     ` [PATCH v4 1/2] printk: add interface for disabling recursion check ShuoX Liu
2012-06-04  3:07                       ` [PATCH v4 2/2] x86 mce: use new printk recursion disabling interface ShuoX Liu
2012-06-22 23:41                         ` Andrew Morton
2012-06-26 20:45                           ` Borislav Petkov
2012-05-25 16:09             ` [PATCH 1/2] printk: add interface for disabling recursion check Luck, Tony
2012-05-28  0:30               ` Yanmin Zhang
2012-05-28  2:54                 ` [PATCH v3 " ShuoX Liu
2012-05-28  2:56                   ` [PATCH v3 2/2] x86 mce: use new printk recursion disabling interface ShuoX Liu
2012-06-04 17:12                     ` Borislav Petkov
2012-06-05  0:32                       ` Yanmin Zhang
2012-06-05  8:14                         ` Borislav Petkov
2012-06-05  9:53                           ` [PATCH v5 1/2] printk: add interface for disabling recursion check ShuoX Liu
2012-06-05  9:55                             ` [PATCH v5 2/2] x86 mce: use new printk recursion disabling interface ShuoX Liu
2012-06-05 15:15                               ` Borislav Petkov
2012-06-06  0:36                                 ` Yanmin Zhang
2012-06-06  8:31                                   ` [PATCH v6 1/2] printk: add interface for disabling recursion check ShuoX Liu
2012-06-06  8:34                                     ` [PATCH v6 2/2] x86 mce: use new printk recursion disabling interface ShuoX Liu
2012-06-06 15:22                                       ` Borislav Petkov
2012-06-07  2:13                                         ` Yanmin Zhang
2012-06-07  2:57                                         ` [PATCH v7 1/2] printk: add interface for disabling recursion check ShuoX Liu
2012-06-07  3:00                                           ` [PATCH v7 2/2] x86 mce: use new printk recursion disabling interface ShuoX Liu
2012-06-08 12:34                                             ` Borislav Petkov
2012-06-25  9:17                                             ` Ingo Molnar
2012-06-25 13:14                                               ` Peter Zijlstra
2012-06-26 20:43                                                 ` Borislav Petkov
2012-06-07 13:19                                           ` [PATCH v7 1/2] printk: add interface for disabling recursion check bing deng
2012-06-07 13:38                                             ` Borislav Petkov
2012-06-08 12:30                                           ` Borislav Petkov

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=4FBDCE4A.7050900@intel.com \
    --to=shuox.liu@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=bp@alien8.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tony.luck@intel.com \
    --cc=yanmin_zhang@linux.intel.com \
    /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).