提交 364de98e 编写于 作者: W Wei Li 提交者: Zheng Zengkai

watchdog: Fix sleeping function called from atomic context

hulk inclusion
category: bugfix
bugzilla: 173968, https://gitee.com/openeuler/kernel/issues/I3J87Y
CVE: NA

-------------------------------------------------

In '6ab91856 ("watchdog: Fix check_preemption_disabled() error")', we
tried to fix check_preemption_disabled() error by disabling preemption in
hardlockup_detector_perf_init(), but missed that function
perf_event_create_kernel_counter() may sleep.

To fix the issue fully, reimplement hardlockup_detector_perf_init()
through smp_call_on_cpu() instead of disabling preemption.

Fixes: 6ab91856 ("watchdog: Fix check_preemption_disabled() error")
Signed-off-by: NWei Li <liwei391@huawei.com>
Reviewed-by: NCheng Jian <cj.chengjian@huawei.com>
Reviewed-by: NXiongfeng Wang <wangxiongfeng2@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 c31c696f
...@@ -499,22 +499,25 @@ void __init hardlockup_detector_perf_restart(void) ...@@ -499,22 +499,25 @@ void __init hardlockup_detector_perf_restart(void)
} }
} }
/** int __init __hardlockup_detector_perf_init(void *not_used)
* hardlockup_detector_perf_init - Probe whether NMI event is available at all
*/
int __init hardlockup_detector_perf_init(void)
{ {
int ret; int ret = hardlockup_detector_event_create();
preempt_disable();
ret = hardlockup_detector_event_create();
if (ret) { if (ret) {
pr_info("Perf NMI watchdog permanently disabled\n"); pr_info("Perf NMI watchdog permanently disabled\n");
} else { } else {
perf_event_release_kernel(this_cpu_read(watchdog_ev)); perf_event_release_kernel(this_cpu_read(watchdog_ev));
this_cpu_write(watchdog_ev, NULL); this_cpu_write(watchdog_ev, NULL);
} }
preempt_enable();
return ret; return ret;
} }
/**
* hardlockup_detector_perf_init - Probe whether NMI event is available at all
*/
int __init hardlockup_detector_perf_init(void)
{
return smp_call_on_cpu(get_boot_cpu_id(),
__hardlockup_detector_perf_init, NULL, false);
}
#endif /* CONFIG_HARDLOCKUP_DETECTOR_PERF */ #endif /* CONFIG_HARDLOCKUP_DETECTOR_PERF */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册