Skip to content

Commit

Permalink
printk: Rename console_replay_all() and update context
Browse files Browse the repository at this point in the history
Rename console_replay_all() to console_try_replay_all() to make
clear that the implementation is best effort. Also, the function
should not be called in NMI context as it takes locks, so update
the comment in code.

Fixes: 693f75b ("printk: Add function to replay kernel log on consoles")
Fixes: 1b74348 ("tty/sysrq: Replay kernel log messages on consoles via sysrq")
Suggested-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Shimoyashiki Taichi <taichi.shimoyashiki@sony.com>
Signed-off-by: Sreenath Vijayan <sreenath.vijayan@sony.com>
Link: https://lore.kernel.org/r/Zlguq/wU21Z8MqI4@sreenath.vijayan@sony.com
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
  • Loading branch information
Sreenath Vijayan authored and Petr Mladek committed Jun 3, 2024
1 parent 1613e60 commit 3d9a0a2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion drivers/tty/sysrq.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ static const struct sysrq_key_op sysrq_unrt_op = {

static void sysrq_handle_replay_logs(u8 key)
{
console_replay_all();
console_try_replay_all();
}
static struct sysrq_key_op sysrq_replay_logs_op = {
.handler = sysrq_handle_replay_logs,
Expand Down
4 changes: 2 additions & 2 deletions include/linux/printk.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ void show_regs_print_info(const char *log_lvl);
extern asmlinkage void dump_stack_lvl(const char *log_lvl) __cold;
extern asmlinkage void dump_stack(void) __cold;
void printk_trigger_flush(void);
void console_replay_all(void);
void console_try_replay_all(void);
#else
static inline __printf(1, 0)
int vprintk(const char *s, va_list args)
Expand Down Expand Up @@ -275,7 +275,7 @@ static inline void dump_stack(void)
static inline void printk_trigger_flush(void)
{
}
static inline void console_replay_all(void)
static inline void console_try_replay_all(void)
{
}
#endif
Expand Down
6 changes: 3 additions & 3 deletions kernel/printk/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -4314,15 +4314,15 @@ void kmsg_dump_rewind(struct kmsg_dump_iter *iter)
EXPORT_SYMBOL_GPL(kmsg_dump_rewind);

/**
* console_replay_all - replay kernel log on consoles
* console_try_replay_all - try to replay kernel log on consoles
*
* Try to obtain lock on console subsystem and replay all
* available records in printk buffer on the consoles.
* Does nothing if lock is not obtained.
*
* Context: Any context.
* Context: Any, except for NMI.
*/
void console_replay_all(void)
void console_try_replay_all(void)
{
if (console_trylock()) {
__console_rewind_all();
Expand Down

0 comments on commit 3d9a0a2

Please sign in to comment.