* [PATCH 1/2] printk: export pr_flush()
@ 2023-10-30 9:24 Martin Hundebøll
2023-10-30 9:24 ` [PATCH 2/2] reboot: flush printk buffers before final shutdown Martin Hundebøll
2023-10-31 11:03 ` [PATCH 1/2] printk: export pr_flush() John Ogness
0 siblings, 2 replies; 5+ messages in thread
From: Martin Hundebøll @ 2023-10-30 9:24 UTC (permalink / raw)
To: Petr Mladek
Cc: Steven Rostedt, John Ogness, Sergey Senozhatsky, linux-kernel,
Martin Hundebøll
Printk users might want to assure whatever printed has reached its
destination before continuing. E.g. during the shutdown-procedure, where
printk-buffers aren't necessarily emptied before the system goes down.
Signed-off-by: Martin Hundebøll <martin@geanix.com>
---
include/linux/printk.h | 5 +++++
kernel/printk/printk.c | 4 +---
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/include/linux/printk.h b/include/linux/printk.h
index 8ef499ab3c1e..a2a33494c222 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -192,6 +192,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);
+bool pr_flush(int timeout_ms, bool reset_on_progress);
#else
static inline __printf(1, 0)
int vprintk(const char *s, va_list args)
@@ -271,6 +272,10 @@ static inline void dump_stack(void)
static inline void printk_trigger_flush(void)
{
}
+static inline bool pr_flush(int timeout_ms, bool reset_on_progress)
+{
+ return true;
+}
#endif
#ifdef CONFIG_SMP
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 0b3af1529778..dc1d2c880eb0 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2336,7 +2336,6 @@ asmlinkage __visible int _printk(const char *fmt, ...)
}
EXPORT_SYMBOL(_printk);
-static bool pr_flush(int timeout_ms, bool reset_on_progress);
static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progress);
#else /* CONFIG_PRINTK */
@@ -2365,7 +2364,6 @@ static ssize_t msg_print_ext_body(char *buf, size_t size,
static void console_lock_spinning_enable(void) { }
static int console_lock_spinning_disable_and_check(int cookie) { return 0; }
static bool suppress_message_printing(int level) { return false; }
-static bool pr_flush(int timeout_ms, bool reset_on_progress) { return true; }
static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progress) { return true; }
#endif /* CONFIG_PRINTK */
@@ -3813,7 +3811,7 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
* Context: Process context. May sleep while acquiring console lock.
* Return: true if all usable printers are caught up.
*/
-static bool pr_flush(int timeout_ms, bool reset_on_progress)
+bool pr_flush(int timeout_ms, bool reset_on_progress)
{
return __pr_flush(NULL, timeout_ms, reset_on_progress);
}
--
2.42.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] reboot: flush printk buffers before final shutdown
2023-10-30 9:24 [PATCH 1/2] printk: export pr_flush() Martin Hundebøll
@ 2023-10-30 9:24 ` Martin Hundebøll
2023-10-31 11:12 ` John Ogness
2023-10-31 11:03 ` [PATCH 1/2] printk: export pr_flush() John Ogness
1 sibling, 1 reply; 5+ messages in thread
From: Martin Hundebøll @ 2023-10-30 9:24 UTC (permalink / raw)
To: Petr Mladek
Cc: Steven Rostedt, John Ogness, Sergey Senozhatsky, linux-kernel,
Martin Hundebøll
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);
machine_restart(cmd);
}
EXPORT_SYMBOL_GPL(kernel_restart);
--
2.42.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] printk: export pr_flush()
2023-10-30 9:24 [PATCH 1/2] printk: export pr_flush() Martin Hundebøll
2023-10-30 9:24 ` [PATCH 2/2] reboot: flush printk buffers before final shutdown Martin Hundebøll
@ 2023-10-31 11:03 ` John Ogness
1 sibling, 0 replies; 5+ messages in thread
From: John Ogness @ 2023-10-31 11:03 UTC (permalink / raw)
To: Martin Hundebøll, Petr Mladek
Cc: Steven Rostedt, Sergey Senozhatsky, linux-kernel,
Martin Hundebøll
On 2023-10-30, Martin Hundebøll <martin@geanix.com> wrote:
> Printk users might want to assure whatever printed has reached its
> destination before continuing. E.g. during the shutdown-procedure, where
> printk-buffers aren't necessarily emptied before the system goes down.
This is reverting:
commit c60ba2d34608 ("printk: Make pr_flush() static")
I agree that it should be exported at some point, but we need to have
outside users.
John Ogness
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] reboot: flush printk buffers before final shutdown
2023-10-30 9:24 ` [PATCH 2/2] reboot: flush printk buffers before final shutdown Martin Hundebøll
@ 2023-10-31 11:12 ` John Ogness
[not found] ` <8e31147e-f727-4354-8644-a4ff4b1431a4@geanix.com>
0 siblings, 1 reply; 5+ messages in thread
From: John Ogness @ 2023-10-31 11:12 UTC (permalink / raw)
To: Martin Hundebøll, Petr Mladek
Cc: Steven Rostedt, Sergey Senozhatsky, linux-kernel,
Martin Hundebøll
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] reboot: flush printk buffers before final shutdown
[not found] ` <8e31147e-f727-4354-8644-a4ff4b1431a4@geanix.com>
@ 2023-10-31 15:16 ` John Ogness
0 siblings, 0 replies; 5+ messages in thread
From: John Ogness @ 2023-10-31 15:16 UTC (permalink / raw)
To: Martin Hundebøll
Cc: Petr Mladek, Steven Rostedt, Sergey Senozhatsky, linux-kernel
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-10-31 15:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-30 9:24 [PATCH 1/2] printk: export pr_flush() Martin Hundebøll
2023-10-30 9:24 ` [PATCH 2/2] reboot: flush printk buffers before final shutdown Martin Hundebøll
2023-10-31 11:12 ` John Ogness
[not found] ` <8e31147e-f727-4354-8644-a4ff4b1431a4@geanix.com>
2023-10-31 15:16 ` John Ogness
2023-10-31 11:03 ` [PATCH 1/2] printk: export pr_flush() John Ogness
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox