linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/2] Add support to dump printk buffer to console via sysrq
@ 2024-02-01 10:16 Sreenath Vijayan
  2024-02-01 10:23 ` [PATCH v4 1/2] printk: Add function to dump printk buffer directly to consoles Sreenath Vijayan
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Sreenath Vijayan @ 2024-02-01 10:16 UTC (permalink / raw)
  To: john.ogness, corbet, gregkh, jirislaby, pmladek
  Cc: rdunlap, rostedt, senozhatsky, linux-doc, linux-kernel,
	linux-serial, taichi.shimoyashiki, daniel.palmer,
	anandakumar.balasubramaniam, sreenath.vijayan

Hi,

This patch series enables one to dump the messages in printk ring
buffer unless all CPUs are locked up. This is useful to view the
kernel messages when terminal is unresponsive to enter commands
like dmesg and syslog services are also disabled, especially on
embedded targets. Although debug features like kdb/kgdb already
allow this, these debug configs should be enabled which is often
not the case.

Till the last version, kmsg_dump* interface was being used to
retrieve the messages in printk buffer before dumping them to
consoles. However, John Ogness pointed out the issue with
kmsg_dump* interface that it doesn't work well with extended
consoles. He suggested a new method to reuse the code in
console_flush_on_panic() but without disabling scheduling.

In the first commit, code under CONSOLE_REPLAY_ALL mode in
console_flush_on_panic() is taken out to a helper function
console_rewind_all() to set the console sequence numbder to
oldest record in the printk buffer. And the new function to
dump the buffer called dump_printk_buffer() calls this function
after taking the console lock and then releases the lock which
flushes out the contents of printk buffer to console.

In the second commit, code is added to call dump_printk_buffer()
function when sysrq+D is pressed. As the function may sleep,
it cannot be called from interrupt context. A work is queued
in the system unbound workqueue to call the function when
the key is pressed.

Links to previous discussion:
- https://lore.kernel.org/all/cover.1705331453.git.sreenath.vijayan@sony.com/T/#t
- https://lore.kernel.org/linux-serial/20231221133953.1507021-1-sreenath.vijayan@sony.com/

Changelog:
V3 -> V4:
- refactored code in console_flush_on_panic() under CONSOLE_REPLAY_ALL mode
- added helper function console_rewind_all()
- used console_rewind_all() instead of ksmg_dump*() in dump_printk_buffer()

V2 -> V3:
- split the implementation into two commits
- added function in printk.c to dump printk buffer to consoles
- added Suggested-by tag
- removed code to dump printk buffer from sysrq.c and called
new function

V1 -> V2:
- modified kernel ring buffer to printk ring buffer
- allocated buf dynamically to prevent stack frame size warnings
- used buf of size 2048 to match PRINTK_MESSAGE_MAX and added comment

-- Sreenath

Sreenath Vijayan (2):
  printk: Add function to dump printk buffer directly to consoles
  tty/sysrq: Dump printk ring buffer messages via sysrq

 Documentation/admin-guide/sysrq.rst |  2 +
 drivers/tty/sysrq.c                 | 20 +++++++++-
 include/linux/printk.h              |  4 ++
 kernel/printk/printk.c              | 61 +++++++++++++++++------------
 4 files changed, 62 insertions(+), 25 deletions(-)

-- 
2.43.0


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

end of thread, other threads:[~2024-02-26  9:28 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-01 10:16 [PATCH v4 0/2] Add support to dump printk buffer to console via sysrq Sreenath Vijayan
2024-02-01 10:23 ` [PATCH v4 1/2] printk: Add function to dump printk buffer directly to consoles Sreenath Vijayan
2024-02-01 11:28   ` John Ogness
2024-02-07 14:43   ` Petr Mladek
2024-02-14 10:33     ` Sreenath Vijayan
2024-02-01 10:29 ` [PATCH v4 2/2] tty/sysrq: Dump printk ring buffer messages via sysrq Sreenath Vijayan
2024-02-01 11:29   ` John Ogness
2024-02-07 15:09   ` Petr Mladek
2024-02-08 10:18     ` Greg KH
2024-02-08 13:39       ` John Ogness
2024-02-14 10:40     ` Sreenath Vijayan
2024-02-14 11:12     ` Sreenath Vijayan
2024-02-26  8:01       ` Sreenath Vijayan
2024-02-26  9:28       ` John Ogness
2024-02-07 14:12 ` [PATCH v4 0/2] Add support to dump printk buffer to console " Petr Mladek
2024-02-14 10:30   ` Sreenath Vijayan

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).