All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hung_task: Allow hung_task_panic when hung_task_warnings is 0.
@ 2016-09-09 19:43 jsiddle
  2016-09-09 20:13 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: jsiddle @ 2016-09-09 19:43 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, penguin-kernel

From: John Siddle <jsiddle@redhat.com>

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.

Signed-off-by: John Siddle <jsiddle@redhat.com>
---
 kernel/hung_task.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/kernel/hung_task.c b/kernel/hung_task.c
index d234022..938e0a0 100644
--- a/kernel/hung_task.c
+++ b/kernel/hung_task.c
@@ -98,7 +98,7 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)
 
 	trace_sched_process_hang(t);
 
-	if (!sysctl_hung_task_warnings)
+	if (!sysctl_hung_task_warnings && !sysctl_hung_task_panic)
 		return;
 
 	if (sysctl_hung_task_warnings > 0)
@@ -108,16 +108,18 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)
 	 * Ok, the task did not get scheduled for more than 2 minutes,
 	 * complain:
 	 */
-	pr_err("INFO: task %s:%d blocked for more than %ld seconds.\n",
-		t->comm, t->pid, timeout);
-	pr_err("      %s %s %.*s\n",
-		print_tainted(), init_utsname()->release,
-		(int)strcspn(init_utsname()->version, " "),
-		init_utsname()->version);
-	pr_err("\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\""
-		" disables this message.\n");
-	sched_show_task(t);
-	debug_show_held_locks(t);
+	if (sysctl_hung_task_warnings) {
+		pr_err("INFO: task %s:%d blocked for more than %ld seconds.\n",
+			t->comm, t->pid, timeout);
+		pr_err("      %s %s %.*s\n",
+			print_tainted(), init_utsname()->release,
+			(int)strcspn(init_utsname()->version, " "),
+			init_utsname()->version);
+		pr_err("\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\""
+			" disables this message.\n");
+		sched_show_task(t);
+		debug_show_held_locks(t);
+	}
 
 	touch_nmi_watchdog();
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] hung_task: Allow hung_task_panic when hung_task_warnings is 0.
  2016-09-09 19:43 [PATCH] hung_task: Allow hung_task_panic when hung_task_warnings is 0 jsiddle
@ 2016-09-09 20:13 ` Andrew Morton
  2016-09-10  0:18   ` Tetsuo Handa
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2016-09-09 20:13 UTC (permalink / raw)
  To: jsiddle; +Cc: linux-kernel, penguin-kernel

On Fri,  9 Sep 2016 15:43:34 -0400 jsiddle@redhat.com wrote:

> From: John Siddle <jsiddle@redhat.com>
> 
> 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.
> 
> ...
>
> --- a/kernel/hung_task.c
> +++ b/kernel/hung_task.c
> @@ -98,7 +98,7 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)
>  
>  	trace_sched_process_hang(t);
>  
> -	if (!sysctl_hung_task_warnings)
> +	if (!sysctl_hung_task_warnings && !sysctl_hung_task_panic)
>  		return;
>  
>  	if (sysctl_hung_task_warnings > 0)
> @@ -108,16 +108,18 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)
>  	 * Ok, the task did not get scheduled for more than 2 minutes,
>  	 * complain:
>  	 */
> -	pr_err("INFO: task %s:%d blocked for more than %ld seconds.\n",
> -		t->comm, t->pid, timeout);
> -	pr_err("      %s %s %.*s\n",
> -		print_tainted(), init_utsname()->release,
> -		(int)strcspn(init_utsname()->version, " "),
> -		init_utsname()->version);
> -	pr_err("\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\""
> -		" disables this message.\n");
> -	sched_show_task(t);
> -	debug_show_held_locks(t);
> +	if (sysctl_hung_task_warnings) {
> +		pr_err("INFO: task %s:%d blocked for more than %ld seconds.\n",
> +			t->comm, t->pid, timeout);
> +		pr_err("      %s %s %.*s\n",
> +			print_tainted(), init_utsname()->release,
> +			(int)strcspn(init_utsname()->version, " "),
> +			init_utsname()->version);
> +		pr_err("\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\""
> +			" disables this message.\n");
> +		sched_show_task(t);
> +		debug_show_held_locks(t);
> +	}

This introduces an off-by-one error.  In the old code, if
sysctl_hung_task_warnings==1 on entry, we warn.  With the new code, we
no longer warn.

This?

--- a/kernel/hung_task.c~hung_task-allow-hung_task_panic-when-hung_task_warnings-is-0-fix
+++ a/kernel/hung_task.c
@@ -101,14 +101,12 @@ static void check_hung_task(struct task_
 	if (!sysctl_hung_task_warnings && !sysctl_hung_task_panic)
 		return;
 
-	if (sysctl_hung_task_warnings > 0)
-		sysctl_hung_task_warnings--;
-
 	/*
 	 * Ok, the task did not get scheduled for more than 2 minutes,
 	 * complain:
 	 */
 	if (sysctl_hung_task_warnings) {
+		sysctl_hung_task_warnings--;
 		pr_err("INFO: task %s:%d blocked for more than %ld seconds.\n",
 			t->comm, t->pid, timeout);
 		pr_err("      %s %s %.*s\n",
_

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] hung_task: Allow hung_task_panic when hung_task_warnings is 0.
  2016-09-09 20:13 ` Andrew Morton
@ 2016-09-10  0:18   ` Tetsuo Handa
  0 siblings, 0 replies; 3+ messages in thread
From: Tetsuo Handa @ 2016-09-10  0:18 UTC (permalink / raw)
  To: akpm, jsiddle; +Cc: linux-kernel

Andrew Morton wrote:
> This introduces an off-by-one error.  In the old code, if
> sysctl_hung_task_warnings==1 on entry, we warn.  With the new code, we
> no longer warn.

Since sysctl_hung_task_warnings == -1 is allowed, we should not
sysctl_hung_task_warnings-- unless sysctl_hung_task_warnings > 0.

> 
> This?
> 
> --- a/kernel/hung_task.c~hung_task-allow-hung_task_panic-when-hung_task_warnings-is-0-fix
> +++ a/kernel/hung_task.c
> @@ -101,14 +101,12 @@ static void check_hung_task(struct task_
>  	if (!sysctl_hung_task_warnings && !sysctl_hung_task_panic)
>  		return;
>  
> -	if (sysctl_hung_task_warnings > 0)
> -		sysctl_hung_task_warnings--;
> -
>  	/*
>  	 * Ok, the task did not get scheduled for more than 2 minutes,
>  	 * complain:
>  	 */
>  	if (sysctl_hung_task_warnings) {

+		if (sysctl_hung_task_warnings > 0)

> +		sysctl_hung_task_warnings--;
>  		pr_err("INFO: task %s:%d blocked for more than %ld seconds.\n",
>  			t->comm, t->pid, timeout);
>  		pr_err("      %s %s %.*s\n",

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-09-10  0:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-09 19:43 [PATCH] hung_task: Allow hung_task_panic when hung_task_warnings is 0 jsiddle
2016-09-09 20:13 ` Andrew Morton
2016-09-10  0:18   ` Tetsuo Handa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.