summaryrefslogtreecommitdiffstats
path: root/kernel/printk/printk.c
diff options
context:
space:
mode:
authorJohn Ogness <john.ogness@linutronix.de>2024-09-04 14:05:30 +0200
committerPetr Mladek <pmladek@suse.com>2024-09-04 15:56:32 +0200
commit5102981d5e2a5a7a12424b5d26c7524ac2899898 (patch)
tree546c0a008b95bc7241f81366856663fe553372e0 /kernel/printk/printk.c
parentprintk: Provide helper for message prepending (diff)
downloadlinux-5102981d5e2a5a7a12424b5d26c7524ac2899898.tar.xz
linux-5102981d5e2a5a7a12424b5d26c7524ac2899898.zip
printk: nbcon: Show replay message on takeover
An emergency or panic context can takeover console ownership while the current owner was printing a printk message. The atomic printer will re-print the message that the previous owner was printing. However, this can look confusing to the user and may even seem as though a message was lost. [3430014.1 [3430014.181123] usb 1-2: Product: USB Audio Add a new field @nbcon_prev_seq to struct console to track the sequence number to print that was assigned to the previous console owner. If this matches the sequence number to print that the current owner is assigned, then a takeover must have occurred. In this case, print an additional message to inform the user that the previous message is being printed again. [3430014.1 ** replaying previous printk message ** [3430014.181123] usb 1-2: Product: USB Audio Signed-off-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Petr Mladek <pmladek@suse.com> Link: https://lore.kernel.org/r/20240904120536.115780-12-john.ogness@linutronix.de Signed-off-by: Petr Mladek <pmladek@suse.com>
Diffstat (limited to 'kernel/printk/printk.c')
-rw-r--r--kernel/printk/printk.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index e9458569bcfd..c27dc54f4151 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2903,6 +2903,17 @@ void console_prepend_dropped(struct printk_message *pmsg, unsigned long dropped)
}
/*
+ * Prepend the message in @pmsg->pbufs->outbuf with a "replay message".
+ * @pmsg->outbuf_len is updated appropriately.
+ *
+ * @pmsg is the printk message to prepend.
+ */
+void console_prepend_replay(struct printk_message *pmsg)
+{
+ console_prepend_message(pmsg, "** replaying previous printk message **\n");
+}
+
+/*
* Read and format the specified record (or a later record if the specified
* record is not available).
*