Skip to content

Commit 6ea9a17

Browse files
paulmckrcufbq
authored andcommitted
Flush console log from kernel_power_off()
Kernels built with CONFIG_PREEMPT_RT=y can lose significant console output and shutdown time, which hides shutdown-time RCU issues from rcutorture. Therefore, make pr_flush() public and invoke it after then last print in kernel_power_off(). [ paulmck: Apply John Ogness feedback. ] [ paulmck: Appy Sebastian Andrzej Siewior feedback. ] [ paulmck: Apply kernel test robot feedback. ] Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Reviewed-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Petr Mladek <pmladek@suse.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Sergey Senozhatsky <senozhatsky@chromium.org> Link: https://lore.kernel.org/r/5f743488-dc2a-4f19-bdda-cf50b9314832@paulmck-laptop Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
1 parent 59bed79 commit 6ea9a17

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

include/linux/printk.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ void printk_legacy_allow_panic_sync(void);
207207
extern bool nbcon_device_try_acquire(struct console *con);
208208
extern void nbcon_device_release(struct console *con);
209209
void nbcon_atomic_flush_unsafe(void);
210+
bool pr_flush(int timeout_ms, bool reset_on_progress);
210211
#else
211212
static inline __printf(1, 0)
212213
int vprintk(const char *s, va_list args)
@@ -315,6 +316,11 @@ static inline void nbcon_atomic_flush_unsafe(void)
315316
{
316317
}
317318

319+
static inline bool pr_flush(int timeout_ms, bool reset_on_progress)
320+
{
321+
return true;
322+
}
323+
318324
#endif
319325

320326
bool this_cpu_in_panic(void);

kernel/printk/printk.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2461,7 +2461,6 @@ asmlinkage __visible int _printk(const char *fmt, ...)
24612461
}
24622462
EXPORT_SYMBOL(_printk);
24632463

2464-
static bool pr_flush(int timeout_ms, bool reset_on_progress);
24652464
static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progress);
24662465

24672466
#else /* CONFIG_PRINTK */
@@ -2474,7 +2473,6 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
24742473

24752474
static u64 syslog_seq;
24762475

2477-
static bool pr_flush(int timeout_ms, bool reset_on_progress) { return true; }
24782476
static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progress) { return true; }
24792477

24802478
#endif /* CONFIG_PRINTK */
@@ -4466,7 +4464,7 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
44664464
* Context: Process context. May sleep while acquiring console lock.
44674465
* Return: true if all usable printers are caught up.
44684466
*/
4469-
static bool pr_flush(int timeout_ms, bool reset_on_progress)
4467+
bool pr_flush(int timeout_ms, bool reset_on_progress)
44704468
{
44714469
return __pr_flush(NULL, timeout_ms, reset_on_progress);
44724470
}

kernel/reboot.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,7 @@ void kernel_power_off(void)
704704
migrate_to_reboot_cpu();
705705
syscore_shutdown();
706706
pr_emerg("Power down\n");
707+
pr_flush(1000, true);
707708
kmsg_dump(KMSG_DUMP_SHUTDOWN);
708709
machine_power_off();
709710
}

0 commit comments

Comments
 (0)