Skip to contentSkip to conversation

hung_task: Display every hung task warning

RFC PATCH Superseded [email protected] 2 participants 4 messages Jan 15, 2014

Subsystems (2)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover hung_task: Display every hung task warning

From: Aaron Tomlin <[email protected]>

When khungtaskd detects hung tasks, it prints out backtraces from a number of those tasks. Sometimes the information on why things are stuck is hidden in those backtraces. Limiting the number of backtraces being printed out can result in the user not seeing the information necessary to debug the issue. This patch introduces an option to print an unlimited number of backtraces when khungtaskd detects hung tasks.

While ULONG_MAX is practically "inf", this patch takes it one step further. Note: The maximum is now 2^31-1 (INT_MAX) which should hopefully be sufficient.

Rebased against v3.13-rc8.

Aaron Tomlin (2):
sysctl: Make neg_one a standard constraint
hung_task: Display every hung task warning

 include/linux/sched/sysctl.h | 2 +-
 kernel/hung_task.c           | 6 ++++--
 kernel/sysctl.c              | 6 ++++--
 3 files changed, 9 insertions(+), 5 deletions(-)
Signature · 1 line
1.8.4.2
#1 lore raw

RFC PATCH v3 1/2 sysctl: Make neg_one a standard constraint

From: Aaron Tomlin <[email protected]>

Add neg_one to the list of standard constraints.

---
 kernel/sysctl.c | 1 +
 1 file changed, 1 insertion(+)
kernel/sysctl.c +1 -0
index 34a6047..dd531a6 100644
@@ -122,6 +122,7 @@ extern int blk_iopoll_enabled;
 static int sixty = 60;
 #endif
 
+static int neg_one = -1;
 static int zero;
 static int __maybe_unused one = 1;
 static int __maybe_unused two = 2;
Signature · 1 line
1.8.4.2
#2 lore raw

RFC PATCH v3 2/2 hung_task: Display every hung task warning

In reply to [email protected]

From: Aaron Tomlin <[email protected]>

When khungtaskd detects hung tasks, it prints out backtraces from a number of those tasks. Sometimes the information on why things are stuck is hidden in those backtraces. Limiting the number of backtraces being printed out can result in the user not seeing the information necessary to debug the issue. This patch introduces an option to print an unlimited number of backtraces when khungtaskd detects hung tasks.

While ULONG_MAX is practically "inf", this patch takes it one step further. Note: The maximum is now 2^31-1 (INT_MAX) which should hopefully be sufficient.

---
 include/linux/sched/sysctl.h | 2 +-
 kernel/hung_task.c           | 6 ++++--
 kernel/sysctl.c              | 5 +++--
 3 files changed, 8 insertions(+), 5 deletions(-)
include/linux/sched/sysctl.h +1 -1
index 41467f8..eb3c72d7 100644
@@ -5,7 +5,7 @@
 extern int	     sysctl_hung_task_check_count;
 extern unsigned int  sysctl_hung_task_panic;
 extern unsigned long sysctl_hung_task_timeout_secs;
-extern unsigned long sysctl_hung_task_warnings;
+extern int sysctl_hung_task_warnings;
 extern int proc_dohung_task_timeout_secs(struct ctl_table *table, int write,
 					 void __user *buffer,
 					 size_t *lenp, loff_t *ppos);
kernel/hung_task.c +4 -2
index 9328b80..0b9c169 100644
@@ -37,7 +37,7 @@ int __read_mostly sysctl_hung_task_check_count = PID_MAX_LIMIT;
  */
 unsigned long __read_mostly sysctl_hung_task_timeout_secs = CONFIG_DEFAULT_HUNG_TASK_TIMEOUT;
 
-unsigned long __read_mostly sysctl_hung_task_warnings = 10;
+int __read_mostly sysctl_hung_task_warnings = 10;
 
 static int __read_mostly did_panic;
 
@@ -98,7 +98,9 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)
 
 	if (!sysctl_hung_task_warnings)
 		return;
