[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230728000233.50887-3-john.ogness@linutronix.de>
Date: Fri, 28 Jul 2023 02:08:27 +0206
From: John Ogness <john.ogness@...utronix.de>
To: Petr Mladek <pmladek@...e.com>
Cc: Sergey Senozhatsky <senozhatsky@...omium.org>,
Steven Rostedt <rostedt@...dmis.org>,
Thomas Gleixner <tglx@...utronix.de>,
linux-kernel@...r.kernel.org
Subject: [PATCH printk v2 2/8] printk: Provide debug_store() for nbcon debugging
To debug and validate nbcon ownership transitions, provide a new
macro debug_store() (enabled with DEBUG_NBCON) to log transition
information to the ringbuffer. If enabled, this macro only logs
to the ringbuffer and does not trigger any printing. This is to
avoid triggering recursive printing in the nbcon consoles.
Signed-off-by: John Ogness <john.ogness@...utronix.de>
---
kernel/printk/printk_nbcon.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/kernel/printk/printk_nbcon.c b/kernel/printk/printk_nbcon.c
index bb379a4f6263..f9462b088439 100644
--- a/kernel/printk/printk_nbcon.c
+++ b/kernel/printk/printk_nbcon.c
@@ -10,6 +10,35 @@
* the legacy style console_lock mechanism.
*/
+/*
+ * Define DEBUG_NBCON to allow for nbcon ownership transitions to be logged
+ * to the ringbuffer. The debug_store() macro only logs to the lockless
+ * ringbuffer and does not trigger any printing.
+ */
+#undef DEBUG_NBCON
+
+#ifdef DEBUG_NBCON
+/* Only write to ringbuffer. */
+int __debug_store(const char *fmt, ...)
+{
+ va_list args;
+ int r;
+
+ va_start(args, fmt);
+ r = vprintk_store(2, 7, NULL, fmt, args);
+ va_end(args);
+
+ return r;
+}
+#define debug_store(cond, fmt, ...) \
+ do { \
+ if (cond) \
+ __debug_store(pr_fmt("DEBUG: " fmt), ##__VA_ARGS__) \
+ } while (0)
+#else
+#define debug_store(cond, fmt, ...)
+#endif
+
/**
* nbcon_state_set - Helper function to set the console state
* @con: Console to update
--
2.39.2
Powered by blists - more mailing lists