RE: [外部邮件] Re: [????] Re: [PATCH][RFC] hung_task: Support to panic when the maximum number of hung task warnings is reached

Li,Rongqing posted 1 patch 1 week, 1 day ago
RE: [外部邮件] Re: [????] Re: [PATCH][RFC] hung_task: Support to panic when the maximum number of hung task warnings is reached
Posted by Li,Rongqing 1 week, 1 day ago
> There are the panic_on_rcu_stall and max_rcu_stall_to_panic sysctls, which
> together allow you to panic after (say) three RCU CPU stall warnings.
> Does those do what you need?
> 
> 							Thanx, Paul
> 


inspired by dfe564045c653d "(rcu: Panic after fixed number of stalls)", add a new knod for hung task, how about?


diff --git a/kernel/hung_task.c b/kernel/hung_task.c
index 8708a12..b93592d 100644
--- a/kernel/hung_task.c
+++ b/kernel/hung_task.c
@@ -83,6 +83,8 @@ static unsigned int __read_mostly sysctl_hung_task_all_cpu_backtrace;
 static unsigned int __read_mostly sysctl_hung_task_panic =
        IS_ENABLED(CONFIG_BOOTPARAM_HUNG_TASK_PANIC);

+static unsigned int __read_mostly sysctl_hung_task_panic_count;
+
 static int
 hung_task_panic(struct notifier_block *this, unsigned long event, void *ptr)
 {
@@ -219,7 +221,9 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)

        trace_sched_process_hang(t);

-       if (sysctl_hung_task_panic) {
+       if (sysctl_hung_task_panic ||
+               (sysctl_hung_task_panic_count &&
+                (sysctl_hung_task_detect_count > sysctl_hung_task_panic_count))) {
                console_verbose();
                hung_task_show_lock = true;
                hung_task_call_panic = true;
@@ -388,6 +392,14 @@ static const struct ctl_table hung_task_sysctls[] = {
                .extra2         = SYSCTL_ONE,
        },
        {
+               .procname       = "hung_task_panic_count",
+               .data           = &sysctl_hung_task_panic_count,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = proc_dointvec_minmax,
+               .extra1         = SYSCTL_ZERO,
+       },
+       {
                .procname       = "hung_task_check_count",
                .data           = &sysctl_hung_task_check_count,
                .maxlen         = sizeof(int),