when panic use prink_flush_buffer to dump printk_ringbuffer
RFC PATCH 1/1 when panic use prink_flush_buffer to dump printk_ringbuffer
From: wangyong <[email protected]>
echo c > proc/sysrq-trigger to trigger system panic, there is no debug information.
I think the reason is using printk_kthread_func, since panic will call local_irq_disable to disable interrupts, and then call smp_send_stop to stop other cpus, the printk thread probably is not waken up by irq_work and can't print messages during panic.
Using printk_flush_buffer to force flush printk_ringbuffer after all messages are added to printk_ringbuffer by printk.
Because printk_kthread_func may call console_lock and be blocked when cpus stop, so printk_flush_buffer does't call console_lock.
Signed-off-by wangyong <[email protected]>
--- include/linux/printk.h | 1 + kernel/panic.c | 2 + kernel/printk/printk.c | 99 ++++++++++++++++++++++++++++++++++++++------------ 3 files changed, 78 insertions(+), 24 deletions(-)
include/linux/printk.h +1 -0
@@ -193,6 +193,7 @@ void dump_stack_print_info(const char *log_lvl);void show_regs_print_info (const char *log_lvl); extern asmlinkage void dump_stack(void) __cold;struct wait_queue_head *printk_wait_queue (void ); +void printk_flush_buffer (void );#else static inline __printf(1, 0) int vprintk(const char *s, va_list args)
kernel/panic.c +2 -0
@@ -301,6 +301,7 @@ void panic(const char *fmt, ...)* We can't use the "normal" timers since we just panicked. */ pr_emerg ("Rebooting in %d seconds..\n" , panic_timeout); +printk_flush_buffer ();for (i =0 ; i < panic_timeout *1000 ; i +=PANIC_TIMER_STEP ) {touch_nmi_watchdog ();
@@ -334,6 +335,7 @@ void panic(const char *fmt, ...)disabled_wait ();#endif pr_emerg ("---[ end Kernel panic - not syncing: %s ]---\n" , buf); +printk_flush_buffer ();/* Do not scroll important messages printed above */ suppress_printk =1 ;
kernel/printk/printk.c +75 -24
133 lines not on this page · raw message
Signature · 1 line
2.15.2