hulk inclusion category: bugfix bugzilla: 173968, https://gitee.com/openeuler/kernel/issues/I3J87Y CVE: NA
---------------------------
This reverts commit b2e484e966ac2f211f8f8cf56083e9bc4d5d3c6a.
When CONFIG_LOCKDEP and CONFIG_DEBUG_LOCKDEP are enabled, it detects the following error:
[ 10.145007] BUG: sleeping function called from invalid context at mm/slab.h:418 [ 10.145394] in_atomic(): 1, irqs_disabled(): 0, pid: 1, name: swapper/0 [ 10.145765] Preemption disabled at: [ 10.145978] [<ffff000008f8e7b4>] hardlockup_detector_perf_init+0x20/0x100 [ 10.146770] CPU: 6 PID: 1 Comm: swapper/0 Not tainted 4.19.90+ #3 [ 10.148242] Hardware name: linux,dummy-virt (DT) [ 10.148572] Call trace: [ 10.148667] dump_backtrace+0x0/0x190 [ 10.148765] show_stack+0x24/0x30 [ 10.148875] dump_stack+0xa4/0xf8 [ 10.148964] ___might_sleep+0x150/0x180 [ 10.149065] __might_sleep+0x58/0x90 [ 10.149199] kmem_cache_alloc_trace+0x244/0x2b0 [ 10.149308] perf_event_alloc+0x74/0x680 [ 10.149402] perf_event_create_kernel_counter+0x2c/0x190 [ 10.149516] arch_probe_cpu_freq+0x84/0x1ac [ 10.149611] hw_nmi_get_sample_period+0xb8/0x180 [ 10.149713] hardlockup_detector_event_create+0x28/0xfc [ 10.149827] hardlockup_detector_perf_init+0x24/0x100 [ 10.149943] watchdog_nmi_probe+0x14/0x1c [ 10.150037] lockup_detector_init+0x58/0x98 [ 10.150173] kernel_init_freeable+0x10c/0x1c4 [ 10.150298] kernel_init+0x18/0x110 [ 10.150422] ret_from_fork+0x10/0x18
In 'b2e484e966ac ("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.
The preemption is always disabled, the problem that wanted be fixed is not existed, so just revert this commit.
Fixes: b2e484e966ac ("watchdog: Fix check_preemption_disabled() error") Signed-off-by: Yang Yingliang yangyingliang@huawei.com Reviewed-by: Xiongfeng Wang wangxiongfeng2@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- kernel/watchdog_hld.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/kernel/watchdog_hld.c b/kernel/watchdog_hld.c index a5aff8ffa48ce..43832b1023693 100644 --- a/kernel/watchdog_hld.c +++ b/kernel/watchdog_hld.c @@ -508,17 +508,14 @@ void __init hardlockup_detector_perf_restart(void) */ int __init hardlockup_detector_perf_init(void) { - 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; } #endif /* CONFIG_HARDLOCKUP_DETECTOR_PERF */