Commit 9aaef96f authored by Hidetoshi Seto's avatar Hidetoshi Seto Committed by Borislav Petkov

x86, mce: Do not call del_timer_sync() in IRQ context

del_timer_sync() can cause a deadlock when called in interrupt context.
It is used with on_each_cpu() in some parts for sysfs files like bank*,
check_interval, cmci_disabled and ignore_ce.

However, use of on_each_cpu() results in calling the function passed
as the argument in interrupt context. This causes a flood of nested
warnings from del_timer_sync() (it runs on each CPU) caused even by a
simple file access like:

$ echo 300 > /sys/devices/system/machinecheck/machinecheck0/check_interval

Fortunately, these MCE-specific files are rarely used and AFAIK only few
MCE geeks experience this warning.

To remove the warning, move timer deletion outside of the interrupt
context.
Signed-off-by: default avatarHidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Signed-off-by: default avatarBorislav Petkov <borislav.petkov@amd.com>
parent b6fd41e2
...@@ -1140,6 +1140,15 @@ static void mce_start_timer(unsigned long data) ...@@ -1140,6 +1140,15 @@ static void mce_start_timer(unsigned long data)
add_timer_on(t, smp_processor_id()); add_timer_on(t, smp_processor_id());
} }
/* Must not be called in IRQ context where del_timer_sync() can deadlock */
static void mce_timer_delete_all(void)
{
int cpu;
for_each_online_cpu(cpu)
del_timer_sync(&per_cpu(mce_timer, cpu));
}
static void mce_do_trigger(struct work_struct *work) static void mce_do_trigger(struct work_struct *work)
{ {
call_usermodehelper(mce_helper, mce_helper_argv, NULL, UMH_NO_WAIT); call_usermodehelper(mce_helper, mce_helper_argv, NULL, UMH_NO_WAIT);
...@@ -1750,7 +1759,6 @@ static struct syscore_ops mce_syscore_ops = { ...@@ -1750,7 +1759,6 @@ static struct syscore_ops mce_syscore_ops = {
static void mce_cpu_restart(void *data) static void mce_cpu_restart(void *data)
{ {
del_timer_sync(&__get_cpu_var(mce_timer));
if (!mce_available(__this_cpu_ptr(&cpu_info))) if (!mce_available(__this_cpu_ptr(&cpu_info)))
return; return;
__mcheck_cpu_init_generic(); __mcheck_cpu_init_generic();
...@@ -1760,16 +1768,15 @@ static void mce_cpu_restart(void *data) ...@@ -1760,16 +1768,15 @@ static void mce_cpu_restart(void *data)
/* Reinit MCEs after user configuration changes */ /* Reinit MCEs after user configuration changes */
static void mce_restart(void) static void mce_restart(void)
{ {
mce_timer_delete_all();
on_each_cpu(mce_cpu_restart, NULL, 1); on_each_cpu(mce_cpu_restart, NULL, 1);
} }
/* Toggle features for corrected errors */ /* Toggle features for corrected errors */
static void mce_disable_ce(void *all) static void mce_disable_cmci(void *data)
{ {
if (!mce_available(__this_cpu_ptr(&cpu_info))) if (!mce_available(__this_cpu_ptr(&cpu_info)))
return; return;
if (all)
del_timer_sync(&__get_cpu_var(mce_timer));
cmci_clear(); cmci_clear();
} }
...@@ -1852,7 +1859,8 @@ static ssize_t set_ignore_ce(struct sys_device *s, ...@@ -1852,7 +1859,8 @@ static ssize_t set_ignore_ce(struct sys_device *s,
if (mce_ignore_ce ^ !!new) { if (mce_ignore_ce ^ !!new) {
if (new) { if (new) {
/* disable ce features */ /* disable ce features */
on_each_cpu(mce_disable_ce, (void *)1, 1); mce_timer_delete_all();
on_each_cpu(mce_disable_cmci, NULL, 1);
mce_ignore_ce = 1; mce_ignore_ce = 1;
} else { } else {
/* enable ce features */ /* enable ce features */
...@@ -1875,7 +1883,7 @@ static ssize_t set_cmci_disabled(struct sys_device *s, ...@@ -1875,7 +1883,7 @@ static ssize_t set_cmci_disabled(struct sys_device *s,
if (mce_cmci_disabled ^ !!new) { if (mce_cmci_disabled ^ !!new) {
if (new) { if (new) {
/* disable cmci */ /* disable cmci */
on_each_cpu(mce_disable_ce, NULL, 1); on_each_cpu(mce_disable_cmci, NULL, 1);
mce_cmci_disabled = 1; mce_cmci_disabled = 1;
} else { } else {
/* enable cmci */ /* enable cmci */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment