Skip to content
Snippets Groups Projects
Commit cc66afea authored by Andi Kleen's avatar Andi Kleen Committed by Ingo Molnar
Browse files

x86/mce: Don't print MCEs when mcelog is active


Since:

  cd9c57ca ("x86/MCE: Dump MCE to dmesg if no consumers")

all MCEs are printed even when mcelog is running. Fix the regression to
not print to dmesg when mcelog is running as it is a consumer too.

Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
[ Massage commit message. ]
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: linux-edac <linux-edac@vger.kernel.org>
Cc: stable@vger.kernel.org # 4.10..
Fixes: cd9c57ca ("x86/MCE: Dump MCE to dmesg if no consumers")
Link: http://lkml.kernel.org/r/20170327093304.10683-2-bp@alien8.de


Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>

Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent ad0376eb
No related branches found
No related tags found
No related merge requests found
...@@ -54,6 +54,8 @@ ...@@ -54,6 +54,8 @@
static DEFINE_MUTEX(mce_chrdev_read_mutex); static DEFINE_MUTEX(mce_chrdev_read_mutex);
static int mce_chrdev_open_count; /* #times opened */
#define mce_log_get_idx_check(p) \ #define mce_log_get_idx_check(p) \
({ \ ({ \
RCU_LOCKDEP_WARN(!rcu_read_lock_sched_held() && \ RCU_LOCKDEP_WARN(!rcu_read_lock_sched_held() && \
...@@ -598,6 +600,10 @@ static int mce_default_notifier(struct notifier_block *nb, unsigned long val, ...@@ -598,6 +600,10 @@ static int mce_default_notifier(struct notifier_block *nb, unsigned long val,
if (atomic_read(&num_notifiers) > 2) if (atomic_read(&num_notifiers) > 2)
return NOTIFY_DONE; return NOTIFY_DONE;
/* Don't print when mcelog is running */
if (mce_chrdev_open_count > 0)
return NOTIFY_DONE;
__print_mce(m); __print_mce(m);
return NOTIFY_DONE; return NOTIFY_DONE;
...@@ -1828,7 +1834,6 @@ void mcheck_cpu_clear(struct cpuinfo_x86 *c) ...@@ -1828,7 +1834,6 @@ void mcheck_cpu_clear(struct cpuinfo_x86 *c)
*/ */
static DEFINE_SPINLOCK(mce_chrdev_state_lock); static DEFINE_SPINLOCK(mce_chrdev_state_lock);
static int mce_chrdev_open_count; /* #times opened */
static int mce_chrdev_open_exclu; /* already open exclusive? */ static int mce_chrdev_open_exclu; /* already open exclusive? */
static int mce_chrdev_open(struct inode *inode, struct file *file) static int mce_chrdev_open(struct inode *inode, struct file *file)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment