提交 8457c84d 编写于 作者: A Andi Kleen 提交者: H. Peter Anvin

x86, mce: replace machine check events logged interval with ratelimit

Impact: behavior change, use common code

Use a standard leaky bucket ratelimit for the machine check
warning print interval instead of waiting every check_interval.
Also decrease the limit to twice per minute.
This interacts better with threshold interrupts because
they can happen more often than check_interval.
Signed-off-by: NAndi Kleen <ak@linux.intel.com>
Signed-off-by: NH. Peter Anvin <hpa@zytor.com>
上级 f9695df4
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/kdebug.h> #include <linux/kdebug.h>
#include <linux/kobject.h> #include <linux/kobject.h>
#include <linux/sysfs.h> #include <linux/sysfs.h>
#include <linux/ratelimit.h>
#include <asm/processor.h> #include <asm/processor.h>
#include <asm/msr.h> #include <asm/msr.h>
#include <asm/mce.h> #include <asm/mce.h>
...@@ -488,11 +489,11 @@ static DECLARE_WORK(mce_trigger_work, mce_do_trigger); ...@@ -488,11 +489,11 @@ static DECLARE_WORK(mce_trigger_work, mce_do_trigger);
*/ */
int mce_notify_user(void) int mce_notify_user(void)
{ {
/* Not more than two messages every minute */
static DEFINE_RATELIMIT_STATE(ratelimit, 60*HZ, 2);
clear_thread_flag(TIF_MCE_NOTIFY); clear_thread_flag(TIF_MCE_NOTIFY);
if (test_and_clear_bit(0, &notify_user)) { if (test_and_clear_bit(0, &notify_user)) {
static unsigned long last_print;
unsigned long now = jiffies;
wake_up_interruptible(&mce_wait); wake_up_interruptible(&mce_wait);
/* /*
...@@ -503,10 +504,8 @@ int mce_notify_user(void) ...@@ -503,10 +504,8 @@ int mce_notify_user(void)
if (trigger[0] && !work_pending(&mce_trigger_work)) if (trigger[0] && !work_pending(&mce_trigger_work))
schedule_work(&mce_trigger_work); schedule_work(&mce_trigger_work);
if (time_after_eq(now, last_print + (check_interval*HZ))) { if (__ratelimit(&ratelimit))
last_print = now;
printk(KERN_INFO "Machine check events logged\n"); printk(KERN_INFO "Machine check events logged\n");
}
return 1; return 1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册