[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ca8dd18e434f309612c907d90e9f77c09e045b37.1706772349.git.sreenath.vijayan@sony.com>
Date: Thu, 1 Feb 2024 15:59:42 +0530
From: Sreenath Vijayan <sreenath.vijayan@...y.com>
To: john.ogness@...utronix.de, corbet@....net, gregkh@...uxfoundation.org,
jirislaby@...nel.org, pmladek@...e.com
Cc: rdunlap@...radead.org, rostedt@...dmis.org, senozhatsky@...omium.org,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-serial@...r.kernel.org, taichi.shimoyashiki@...y.com,
daniel.palmer@...y.com, anandakumar.balasubramaniam@...y.com,
sreenath.vijayan@...y.com
Subject: [PATCH v4 2/2] tty/sysrq: Dump printk ring buffer messages via sysrq
When terminal is unresponsive, one cannot use dmesg to view printk
ring buffer messages. Also, syslog services may be disabled,
to check the messages after a reboot, especially on embedded systems.
In this scenario, dump the printk ring buffer messages via sysrq
by pressing sysrq+D.
Signed-off-by: Sreenath Vijayan <sreenath.vijayan@...y.com>
Signed-off-by: Shimoyashiki Taichi <taichi.shimoyashiki@...y.com>
---
Documentation/admin-guide/sysrq.rst | 2 ++
drivers/tty/sysrq.c | 20 +++++++++++++++++++-
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/Documentation/admin-guide/sysrq.rst b/Documentation/admin-guide/sysrq.rst
index 2f2e5bd440f9..c634e8b4cea2 100644
--- a/Documentation/admin-guide/sysrq.rst
+++ b/Documentation/admin-guide/sysrq.rst
@@ -161,6 +161,8 @@ Command Function
will be printed to your console. (``0``, for example would make
it so that only emergency messages like PANICs or OOPSes would
make it to your console.)
+
+``D`` Dump the printk ring buffer
=========== ===================================================================
Okay, so what can I use them for?
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index 02217e3c916b..365f7fa145f0 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -450,6 +450,24 @@ static const struct sysrq_key_op sysrq_unrt_op = {
.enable_mask = SYSRQ_ENABLE_RTNICE,
};
+static void dmesg_dump_callback(struct work_struct *work)
+{
+ dump_printk_buffer();
+}
+
+static DECLARE_WORK(sysrq_dmesg_work, dmesg_dump_callback);
+
+static void sysrq_handle_dmesg_dump(u8 key)
+{
+ queue_work(system_unbound_wq, &sysrq_dmesg_work);
+}
+static struct sysrq_key_op sysrq_dmesg_dump_op = {
+ .handler = sysrq_handle_dmesg_dump,
+ .help_msg = "dump-dmesg(D)",
+ .action_msg = "Dump dmesg",
+ .enable_mask = SYSRQ_ENABLE_DUMP,
+};
+
/* Key Operations table and lock */
static DEFINE_SPINLOCK(sysrq_key_table_lock);
@@ -505,7 +523,7 @@ static const struct sysrq_key_op *sysrq_key_table[62] = {
NULL, /* A */
NULL, /* B */
NULL, /* C */
- NULL, /* D */
+ &sysrq_dmesg_dump_op, /* D */
NULL, /* E */
NULL, /* F */
NULL, /* G */
--
2.43.0
Powered by blists - more mailing lists