All of lore.kernel.org
 help / color / mirror / Atom feed
* + panic-move-panic_print-before-kmsg-dumpers.patch added to -mm tree
@ 2022-02-28 18:50 Andrew Morton
  2022-03-23 14:23 ` Guilherme G. Piccoli
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2022-02-28 18:50 UTC (permalink / raw)
  To: mm-commits, senozhatsky, pmladek, feng.tang, bhe, gpiccoli, akpm


The patch titled
     Subject: panic: move panic_print before kmsg dumpers
has been added to the -mm tree.  Its filename is
     panic-move-panic_print-before-kmsg-dumpers.patch

This patch should soon appear at
    https://ozlabs.org/~akpm/mmots/broken-out/panic-move-panic_print-before-kmsg-dumpers.patch
and later at
    https://ozlabs.org/~akpm/mmotm/broken-out/panic-move-panic_print-before-kmsg-dumpers.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
Subject: panic: move panic_print before kmsg dumpers

The panic_print s\x10etting allows users to collect more information in a
panic event, like memory stats, tasks, CPUs backtraces, etc.
This is an interesting debug mechanism, but currently the print event
happens *after* kmsg_dump(), meaning that pstore, for example, cannot
collect a dmesg with the panic_print extra information.

This patch changes that in 2 steps:

(a) The panic_print setting allows to replay the existing kernel log
    buffer to the console (bit 5), besides the extra information dump. 
    This functionality makes sense only at the end of the panic()
    function.  So, we hereby allow to distinguish the two situations by a
    new boolean parameter in the function panic_print_sys_info().

(b) With the above change, we can safely call panic_print_sys_info()
    before kmsg_dump(), allowing to dump the extra information when using
    pstore or other kmsg dumpers.

The additional messages from panic_print could overwrite the oldest
messages when the buffer is full.  The only reasonable solution is to use
a large enough log buffer, hence we added an advice into the kernel
parameters documentation about that.

Link: https://lkml.kernel.org/r/20220214141308.841525-1-gpiccoli@igalia.com
Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
Acked-by: Baoquan He <bhe@redhat.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Feng Tang <feng.tang@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 Documentation/admin-guide/kernel-parameters.txt |    4 ++++
 kernel/panic.c                                  |   13 +++++++++----
 2 files changed, 13 insertions(+), 4 deletions(-)

--- a/Documentation/admin-guide/kernel-parameters.txt~panic-move-panic_print-before-kmsg-dumpers
+++ a/Documentation/admin-guide/kernel-parameters.txt
@@ -3727,6 +3727,10 @@
 			bit 4: print ftrace buffer
 			bit 5: print all printk messages in buffer
 			bit 6: print all CPUs backtrace (if available in the arch)
+			*Be aware* that this option may print a _lot_ of lines,
+			so there are risks of losing older messages in the log.
+			Use this option carefully, maybe worth to setup a
+			bigger log buffer with "log_buf_len" along with this.
 
 	panic_on_taint=	Bitmask for conditionally calling panic() in add_taint()
 			Format: <hex>[,nousertaint]
--- a/kernel/panic.c~panic-move-panic_print-before-kmsg-dumpers
+++ a/kernel/panic.c
@@ -148,10 +148,13 @@ void nmi_panic(struct pt_regs *regs, con
 }
 EXPORT_SYMBOL(nmi_panic);
 
-static void panic_print_sys_info(void)
+static void panic_print_sys_info(bool console_flush)
 {
-	if (panic_print & PANIC_PRINT_ALL_PRINTK_MSG)
-		console_flush_on_panic(CONSOLE_REPLAY_ALL);
+	if (console_flush) {
+		if (panic_print & PANIC_PRINT_ALL_PRINTK_MSG)
+			console_flush_on_panic(CONSOLE_REPLAY_ALL);
+		return;
+	}
 
 	if (panic_print & PANIC_PRINT_ALL_CPU_BT)
 		trigger_all_cpu_backtrace();
@@ -286,6 +289,8 @@ void panic(const char *fmt, ...)
 	 */
 	atomic_notifier_call_chain(&panic_notifier_list, 0, buf);
 
+	panic_print_sys_info(false);
+
 	kmsg_dump(KMSG_DUMP_PANIC);
 
 	/*
@@ -316,7 +321,7 @@ void panic(const char *fmt, ...)
 	debug_locks_off();
 	console_flush_on_panic(CONSOLE_FLUSH_PENDING);
 
-	panic_print_sys_info();
+	panic_print_sys_info(true);
 
 	if (!panic_blink)
 		panic_blink = no_blink;
_

Patches currently in -mm which might be from gpiccoli@igalia.com are

docs-sysctl-kernel-add-missing-bit-to-panic_print.patch
panic-add-option-to-dump-all-cpus-backtraces-in-panic_print.patch
panic-move-panic_print-before-kmsg-dumpers.patch


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: + panic-move-panic_print-before-kmsg-dumpers.patch added to -mm tree
  2022-02-28 18:50 + panic-move-panic_print-before-kmsg-dumpers.patch added to -mm tree Andrew Morton
@ 2022-03-23 14:23 ` Guilherme G. Piccoli
  2022-03-23 16:28   ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Guilherme G. Piccoli @ 2022-03-23 14:23 UTC (permalink / raw)
  To: Andrew Morton; +Cc: mm-commits, bhe, feng.tang, pmladek, senozhatsky

