From: Xu Qiang xuqiang36@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I7WQWT CVE: NA
--------------------------------
A user-mode interface is added to control the core lockup detection sensitivity.
Signed-off-by: Xu Qiang xuqiang36@huawei.com Reviewed-by: Ding Tianhong dingtianhong@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com Reviewed-by: Ding Tianhong dingtianhong@huawei.com Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com Conflicts: kernel/sysctl.c Signed-off-by: Li Huafei lihuafei1@huawei.com --- include/linux/nmi.h | 1 + kernel/watchdog.c | 14 ++++++++++++++ kernel/watchdog_hld.c | 4 +++- 3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/include/linux/nmi.h b/include/linux/nmi.h index b3229c437264..e14216d1d5aa 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -132,6 +132,7 @@ extern void corelockup_detector_offline_cpu(unsigned int cpu); extern void watchdog_check_hrtimer(void); extern unsigned long watchdog_hrtimer_interrupts(unsigned int cpu); extern bool enable_corelockup_detector; +extern int corelockup_miss_thresh; #endif
void watchdog_nmi_stop(void); diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 4ef8c343c442..73d5eb55b112 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -778,6 +778,9 @@ int proc_watchdog_cpumask(struct ctl_table *table, int write, }
static const int sixty = 60; +#ifdef CONFIG_HARDLOCKUP_DETECTOR +static const int five = 5; +#endif
static struct ctl_table watchdog_sysctls[] = { { @@ -866,6 +869,17 @@ static struct ctl_table watchdog_sysctls[] = { .extra2 = SYSCTL_ONE, }, #endif /* CONFIG_SMP */ +#ifdef CONFIG_CORELOCKUP_DETECTOR + { + .procname = "corelockup_thresh", + .data = &corelockup_miss_thresh, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_THREE, + .extra2 = (void *)&five, + }, +#endif #endif {} }; diff --git a/kernel/watchdog_hld.c b/kernel/watchdog_hld.c index 392837224ec1..48b815afb946 100644 --- a/kernel/watchdog_hld.c +++ b/kernel/watchdog_hld.c @@ -83,6 +83,7 @@ static DEFINE_PER_CPU(unsigned long, hrint_saved); static DEFINE_PER_CPU(unsigned long, hrint_missed); static unsigned long corelockup_allcpu_dumped; bool enable_corelockup_detector; +int __read_mostly corelockup_miss_thresh = 5;
static int __init enable_corelockup_detector_setup(char *str) { @@ -169,7 +170,8 @@ void watchdog_check_hrtimer(void) } __this_cpu_inc(nmi_cnt_missed);
- if ((__this_cpu_read(hrint_missed) > 5) && (__this_cpu_read(nmi_cnt_missed) > 5)) { + if ((__this_cpu_read(hrint_missed) > corelockup_miss_thresh) + && (__this_cpu_read(nmi_cnt_missed) > corelockup_miss_thresh)) { pr_emerg("Watchdog detected core LOCKUP on cpu %d\n", cpu);
if (!test_and_set_bit(0, &corelockup_allcpu_dumped)) {