From: Wei Li liwei391@huawei.com
hulk inclusion category: bugfix bugzilla: 173968, https://gitee.com/openeuler/kernel/issues/I3J87Y CVE: NA
-------------------------------------------------
In '6ab918569ad4 ("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: 6ab918569ad4 ("watchdog: Fix check_preemption_disabled() error") Signed-off-by: Wei Li liwei391@huawei.com Reviewed-by: Cheng Jian cj.chengjian@huawei.com Reviewed-by: Xiongfeng Wang wangxiongfeng2@huawei.com Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com --- kernel/watchdog_hld.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/kernel/watchdog_hld.c b/kernel/watchdog_hld.c index f535ddd76315..b8a2d3b2cd9c 100644 --- a/kernel/watchdog_hld.c +++ b/kernel/watchdog_hld.c @@ -499,22 +499,25 @@ void __init hardlockup_detector_perf_restart(void) } }
-/** - * hardlockup_detector_perf_init - Probe whether NMI event is available at all - */ -int __init hardlockup_detector_perf_init(void) +int __init __hardlockup_detector_perf_init(void *not_used) { - int ret; + int ret = hardlockup_detector_event_create();
- preempt_disable(); - ret = hardlockup_detector_event_create(); if (ret) { pr_info("Perf NMI watchdog permanently disabled\n"); } else { perf_event_release_kernel(this_cpu_read(watchdog_ev)); this_cpu_write(watchdog_ev, NULL); } - preempt_enable(); 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 */