mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Feng Tang <feng.tang@linux.alibaba.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Petr Mladek <pmladek@suse.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Lance Yang <lance.yang@linux.dev>,
	linux-kernel@vger.kernel.org
Cc: mhiramat@kernel.org, llong@redhat.com,
	Feng Tang <feng.tang@linux.alibaba.com>
Subject: [PATCH v1 3/3] kernel/watchdog: add option to dump system info when system is locked up
Date: Sun, 11 May 2025 16:52:54 +0800	[thread overview]
Message-ID: <20250511085254.61446-4-feng.tang@linux.alibaba.com> (raw)
In-Reply-To: <20250511085254.61446-1-feng.tang@linux.alibaba.com>

Kernel panic code utilizes sys_show_info() to dump needed system
information to help debugging. Similarly, add this debug option for
software/hardware lockup cases, and 'lockup_print_mask' is the control
knob and a bitmask to control what information should be printed out:

	bit 0: print all tasks info
	bit 1: print system memory info
	bit 2: print timer info
	bit 3: print locks info if CONFIG_LOCKDEP is on
	bit 4: print ftrace buffer
	bit 5: print all printk messages in buffer
	bit 6: print all CPUs backtrace (if available in the arch)
	bit 7: print only tasks in uninterruptible (blocked) state

Signed-off-by: Feng Tang <feng.tang@linux.alibaba.com>
---
 .../admin-guide/kernel-parameters.txt         | 11 +++++++---
 kernel/watchdog.c                             | 20 +++++++++++++++++++
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index d35d8101bee9..2b8bda2b5f0b 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -4489,9 +4489,14 @@
 			bigger log buffer with "log_buf_len" along with this.
 
 	hungtask_print_mask=
-			Bitmask for printing system info when hung task is detected.
-			Details of bits definition is the same as panic_print's
-			definition above.
+			Bitmask for printing system info when hung task is
+			detected. Details of bits definition is the same as
+			panic_print's definition above.
+
+	lockup_print_mask=
+			Bitmask for printing system info when software/hardware
+			system lockup is detected. Details of bits definition
+			is the same as panic_print's definition above.
 
 	parkbd.port=	[HW] Parallel port number the keyboard adapter is
 			connected to, default is 0.
diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index 9fa2af9dbf2c..fb1b94929c3b 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -52,6 +52,23 @@ static int __read_mostly watchdog_hardlockup_available;
 struct cpumask watchdog_cpumask __read_mostly;
 unsigned long *watchdog_cpumask_bits = cpumask_bits(&watchdog_cpumask);
 
+/*
+ * A bitmask to control what kinds of system info to be printed when a
+ * software/hardware lockup is detected, it could be task, memory, lock
+ * etc. And the bit definition (from panic.h) is:
+ *
+ *	#define SYS_PRINT_TASK_INFO		0x00000001
+ *	#define SYS_PRINT_MEM_INFO		0x00000002
+ *	#define SYS_PRINT_TIMER_INFO		0x00000004
+ *	#define SYS_PRINT_LOCK_INFO		0x00000008
+ *	#define SYS_PRINT_FTRACE_INFO		0x00000010
+ *	#define SYS_PRINT_ALL_PRINTK_MSG	0x00000020
+ *	#define SYS_PRINT_ALL_CPU_BT		0x00000040
+ *	#define SYS_PRINT_BLOCKED_TASKS		0x00000080
+ */
+unsigned long lockup_print_mask;
+core_param(lockup_print_mask, lockup_print_mask, ulong, 0644);
+
 #ifdef CONFIG_HARDLOCKUP_DETECTOR
 
 # ifdef CONFIG_SMP
@@ -212,6 +229,7 @@ void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs)
 				clear_bit_unlock(0, &hard_lockup_nmi_warn);
 		}
 
+		sys_show_info(lockup_print_mask);
 		if (hardlockup_panic)
 			nmi_panic(regs, "Hard LOCKUP");
 
@@ -774,6 +792,8 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
 		}
 
 		add_taint(TAINT_SOFTLOCKUP, LOCKDEP_STILL_OK);
+
+		sys_show_info(lockup_print_mask);
 		if (softlockup_panic)
 			panic("softlockup: hung tasks");
 	}
-- 
2.39.5 (Apple Git-154)


  parent reply	other threads:[~2025-05-11  8:53 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-11  8:52 [PATCH v1 0/3] generalize panic_print's dump function to be used by other kernel parts Feng Tang
2025-05-11  8:52 ` [PATCH v1 1/3] kernel/panic: generalize panic_print's function to show sys info Feng Tang
2025-05-13  9:57   ` Petr Mladek
2025-05-13 13:23     ` Feng Tang
2025-05-15 10:32       ` Petr Mladek
2025-05-15 11:28         ` Lance Yang
2025-05-16  5:38         ` Feng Tang
2025-05-16 13:39           ` Lance Yang
2025-05-21  5:31           ` Feng Tang
2025-06-10 15:44             ` Petr Mladek
2025-06-11 13:43               ` Feng Tang
2025-05-11  8:52 ` [PATCH v1 2/3] kernel/hung_task: add option to dump system info when hung task detected Feng Tang
2025-05-11  8:52 ` Feng Tang [this message]
2025-05-12  1:46 ` [PATCH v1 0/3] generalize panic_print's dump function to be used by other kernel parts Andrew Morton
2025-05-12  3:14   ` Feng Tang
2025-05-12  8:23     ` Lance Yang
2025-05-12  9:31       ` Feng Tang
2025-05-13 13:27       ` Petr Mladek
2025-05-13 17:09         ` Paul E. McKenney
2025-05-14  3:33           ` Feng Tang
2025-05-14 13:55             ` Paul E. McKenney
2025-05-14  3:22         ` Feng Tang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250511085254.61446-4-feng.tang@linux.alibaba.com \
    --to=feng.tang@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=lance.yang@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llong@redhat.com \
    --cc=mhiramat@kernel.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®