[2/2] reboot: flush printk buffers before final shutdown

Message ID 20231030092432.3434623-2-martin@geanix.com
State New
Headers
Series [1/2] printk: export pr_flush() |

Commit Message

Martin Hundebøll Oct. 30, 2023, 9:24 a.m. UTC
  Make sure printed messages are in fact printed before putting the system
down.

Signed-off-by: Martin Hundebøll <martin@geanix.com>
---
 kernel/reboot.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

John Ogness Oct. 31, 2023, 11:12 a.m. UTC | #1
On 2023-10-30, Martin Hundebøll <martin@geanix.com> wrote:
> Make sure printed messages are in fact printed before putting the system
> down.
>
> Signed-off-by: Martin Hundebøll <martin@geanix.com>
> ---
>  kernel/reboot.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/kernel/reboot.c b/kernel/reboot.c
> index 3bba88c7ffc6..bab8350d5dae 100644
> --- a/kernel/reboot.c
> +++ b/kernel/reboot.c
> @@ -273,6 +273,7 @@ void kernel_restart(char *cmd)
>  	else
>  		pr_emerg("Restarting system with command '%s'\n", cmd);
>  	kmsg_dump(KMSG_DUMP_SHUTDOWN);
> +	pr_flush(1000, false);

printk() tries to print directly from the calling context. Are you
experiencing problems where you do not see the restarting message?

John Ogness
  
John Ogness Oct. 31, 2023, 3:16 p.m. UTC | #2
On 2023-10-31, Martin Hundebøll <martin@geanix.com> wrote:
>> printk() tries to print directly from the calling context. Are you
>> experiencing problems where you do not see the restarting message?
>
> Yes, but only with rt-patches. Sorry I forgot to mention that in the
> commit message. I considered sending the patches to the "rt-tree", but
> figured they don't need more patches to maintain, when the same
> changes could live in mainline just as well.

Thanks for clarifying. These patches really are only appropriate for the
rt-tree.

John Ogness
  

Patch

diff --git a/kernel/reboot.c b/kernel/reboot.c
index 3bba88c7ffc6..bab8350d5dae 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -273,6 +273,7 @@  void kernel_restart(char *cmd)
 	else
 		pr_emerg("Restarting system with command '%s'\n", cmd);
 	kmsg_dump(KMSG_DUMP_SHUTDOWN);
+	pr_flush(1000, false);
 	machine_restart(cmd);
 }
 EXPORT_SYMBOL_GPL(kernel_restart);