Previously hung_task_panic would not be respected if enabled after hung_task_warnings had already been decremented to 0. Permit the kernel to panic if hung_task_panic is enabled after hung_task_warnings has already been decremented to 0 and another task hangs for hung_task_timeout_secs seconds. Check if hung_task_panic is enabled so we don't return prematurely, and check if hung_task_warnings is non-zero so we don't print the warning unnecessarily. [akpm@linux-foundation.org: fix off-by-one] Link: http://lkml.kernel.org/r/1473450214-4049-1-git-send-email-jsiddle@redhat.com Signed-off-by: John Siddle <jsiddle@redhat.com> Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Unified · Split
| @@ -98,26 +98,26 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout) · 97 unmodified lines | ||
| 98 | 98 | |
| 99 | 99 | trace_sched_process_hang(t); |
| 100 | 100 | |
| 101 | − if (!sysctl_hung_task_warnings) | |
| 101 | + if (!sysctl_hung_task_warnings && !sysctl_hung_task_panic) | |
| 102 | 102 | return; |
| 103 | 103 | |
| 104 | − if (sysctl_hung_task_warnings > 0) | |
| 105 | − sysctl_hung_task_warnings--; | |
| 106 | − | |
| 107 | 104 | /* |
| 108 | 105 | * Ok, the task did not get scheduled for more than 2 minutes, |
| 109 | 106 | * complain: |
| 110 | 107 | */ |
| 111 | − pr_err("INFO: task %s:%d blocked for more than %ld seconds.\n", | |
| 112 | − t->comm, t->pid, timeout); | |
| 113 | − pr_err(" %s %s %.*s\n", | |
| 114 | − print_tainted(), init_utsname()->release, | |
| 115 | − (int)strcspn(init_utsname()->version, " "), | |
| 116 | − init_utsname()->version); | |
| 117 | − pr_err("\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\"" | |
| 118 | − " disables this message.\n"); | |
| 119 | − sched_show_task(t); | |
| 120 | − debug_show_all_locks(); | |
| 108 | + if (sysctl_hung_task_warnings) { | |
| 109 | + sysctl_hung_task_warnings--; | |
| 110 | + pr_err("INFO: task %s:%d blocked for more than %ld seconds.\n", | |
| 111 | + t->comm, t->pid, timeout); | |
| 112 | + pr_err(" %s %s %.*s\n", | |
| 113 | + print_tainted(), init_utsname()->release, | |
| 114 | + (int)strcspn(init_utsname()->version, " "), | |
| 115 | + init_utsname()->version); | |
| 116 | + pr_err("\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\"" | |
| 117 | + " disables this message.\n"); | |
| 118 | + sched_show_task(t); | |
| 119 | + debug_show_all_locks(); | |
| 120 | + } | |
| 121 | 121 | |
| 122 | 122 | touch_nmi_watchdog(); |
| 123 | 123 | |