linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hung_task: add warning counter to blocked task report
@ 2025-07-21  3:17 Ye Liu
  2025-07-21  4:56 ` Lance Yang
  0 siblings, 1 reply; 6+ messages in thread
From: Ye Liu @ 2025-07-21  3:17 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Ye Liu, Lance Yang, linux-kernel

From: Ye Liu <liuye@kylinos.cn>

Add a warning counter to each hung task message to make it easier
to analyze and locate issues in the logs.

Signed-off-by: Ye Liu <liuye@kylinos.cn>
---
 kernel/hung_task.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/hung_task.c b/kernel/hung_task.c
index 8708a1205f82..9e5f86148d47 100644
--- a/kernel/hung_task.c
+++ b/kernel/hung_task.c
@@ -58,6 +58,7 @@ EXPORT_SYMBOL_GPL(sysctl_hung_task_timeout_secs);
 static unsigned long __read_mostly sysctl_hung_task_check_interval_secs;
 
 static int __read_mostly sysctl_hung_task_warnings = 10;
+static int hung_task_warning_count;
 
 static int __read_mostly did_panic;
 static bool hung_task_show_lock;
@@ -232,8 +233,9 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)
 	if (sysctl_hung_task_warnings || hung_task_call_panic) {
 		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, (jiffies - t->last_switch_time) / HZ);
+		pr_err("INFO: task %s:%d blocked for more than %ld seconds. [Warning #%d]\n",
+		       t->comm, t->pid, (jiffies - t->last_switch_time) / HZ,
+		       ++hung_task_warning_count);
 		pr_err("      %s %s %.*s\n",
 			print_tainted(), init_utsname()->release,
 			(int)strcspn(init_utsname()->version, " "),
-- 
2.43.0


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

end of thread, other threads:[~2025-07-23 10:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-21  3:17 [PATCH] hung_task: add warning counter to blocked task report Ye Liu
2025-07-21  4:56 ` Lance Yang
2025-07-21  5:45   ` Ye Liu
2025-07-21  6:19     ` Lance Yang
2025-07-23  7:31       ` Ye Liu
2025-07-23 10:46         ` Lance Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).