On 28/02/2022 15:50, Andrew Morton wrote:
> The patch titled
>      Subject: panic: move panic_print before kmsg dumpers
> has been added to the -mm tree.  Its filename is
>      panic-move-panic_print-before-kmsg-dumpers.patch
> 
> This patch should soon appear at
>     https://ozlabs.org/~akpm/mmots/broken-out/panic-move-panic_print-before-kmsg-dumpers.patch
> and later at
>     https://ozlabs.org/~akpm/mmotm/broken-out/panic-move-panic_print-before-kmsg-dumpers.patch
> 
> Before you just go and hit "reply", please:
>    a) Consider who else should be cc'ed
>    b) Prefer to cc a suitable mailing list as well
>    c) Ideally: find the original patch on the mailing list and do a
>       reply-to-all to that, adding suitable additional cc's
> 

Hi Andrew, I'd like to ask you if it's possible to merge this patch (and
also [0]) for 5.18. I've checked Linus tree as for today and it's not
there, I hope there is still time.

Thanks in advance,


Guilherme


[0]
https://ozlabs.org/~akpm/mmotm/broken-out/panic-add-option-to-dump-all-cpus-backtraces-in-panic_print.patch

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: + panic-move-panic_print-before-kmsg-dumpers.patch added to -mm tree
  2022-03-23 14:23 ` Guilherme G. Piccoli
@ 2022-03-23 16:28   ` Andrew Morton
  2022-03-23 18:14     ` Guilherme G. Piccoli
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2022-03-23 16:28 UTC (permalink / raw)
  To: Guilherme G. Piccoli; +Cc: mm-commits, bhe, feng.tang, pmladek, senozhatsky

On Wed, 23 Mar 2022 11:23:39 -0300 "Guilherme G. Piccoli" <gpiccoli@igalia.com> wrote:

> On 28/02/2022 15:50, Andrew Morton wrote:
> > The patch titled
> >      Subject: panic: move panic_print before kmsg dumpers
> > has been added to the -mm tree.  Its filename is
> >      panic-move-panic_print-before-kmsg-dumpers.patch
> > 
> > This patch should soon appear at
> >     https://ozlabs.org/~akpm/mmots/broken-out/panic-move-panic_print-before-kmsg-dumpers.patch
> > and later at
> >     https://ozlabs.org/~akpm/mmotm/broken-out/panic-move-panic_print-before-kmsg-dumpers.patch
> > 
> > Before you just go and hit "reply", please:
> >    a) Consider who else should be cc'ed
> >    b) Prefer to cc a suitable mailing list as well
> >    c) Ideally: find the original patch on the mailing list and do a
> >       reply-to-all to that, adding suitable additional cc's
> > 
> 
> Hi Andrew, I'd like to ask you if it's possible to merge this patch (and
> also [0]) for 5.18. I've checked Linus tree as for today and it's not
> there, I hope there is still time.
> 

Yes, it's in the queue.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: + panic-move-panic_print-before-kmsg-dumpers.patch added to -mm tree
  2022-03-23 16:28   ` Andrew Morton
@ 2022-03-23 18:14     ` Guilherme G. Piccoli
  0 siblings, 0 replies; 4+ messages in thread
From: Guilherme G. Piccoli @ 2022-03-23 18:14 UTC (permalink / raw)
  To: Andrew Morton; +Cc: mm-commits, bhe, feng.tang, pmladek, senozhatsky

On 23/03/2022 13:28, Andrew Morton wrote:
> On Wed, 23 Mar 2022 11:23:39 -0300 "Guilherme G. Piccoli" <gpiccoli@igalia.com> wrote:
> [...] 
>> Hi Andrew, I'd like to ask you if it's possible to merge this patch (and
>> also [0]) for 5.18. I've checked Linus tree as for today and it's not
>> there, I hope there is still time.
>>
> 
> Yes, it's in the queue.

Thanks a lot, much appreciated!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-03-23 18:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-28 18:50 + panic-move-panic_print-before-kmsg-dumpers.patch added to -mm tree Andrew Morton
2022-03-23 14:23 ` Guilherme G. Piccoli
2022-03-23 16:28   ` Andrew Morton
2022-03-23 18:14     ` Guilherme G. Piccoli

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.