2024-05-30 07:46:43

by Sreenath Vijayan

[permalink] [raw]
Subject: [PATCH] printk: Rename console_replay_all() and update context

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: 693f75b91a91 ("printk: Add function to replay kernel log on consoles")
Fixes: 1b743485e27f ("tty/sysrq: Replay kernel log messages on consoles via sysrq")
Suggested-by: Petr Mladek <[email protected]>
Signed-off-by: Shimoyashiki Taichi <[email protected]>
Signed-off-by: Sreenath Vijayan <[email protected]>
---
drivers/tty/sysrq.c | 2 +-
include/linux/printk.h | 4 ++--
kernel/printk/printk.c | 6 +++---
3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index e5974b8239c9..53f8c2329c30 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -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,
diff --git a/include/linux/printk.h b/include/linux/printk.h
index 40afab23881a..ca4c9271daf6 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -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)
@@ -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
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 420fd310129d..ed003c06c335 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -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();
--
2.34.1



2024-05-31 08:49:18

by Petr Mladek

[permalink] [raw]
Subject: Re: [PATCH] printk: Rename console_replay_all() and update context

On Thu 2024-05-30 13:15:47, Sreenath Vijayan wrote:
> 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: 693f75b91a91 ("printk: Add function to replay kernel log on consoles")
> Fixes: 1b743485e27f ("tty/sysrq: Replay kernel log messages on consoles via sysrq")
> Suggested-by: Petr Mladek <[email protected]>
> Signed-off-by: Shimoyashiki Taichi <[email protected]>
> Signed-off-by: Sreenath Vijayan <[email protected]>

Thanks for the fix.

Reviewed-by: Petr Mladek <[email protected]>

Best Regards,
Petr

PS: I am going to queue it for 6.11. It is not critical
to hurry it into 6.10-rcX.

2024-06-04 08:09:28

by Petr Mladek

[permalink] [raw]
Subject: Re: [PATCH] printk: Rename console_replay_all() and update context

On Fri 2024-05-31 10:49:08, Petr Mladek wrote:
> On Thu 2024-05-30 13:15:47, Sreenath Vijayan wrote:
> > 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: 693f75b91a91 ("printk: Add function to replay kernel log on consoles")
> > Fixes: 1b743485e27f ("tty/sysrq: Replay kernel log messages on consoles via sysrq")
> > Suggested-by: Petr Mladek <[email protected]>
> > Signed-off-by: Shimoyashiki Taichi <[email protected]>
> > Signed-off-by: Sreenath Vijayan <[email protected]>
>
> Thanks for the fix.
>
> Reviewed-by: Petr Mladek <[email protected]>

> PS: I am going to queue it for 6.11. It is not critical
> to hurry it into 6.10-rcX.

JFYI, the patch has been comitted into printk/linux.git,
branch for-6.11.

BTW:

I have pushed a patch which came to my mailbox with ID

[email protected]

From some reasons, it is not available in the official archive
at lore.kernel.org. Instead, I have mentioned in the commit
message

https://lore.kernel.org/r/Zlguq/[email protected]@sony.com

which points to the same patch (same changes), exists at
lore.kernel.org but I havn't got that one from some reason.

Best Regards,
Petr

2024-06-06 06:51:27

by Sreenath Vijayan

[permalink] [raw]
Subject: Re: [PATCH] printk: Rename console_replay_all() and update context

On Tue, Jun 04, 2024 at 10:09:07AM +0200, Petr Mladek wrote:
> On Fri 2024-05-31 10:49:08, Petr Mladek wrote:
> > On Thu 2024-05-30 13:15:47, Sreenath Vijayan wrote:
> > > 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: 693f75b91a91 ("printk: Add function to replay kernel log on consoles")
> > > Fixes: 1b743485e27f ("tty/sysrq: Replay kernel log messages on consoles via sysrq")
> > > Suggested-by: Petr Mladek <[email protected]>
> > > Signed-off-by: Shimoyashiki Taichi <[email protected]>
> > > Signed-off-by: Sreenath Vijayan <[email protected]>
> >
> > Thanks for the fix.
> >
> > Reviewed-by: Petr Mladek <[email protected]>
>
> > PS: I am going to queue it for 6.11. It is not critical
> > to hurry it into 6.10-rcX.
>
> JFYI, the patch has been comitted into printk/linux.git,
> branch for-6.11.
>

Ok, thank you for the update.

> BTW:
>
> I have pushed a patch which came to my mailbox with ID
>
> [email protected]
>
> >From some reasons, it is not available in the official archive
> at lore.kernel.org. Instead, I have mentioned in the commit
> message
>
> https://lore.kernel.org/r/Zlguq/[email protected]@sony.com
>
> which points to the same patch (same changes), exists at
> lore.kernel.org but I havn't got that one from some reason.
>
> Best Regards,
> Petr

Understood.

Regards,
Sreenath