panic: add an option to replay all the printk message in buffer
Subsystems (4)
PATCH v2 1/1 panic: add an option to replay all the printk message in buffer
Currently on panic, kernel will lower the loglevel and print out new printk msg only with console_flush_on_panic().
Add an option for users to configure the "panic_print" to see all dmesg in buffer, some of which they may have never seen due to the loglevel setting, which will help debugging too.
Thanks to Petr Mladek as somes codes come directly from the sample code in his review comments.
---
Changelog:
v2:
- Add a new func in printk.c dedicated for the replaying, as suggested by Petr Mladekand
- Combine the 2 patches in v1 into one suggested by both Petr and Sergey
Documentation/admin-guide/kernel-parameters.txt | 1 + include/linux/console.h | 1 + kernel/panic.c | 5 +++ kernel/printk/printk.c | 46 ++++++++++++++++++++----- 4 files changed, 44 insertions(+), 9 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +1 -0
@@ -3135,6 +3135,7 @@ bit 2: print timer info bit 3: print locks info if CONFIG_LOCKDEP is on bit 4: print ftrace buffer + bit 5: print all printk messages in buffer panic_on_warn panic() instead of WARN(). Useful to cause kdump on a WARN().
include/linux/console.h +1 -0
@@ -176,6 +176,7 @@ extern void console_unlock(void);extern void console_conditional_schedule (void );extern void console_unblank (void );extern void console_flush_on_panic (void ); +extern void console_replay_on_panic (void );extern struct tty_driver *console_device (int *);extern void console_stop (struct console *);extern void console_start (struct console *);
kernel/panic.c +5 -0
@@ -51,6 +51,7 @@ EXPORT_SYMBOL_GPL(panic_timeout);#define PANIC_PRINT_TIMER_INFO 0x00000004#define PANIC_PRINT_LOCK_INFO 0x00000008#define PANIC_PRINT_FTRACE_INFO 0x00000010 +#define PANIC_PRINT_ALL_PRINTK_MSG 0x00000020unsigned long panic_print;ATOMIC_NOTIFIER_HEAD (panic_notifier_list);
@@ -134,6 +135,10 @@ EXPORT_SYMBOL(nmi_panic);static void panic_print_sys_info (void ) { +/* Replay existing messages before adding other sys info. */ +if (panic_print &PANIC_PRINT_ALL_PRINTK_MSG ) +console_replay_on_panic (); +if (panic_print &PANIC_PRINT_TASK_INFO )show_state ();
kernel/printk/printk.c +37 -9
85 lines not on this page · raw message
Signature · 1 line
2.14.1
Quoted 9 lines · On Wed, 10 Apr 2019 23:37:18 +0800 Feng Tang <[email protected]> wrote:
Currently on panic, kernel will lower the loglevel and print out new printk msg only with
console_flush_on_panic().Add an option for users to configure the "
panic_print" to see all dmesg in buffer, some of which they may have never seen due to the loglevel setting, which will help debugging too.Thanks to Petr Mladek as somes codes come directly from the sample code in his review comments.
CONFIG_PRINTK=n:
kernel/printk/printk.c: In function console_unlock:kernel/printk/printk.c:2419:11: warning: __builtin_memcpy writing 27 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=]
len += sprintf(text + len,
^~~~~~~~~~~~~~~~~~~
"Replaying the entire log:\n");
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~because LOG_LINE_MAX=0 and PREFIX_MAX=0.
Which is interesting. The pre-existing
len = sprintf(text,
"** %llu printk messages dropped **\n", log_first_seq - console_seq);
in console_unlock() has the same issue, but the compiler doesn't seem to want to warn.
(Also, using sprintf() is a bit lame for the new message - could use strlcpy()).
I'll drop the patch for now - we don't want that warning to come out. console_unlock() needs some fixing for the CONFIG_PRINTK=n case.
Hi Andrew,
Quoted 14 lines · Andrew Morton
Quoted 9 lines · On Wed, 10 Apr 2019 23:37:18 +0800 Feng Tang <[email protected]> wrote:
Currently on panic, kernel will lower the loglevel and print out new printk msg only with
console_flush_on_panic().Add an option for users to configure the "
panic_print" to see all dmesg in buffer, some of which they may have never seen due to the loglevel setting, which will help debugging too.Thanks to Petr Mladek as somes codes come directly from the sample code in his review comments.
CONFIG_PRINTK=n:
Quoted 8 lines
kernel/printk/printk.c: In functionconsole_unlock:kernel/printk/printk.c:2419:11: warning:__builtin_memcpywriting 27 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=]len += sprintf(text + len, ^~~~~~~~~~~~~~~~~~~ "Replaying the entire log:\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~because LOG_LINE_MAX=0 and PREFIX_MAX=0.
Thanks for catching this!
Quoted 10 lines
Which is interesting. The pre-existing
len = sprintf(text,
"** %llu printk messages dropped **\n",log_first_seq-console_seq);in
console_unlock()has the same issue, but the compiler doesn't seem to want to warn.
For this one, I did some check, and it should be related with the conditional check
if (console_seq < log_first_seq) {Both the console_seq and log_first_seq will not be touched by any code when CONFIG_PRINTK=n, and compiler will simply skip the whole code block, as "console_seq < log_first_seq" will never happen.
But code block following "if (console_replay)" will be compiled, that's why these warning message will be shown.
Quoted 6 lines
(Also, using
sprintf()is a bit lame for the new message - could usestrlcpy()).I'll drop the patch for now - we don't want that warning to come out.
console_unlock()needs some fixing for theCONFIG_PRINTK=ncase.
My instant thought would be put the console_unlcok() and similar funcs under CONFIG_PRINTK protection, while adding nop functions in the "else" segment.
But complexer question will be when CONFIG_PRINTK=n, how those console_xxx functions should consider these to make compiled binary smaller (though it rarely happens). would wait for Petr/Sergey/Steven's insights.
Thanks,
Feng
Petr Mladek
maintainerQuoted 57 lines · Feng Tang
Hi Andrew,
Quoted 14 lines · Andrew Morton
Quoted 9 lines · On Wed, 10 Apr 2019 23:37:18 +0800 Feng Tang <[email protected]> wrote:
Currently on panic, kernel will lower the loglevel and print out new printk msg only with
console_flush_on_panic().Add an option for users to configure the "
panic_print" to see all dmesg in buffer, some of which they may have never seen due to the loglevel setting, which will help debugging too.Thanks to Petr Mladek as somes codes come directly from the sample code in his review comments.
CONFIG_PRINTK=n:Quoted 8 lines
kernel/printk/printk.c: In functionconsole_unlock:kernel/printk/printk.c:2419:11: warning:__builtin_memcpywriting 27 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=]len += sprintf(text + len, ^~~~~~~~~~~~~~~~~~~ "Replaying the entire log:\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~because LOG_LINE_MAX=0 and PREFIX_MAX=0.
Thanks for catching this!
Quoted 10 lines
Which is interesting. The pre-existing
len = sprintf(text,
"** %llu printk messages dropped **\n",log_first_seq-console_seq);in
console_unlock()has the same issue, but the compiler doesn't seem to want to warn.For this one, I did some check, and it should be related with the conditional check
if (console_seq < log_first_seq) {Both the
console_seqandlog_first_seqwill not be touched by any code whenCONFIG_PRINTK=n, and compiler will simply skip the whole code block, as "console_seq<log_first_seq" will never happen.But code block following "if (
console_replay)" will be compiled, that's why these warning message will be shown.Quoted 6 lines
(Also, using
sprintf()is a bit lame for the new message - could usestrlcpy()).I'll drop the patch for now - we don't want that warning to come out.
console_unlock()needs some fixing for theCONFIG_PRINTK=ncase.
Quoted 7 lines
My instant thought would be put the
console_unlcok()and similar funcs underCONFIG_PRINTKprotection, while adding nop functions in the "else" segment.But complexer question will be when
CONFIG_PRINTK=n, how thoseconsole_xxxfunctions should consider these to make compiled binary smaller (though it rarely happens). would wait for Petr/Sergey/Steven's insights.
I guess that it is because console_sem is historically used to synchronize some unrelated things, espcially in tty code. Unfortunately, it is not easy to clean this up.
For this patch, the best solution seems to be using scnprintf() instead of sprintf().
Please, note the difference between snprintf() and scnprintf(). We need the "scn*" variant the returns the number of really printed characters.
Best Regards,
Petr
Quoted 8 lines · Petr Mladek
Quoted 7 lines
My instant thought would be put the
console_unlcok()and similar funcs underCONFIG_PRINTKprotection, while adding nop functions in the "else" segment.But complexer question will be when
CONFIG_PRINTK=n, how thoseconsole_xxxfunctions should consider these to make compiled binary smaller (though it rarely happens). would wait for Petr/Sergey/Steven's insights.
Quoted 6 lines
I guess that it is because
console_semis historically used to synchronize some unrelated things, espcially in tty code. Unfortunately, it is not easy to clean this up.For this patch, the best solution seems to be using
scnprintf()instead ofsprintf().
OK, since we have another chance to re-iterate this. Do we really want to complicate console_unlock() printing loop any further? Asking off chance, can we return back to the idea of adding enum FLUSH_PENDING/FLUSH_ALL to console_flush_on_panic()?
Does not look too complex/ugly.
---
-void console_flush_on_panic(void)
+void console_flush_on_panic(enum console_flush_mode flush_mode)
{
/*
* If someone else is holding the console lock, trylock will fail
@@ -2549,6 +2549,10 @@ void console_flush_on_panic(void)
*/
console_trylock();
console_may_schedule = 0;
+ if (flush_mode == FLUSH_ALL) {
+ console_seq = log_first_seq;
+ console_idx = log_first_idx;
+ }
console_unlock();
}
---
-ss
Quoted 2 lines · Sergey Senozhatsky
Does not look too complex/ugly.
Looks simpler than adding one more global state to the console_unlock() printing loop.
// Not tested at all //
---
arch/powerpc/kernel/traps.c +1 -1
@@ -179,7 +179,7 @@ extern void panic_flush_kmsg_end(void)kmsg_dump (KMSG_DUMP_PANIC );bust_spinlocks (0 );debug_locks_off (); -console_flush_on_panic (); +console_flush_on_panic (CONSOLE_FLUSH_PENDING ); }static unsigned long oops_begin (struct pt_regs *regs)
include/linux/console.h +7 -1
@@ -175,7 +175,13 @@ extern int console_trylock(void);extern void console_unlock (void );extern void console_conditional_schedule (void );extern void console_unblank (void ); -extern void console_flush_on_panic (void ); + +enum console_flush_mode { +CONSOLE_FLUSH_PENDING , +CONSOLE_FLUSH_ALL , +}; + +extern void console_flush_on_panic (enum console_flush_mode flush_mode);extern struct tty_driver *console_device (int *);extern void console_stop (struct console *);extern void console_start (struct console *);
kernel/panic.c +5 -1
@@ -51,6 +51,7 @@ EXPORT_SYMBOL_GPL(panic_timeout);#define PANIC_PRINT_TIMER_INFO 0x00000004#define PANIC_PRINT_LOCK_INFO 0x00000008#define PANIC_PRINT_FTRACE_INFO 0x00000010 +#define PANIC_PRINT_ALL_PRINTK_MSG 0x00000020unsigned long panic_print;ATOMIC_NOTIFIER_HEAD (panic_notifier_list);
@@ -148,6 +149,9 @@ static void panic_print_sys_info(void)if (panic_print &PANIC_PRINT_FTRACE_INFO )ftrace_dump (DUMP_ALL ); + +if (panic_print &PANIC_PRINT_ALL_PRINTK_MSG ) +console_flush_on_panic (CONSOLE_FLUSH_ALL ); }/**
@@ -277,7 +281,7 @@ void panic(const char *fmt, ...)* panic() is not being callled from OOPS. */ debug_locks_off (); -console_flush_on_panic (); +console_flush_on_panic (CONSOLE_FLUSH_PENDING );panic_print_sys_info ();
kernel/printk/printk.c +9 -1
@@ -2538,7 +2538,7 @@ void console_unblank(void)* * Immediately output all pending messages no matter what. */ -void console_flush_on_panic (void ) +void console_flush_on_panic (enum console_flush_mode flush_mode) {/* * If someone else is holding the console lock, trylock will fail
@@ -2549,6 +2549,14 @@ void console_flush_on_panic(void)*/ console_trylock (); console_may_schedule =0 ; +if (flush_mode ==CONSOLE_FLUSH_ALL ) { +/* +* Can be done under logbuf lock, but it's unlikely that +* we will have any race conditions here. +*/ + console_seq = log_first_seq; + console_idx = log_first_idx; + }console_unlock (); }
---
Petr Mladek
maintainerQuoted 22 lines · Sergey Senozhatsky
Quoted 2 lines · Sergey Senozhatsky
Does not look too complex/ugly.
Looks simpler than adding one more global state to the
console_unlock()printing loop.// Not tested at all //
kernel/panic.c +1
-0@@ -51,6 +51,7 @@ EXPORT_SYMBOL_GPL(panic_timeout);#define PANIC_PRINT_TIMER_INFO 0x00000004#define PANIC_PRINT_LOCK_INFO 0x00000008#define PANIC_PRINT_FTRACE_INFO 0x00000010 +#define PANIC_PRINT_ALL_PRINTK_MSG 0x00000020unsigned long panic_print;ATOMIC_NOTIFIER_HEAD (panic_notifier_list);
kernel/panic.c static void panic_print_sys_info(void) · line 154
Quoted 6 lines
kernel/panic.c +3
-0@@ -148,6 +149,9 @@ static void panic_print_sys_info(void)if (panic_print &PANIC_PRINT_FTRACE_INFO )ftrace_dump (DUMP_ALL ); + +if (panic_print &PANIC_PRINT_ALL_PRINTK_MSG ) +console_flush_on_panic (CONSOLE_FLUSH_ALL );
The console must be replayed as the first thing in panic_print_sys_info(). Otherwise, the original messages are replaced by the other dumps. Especially ftrace_dump() might be pretty long.
Also the names of the function and the parameter are misleading. All messages are already flushed when this is called.
Quoted 8 lines
kernel/panic.c +0
-0}/** kernel/printk/printk.c +0
-0
kernel/printk/printk.c void console_flush_on_panic(void) · line 2558
Quoted 10 lines
kernel/printk/printk.c +7
-0@@ -2549,6 +2549,14 @@ void console_flush_on_panic(void)*/ console_trylock (); console_may_schedule =0 ; +if (flush_mode ==CONSOLE_FLUSH_ALL ) { +/* +* Can be done under logbuf lock, but it's unlikely that +* we will have any race conditions here. +*/ + console_seq = log_first_seq; + console_idx = log_first_idx;
I agree that it is easier. The cost is that the same messages are printed again without any explanation.
I still think that it would be convenient to write a header line. It would help to understand the log for any, even 3rd-party, reader. Also it would help to find the beginning in a very long log.
If the complexity of console_unlock() is the concern, we could refactor the code, e.g. put this "reset log" code into a separate function.
Best Regards,
Petr
Quoted 40 lines · Petr Mladek
Quoted 22 lines · Sergey Senozhatsky
Quoted 2 lines · Sergey Senozhatsky
Does not look too complex/ugly.
Looks simpler than adding one more global state to the
console_unlock()printing loop.// Not tested at all //
kernel/panic.c +1
-0@@ -51,6 +51,7 @@ EXPORT_SYMBOL_GPL(panic_timeout);#define PANIC_PRINT_TIMER_INFO 0x00000004#define PANIC_PRINT_LOCK_INFO 0x00000008#define PANIC_PRINT_FTRACE_INFO 0x00000010 +#define PANIC_PRINT_ALL_PRINTK_MSG 0x00000020unsigned long panic_print;ATOMIC_NOTIFIER_HEAD (panic_notifier_list);kernel/panic.c static void panic_print_sys_info(void) · line 154
Quoted 6 lines
kernel/panic.c +3
-0@@ -148,6 +149,9 @@ static void panic_print_sys_info(void)if (panic_print &PANIC_PRINT_FTRACE_INFO )ftrace_dump (DUMP_ALL ); + +if (panic_print &PANIC_PRINT_ALL_PRINTK_MSG ) +console_flush_on_panic (CONSOLE_FLUSH_ALL );The console must be replayed as the first thing in
panic_print_sys_info(). Otherwise, the original messages are replaced by the other dumps. Especiallyftrace_dump()might be pretty long.Also the names of the function and the parameter are misleading. All messages are already flushed when this is called.
Quoted 2 lines
kernel/panic.c +0
-0}
Quoted 16 lines
Quoted 6 lines
kernel/panic.c +0
-0/** kernel/printk/printk.c +0
-0kernel/printk/printk.c void console_flush_on_panic(void) · line 2558
Quoted 10 lines
kernel/printk/printk.c +7
-0@@ -2549,6 +2549,14 @@ void console_flush_on_panic(void)*/ console_trylock (); console_may_schedule =0 ; +if (flush_mode ==CONSOLE_FLUSH_ALL ) { +/* +* Can be done under logbuf lock, but it's unlikely that +* we will have any race conditions here. +*/ + console_seq = log_first_seq; + console_idx = log_first_idx;
This is very similar to my V1 patch :), excepted I used a bool as the parameter.
Quoted 7 lines
I agree that it is easier. The cost is that the same messages are printed again without any explanation.
I still think that it would be convenient to write a header line. It would help to understand the log for any, even 3rd-party, reader. Also it would help to find the beginning in a very long log.
My thought is, the replay is only a debug option and disabled by default, so when user specifically enable the bit of PANIC_PRINT_ALL_PRINTK_MSG, the whole replay of printk msg should be expected.
Thanks,
Feng
Quoted 7 lines
If the complexity of
console_unlock()is the concern, we could refactor the code, e.g. put this "reset log" code into a separate function.Best Regards,
Petr
Quoted 7 lines · Feng Tang
Quoted 7 lines
Quoted 7 lines
+++
b/kernel/printk/printk.ckernel/printk/printk.c +2
-0@@ -2549,6 +2549,14 @@ void console_flush_on_panic(void)*/ console_trylock (); console_may_schedule =0 ; +if (flush_mode ==CONSOLE_FLUSH_ALL ) { +/*
Quoted 8 lines
Quoted 5 lines
kernel/printk/printk.c void console_flush_on_panic(void) · line 2558
Quoted 5 lines
kernel/printk/printk.c +5
-0+* Can be done under logbuf lock, but it's unlikely that +* we will have any race conditions here. +*/ + console_seq = log_first_seq; + console_idx = log_first_idx;This is very similar to my V1 patch :), excepted I used a bool as the parameter.
Yes it is :)
I will reply to Petr's and Feng's email.
Quoted 10 lines
Quoted 6 lines
I agree that it is easier. The cost is that the same messages are printed again without any explanation.
I still think that it would be convenient to write a header line. It would help to understand the log for any, even 3rd-party, reader. Also it would help to find the beginning in a very long log.
My thought is, the replay is only a debug option and disabled by default, so when user specifically enable the bit of
PANIC_PRINT_ALL_PRINTK_MSG, the whole replay of printk msg should be expected.
I think that PANIC_PRINT_ALL_PRINTK_MSG is a debugging option; a quite specific one. So people who ask the kernel to PANIC_PRINT_ALL_PRINTK_MSG they know what they are doing, and we probably will not cofuse anyone. After all, we don't print any headers when we ftrace_dump() or imitate sysrq via sysrq_timer_list_show(), or for any other panic_print_sys_info() printouts. So it's OK to just do the simple thing for PANIC_PRINT_ALL_PRINTK_MSG.
-ss
Petr Mladek
maintainerQuoted 7 lines · Sergey Senozhatsky
I think that
PANIC_PRINT_ALL_PRINTK_MSGis a debugging option; a quite specific one. So people who ask the kernel toPANIC_PRINT_ALL_PRINTK_MSGthey know what they are doing, and we probably will not cofuse anyone. After all, we don't print any headers when weftrace_dump()or imitate sysrq viasysrq_timer_list_show(), or for any otherpanic_print_sys_info()printouts. So it's OK to just do the simple thing forPANIC_PRINT_ALL_PRINTK_MSG.
The following functions are currently called from panic_print_sys_info():
+ show_state():
printk(KERN_INFO
" task PC stack pid father\n");
+ show_mem():
printk("Mem-Info:\n");+ sysrq_timer_list_show()
no global header; but each section can be easily distinguished because there are several static strings that explains the content
+ debug_show_all_locks()
pr_warn("\nShowing all locks held in the system:\n");+ ftrace_dump():
printk(KERN_TRACE "Dumping ftrace buffer:\n");
The person that enabled the debugging option might know what it did when it process the log the very same day. It might be less clear for others reading the log.
Also it still might be convenient to find the beginning easily. Or it might help to orientate when several test runs (over night test) are squashed in a single file. I see such logs pretty often.
That said, I do not resist on it.
Best Regards,
Petr
Hi Petr,
Quoted 29 lines · Petr Mladek
Quoted 7 lines · Sergey Senozhatsky
I think that
PANIC_PRINT_ALL_PRINTK_MSGis a debugging option; a quite specific one. So people who ask the kernel toPANIC_PRINT_ALL_PRINTK_MSGthey know what they are doing, and we probably will not cofuse anyone. After all, we don't print any headers when weftrace_dump()or imitate sysrq viasysrq_timer_list_show(), or for any otherpanic_print_sys_info()printouts. So it's OK to just do the simple thing forPANIC_PRINT_ALL_PRINTK_MSG.The following functions are currently called from
panic_print_sys_info():+
show_state():printk(KERN_INFO " task PC stack pid father\n"); + show_mem(): printk("Mem-Info:\n");+
sysrq_timer_list_show()
no global header; but each section can be easily distinguished because there are several static strings that explains the content+
debug_show_all_locks()pr_warn("\nShowing all locks held in the system:\n");+
ftrace_dump():printk(KERN_TRACE "Dumping ftrace buffer:\n");
Quoted 8 lines
The person that enabled the debugging option might know what it did when it process the log the very same day. It might be less clear for others reading the log.
Also it still might be convenient to find the beginning easily. Or it might help to orientate when several test runs (over night test) are squashed in a single file. I see such logs pretty often.
Thanks for checking all the info. For the note, how about adding something like this inside panic_print_sys_info()?
if (panic_print & PANIC_PRINT_ALL_PRINTK_MSG) {
printk("\nprintk: will replay all the messages in buffer:\n");
console_flush_on_panic(CONSOLE_FLUSH_ALL);
}If you are all fine with it, I'll go post a v3, thanks,
- Feng
Quoted 5 lines
That said, I do not resist on it.
Best Regards,
Petr
Petr Mladek
maintainerQuoted 41 lines · Feng Tang
Hi Petr,
Quoted 29 lines · Petr Mladek
Quoted 7 lines · Sergey Senozhatsky
I think that
PANIC_PRINT_ALL_PRINTK_MSGis a debugging option; a quite specific one. So people who ask the kernel toPANIC_PRINT_ALL_PRINTK_MSGthey know what they are doing, and we probably will not cofuse anyone. After all, we don't print any headers when weftrace_dump()or imitate sysrq viasysrq_timer_list_show(), or for any otherpanic_print_sys_info()printouts. So it's OK to just do the simple thing forPANIC_PRINT_ALL_PRINTK_MSG.The following functions are currently called from
panic_print_sys_info():+
show_state():printk(KERN_INFO " task PC stack pid father\n"); + show_mem(): printk("Mem-Info:\n");+
sysrq_timer_list_show()
no global header; but each section can be easily distinguished because there are several static strings that explains the content+
debug_show_all_locks()pr_warn("\nShowing all locks held in the system:\n");+
ftrace_dump():printk(KERN_TRACE "Dumping ftrace buffer:\n");Quoted 8 lines
The person that enabled the debugging option might know what it did when it process the log the very same day. It might be less clear for others reading the log.
Also it still might be convenient to find the beginning easily. Or it might help to orientate when several test runs (over night test) are squashed in a single file. I see such logs pretty often.
Quoted 7 lines
Thanks for checking all the info. For the note, how about adding something like this inside
panic_print_sys_info()?if (panic_print & PANIC_PRINT_ALL_PRINTK_MSG) { printk("\nprintk: will replay all the messages in buffer:\n"); console_flush_on_panic(CONSOLE_FLUSH_ALL); }
This will store the message at the end of the buffer. It will repeat the message once again when replaying the log. I personally think that it is worse than printing nothing.
Quoted 1 line
If you are all fine with it, I'll go post a v3, thanks,
I suggest to wait few days. We might get opinion from someone else...
Then sent whatever approach makes most sense to you. In fact, you are the 3rd person in this triangle. I believe that we will respect it. Last many mails are just a bike shedding.
Just one thing. Please, use "replay" in the function or parameter name. The effect of console_flush_on_panic(CONSOLE_FLUSH_ALL) is really hard to guess from the name.
Best Regards,
Petr
Quoted 45 lines · Petr Mladek
Quoted 44 lines · Feng Tang
Hi Petr,
Quoted 29 lines · Petr Mladek
Quoted 7 lines · Sergey Senozhatsky
I think that
PANIC_PRINT_ALL_PRINTK_MSGis a debugging option; a quite specific one. So people who ask the kernel toPANIC_PRINT_ALL_PRINTK_MSGthey know what they are doing, and we probably will not cofuse anyone. After all, we don't print any headers when weftrace_dump()or imitate sysrq viasysrq_timer_list_show(), or for any otherpanic_print_sys_info()printouts. So it's OK to just do the simple thing forPANIC_PRINT_ALL_PRINTK_MSG.The following functions are currently called from
panic_print_sys_info():+
show_state():printk(KERN_INFO " task PC stack pid father\n"); + show_mem(): printk("Mem-Info:\n");+
sysrq_timer_list_show()
no global header; but each section can be easily distinguished because there are several static strings that explains the content+
debug_show_all_locks()pr_warn("\nShowing all locks held in the system:\n");+
ftrace_dump():printk(KERN_TRACE "Dumping ftrace buffer:\n");Quoted 8 lines
The person that enabled the debugging option might know what it did when it process the log the very same day. It might be less clear for others reading the log.
Also it still might be convenient to find the beginning easily. Or it might help to orientate when several test runs (over night test) are squashed in a single file. I see such logs pretty often.
Thanks for checking all the info. For the note, how about adding something like this inside
panic_print_sys_info()?
Quoted 8 lines
Quoted 4 lines
if (panic_print & PANIC_PRINT_ALL_PRINTK_MSG) { printk("\nprintk: will replay all the messages in buffer:\n"); console_flush_on_panic(CONSOLE_FLUSH_ALL); }This will store the message at the end of the buffer. It will repeat the message once again when replaying the log. I personally think that it is worse than printing nothing.
Got it :)
Quoted 7 lines
Quoted 3 lines
If you are all fine with it, I'll go post a v3, thanks,
I suggest to wait few days. We might get opinion from someone else...
Quoted 7 lines
Then sent whatever approach makes most sense to you. In fact, you are the 3rd person in this triangle. I believe that we will respect it. Last many mails are just a bike shedding.
Just one thing. Please, use "replay" in the function or parameter name. The effect of
console_flush_on_panic(CONSOLE_FLUSH_ALL)is really hard to guess from the name.
Ok. thanks
- Feng
Quoted 13 lines · Petr Mladek
The following functions are currently called from
panic_print_sys_info():+
show_state():printk(KERN_INFO " task PC stack pid father\n"); + show_mem(): printk("Mem-Info:\n");+
sysrq_timer_list_show()
no global header; but each section can be easily distinguished because there are several static strings that explains the content
Quoted 5 lines
+
debug_show_all_locks()pr_warn("\nShowing all locks held in the system:\n");+
ftrace_dump():printk(KERN_TRACE "Dumping ftrace buffer:\n");
Oh, thanks.
Quoted 8 lines
The person that enabled the debugging option might know what it did when it process the log the very same day. It might be less clear for others reading the log.
Also it still might be convenient to find the beginning easily. Or it might help to orientate when several test runs (over night test) are squashed in a single file. I see such logs pretty often.
OK, well since we are talking here about serial log, then we probably can just add printk("dump logbuf:\n"). It will appear before the FLUSH_ALL output. Or we can just tweak panic code a bit - anything panic_print_sys_info() prints can be "after" end of panic marker.
Basically, just move pr_emerg("---[ end Kernel panic...") a bit. I don't quite understand why is it at the bottom - we don't always print end of panic maker, e.g. when panic_timeout != 0. Not sure if this was intentional.
---
kernel/panic.c +1 -1
@@ -282,6 +282,7 @@ void panic(const char *fmt, ...)*/ debug_locks_off ();console_flush_on_panic (CONSOLE_FLUSH_PENDING ); +pr_emerg ("---[ end Kernel panic - not syncing: %s ]---\n" , buf);panic_print_sys_info ();
@@ -331,7 +332,6 @@ void panic(const char *fmt, ...) disabled_wait(caller); }#endif -pr_emerg ("---[ end Kernel panic - not syncing: %s ]---\n" , buf);/* Do not scroll important messages printed above */ suppress_printk =1 ;
---
-ss