-	sysctl_hung_task_warnings--;
+
+	if (sysctl_hung_task_warnings > 0)
+		sysctl_hung_task_warnings--;
 
 	/*
 	 * Ok, the task did not get scheduled for more than 2 minutes,
kernel/sysctl.c +3 -2
index dd531a6..b50cd13 100644
@@ -985,9 +985,10 @@ static struct ctl_table kern_table[] = {
 	{
 		.procname	= "hung_task_warnings",
 		.data		= &sysctl_hung_task_warnings,
-		.maxlen		= sizeof(unsigned long),
+		.maxlen		= sizeof(int),
 		.mode		= 0644,
-		.proc_handler	= proc_doulongvec_minmax,
+		.proc_handler	= proc_dointvec_minmax,
+		.extra1		= &neg_one,
 	},
 #endif
 #ifdef CONFIG_COMPAT
Signature · 1 line
1.8.4.2
#3 lore raw
Quoted 12 lines · On Wed, 15 Jan 2014, [email protected] wrote:

From: Aaron Tomlin <[email protected]>

When khungtaskd detects hung tasks, it prints out backtraces from a number of those tasks. Sometimes the information on why things are stuck is hidden in those backtraces. Limiting the number of backtraces being printed out can result in the user not seeing the information necessary to debug the issue. This patch introduces an option to print an unlimited number of backtraces when khungtaskd detects hung tasks.

Quoted 5 lines

While ULONG_MAX is practically "inf", this patch takes it one step further. Note: The maximum is now 2^31-1 (INT_MAX) which should hopefully be sufficient.

This rationale is someone cryptic, it seems what you're doing is allowing the sysctl to be set to -1 that will never limit the number of warnings and to do that you need a signed value so you converted ulong to int.

Quoted 51 lines
---
 include/linux/sched/sysctl.h | 2 +-
 kernel/hung_task.c           | 6 ++++--
 kernel/sysctl.c              | 5 +++--
 3 files changed, 8 insertions(+), 5 deletions(-)
include/linux/sched/sysctl.h +1 -1
index 41467f8..eb3c72d7 100644
@@ -5,7 +5,7 @@
 extern int	     sysctl_hung_task_check_count;
 extern unsigned int  sysctl_hung_task_panic;
 extern unsigned long sysctl_hung_task_timeout_secs;
-extern unsigned long sysctl_hung_task_warnings;
+extern int sysctl_hung_task_warnings;
 extern int proc_dohung_task_timeout_secs(struct ctl_table *table, int write,
 					 void __user *buffer,
 					 size_t *lenp, loff_t *ppos);
kernel/hung_task.c +4 -2
index 9328b80..0b9c169 100644
@@ -37,7 +37,7 @@ int __read_mostly sysctl_hung_task_check_count = PID_MAX_LIMIT;
  */
 unsigned long __read_mostly sysctl_hung_task_timeout_secs = CONFIG_DEFAULT_HUNG_TASK_TIMEOUT;
 
-unsigned long __read_mostly sysctl_hung_task_warnings = 10;
+int __read_mostly sysctl_hung_task_warnings = 10;
 
 static int __read_mostly did_panic;
 
@@ -98,7 +98,9 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)
 
 	if (!sysctl_hung_task_warnings)
 		return;
-	sysctl_hung_task_warnings--;
+
+	if (sysctl_hung_task_warnings > 0)
+		sysctl_hung_task_warnings--;
 
 	/*
 	 * Ok, the task did not get scheduled for more than 2 minutes,
kernel/sysctl.c +0 -0
index dd531a6..b50cd13 100644
@@ -985,9 +985,10 @@ static struct ctl_table kern_table[] = {
 	{
 		.procname	= "hung_task_warnings",

kernel/sysctl.c static struct ctl_table kern_table[] = { · line 994

Quoted 10 lines
kernel/sysctl.c +3 -2
 		.data		= &sysctl_hung_task_warnings,
-		.maxlen		= sizeof(unsigned long),
+		.maxlen		= sizeof(int),
 		.mode		= 0644,
-		.proc_handler	= proc_doulongvec_minmax,
+		.proc_handler	= proc_dointvec_minmax,
+		.extra1		= &neg_one,
 	},
 #endif
 #ifdef CONFIG_COMPAT

hung_task_warnings isn't documented in the source, so how is anybody supposed to know that -1 is an acceptable value and what it's special case allows?