From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: kexec@lists.infradead.org
Subject: [PATCH V6] panic: Move panic_print before kmsg dumpers
Date: Fri, 25 Feb 2022 14:18:22 +0900 [thread overview]
Message-ID: <YhhmnmgAlVCcVqSV@google.com> (raw)
In-Reply-To: <YheXRmmWr619Qxin@alley>
On (22/02/24 15:33), Petr Mladek wrote:
> > My bad! I did not spot the `return` at the end of the new branch.
> >
> > + if (console_flush) {
> > + if (panic_print & PANIC_PRINT_ALL_PRINTK_MSG)
> > + console_flush_on_panic(CONSOLE_REPLAY_ALL);
> > + return;
> > + }
> >
> > Hmm. Yeah, well, that's a bit of a tricky interface now
> >
> > panic()
> > // everything (if corresponding bits set), no console flush
> > panic_print_sys_info(false)
> > ...
> > // console flush only if corresponding bit set
> > panic_print_sys_info(true)
>
> I agree that self-explaining names are always better than true/false.
> It is pity that replay the log is handled in panic_print at all.
>
> I sometimes hide these tricks into wrappers. We could rename:
>
> panic_printk_sys_info() -> panic_print_handler()
>
> and add wrappers:
>
> void panic_print_sys_info()
> {
> panic_printk_handler(false);
> }
>
> void panic_print_log_replay()
> {
> panic_printk_handler(true);
> }
>
> Or just split panic_printk_sys_info() into these two functions.
Agreed. I also tend to think that panic_printk_sys_info() is needed anyway,
just because now we do
debug_locks_off();
console_flush_on_panic(CONSOLE_FLUSH_PENDING);
if (panic_print & PANIC_PRINT_ALL_PRINTK_MSG)
console_flush_on_panic(CONSOLE_REPLAY_ALL);
It probably would be better if we do
debug_locks_off();
if (panic_print & PANIC_PRINT_ALL_PRINTK_MSG)
console_flush_on_panic(CONSOLE_REPLAY_ALL);
else
console_flush_on_panic(CONSOLE_FLUSH_PENDING);
instead.
IOW move console_flush_on_panic() handling out of panic_print_sys_info().
console_flush_on_panic() isn't really related to "print sys info" stuff
that panic_print_sys_info() does.
Something like this may be:
---
static void panic_print_sys_info(void)
{
- if (panic_print & PANIC_PRINT_ALL_PRINTK_MSG)
- console_flush_on_panic(CONSOLE_REPLAY_ALL);
-
if (panic_print & PANIC_PRINT_ALL_CPU_BT)
trigger_all_cpu_backtrace();
@@ -196,6 +193,23 @@ static void panic_print_sys_info(void)
ftrace_dump(DUMP_ALL);
}
+static void panic_console_flush(void)
+{
+ /*
+ * We may have ended up stopping the CPU holding the lock (in
+ * smp_send_stop()) while still having some valuable data in the console
+ * buffer. Try to acquire the lock then release it regardless of the
+ * result. The release will also print the buffers out. Locks debug
+ * should be disabled to avoid reporting bad unlock balance when
+ * panic() is not being callled from OOPS.
+ */
+ debug_locks_off();
+ if (panic_print & PANIC_PRINT_ALL_PRINTK_MSG)
+ console_flush_on_panic(CONSOLE_REPLAY_ALL);
+ else
+ console_flush_on_panic(CONSOLE_FLUSH_PENDING);
+}
+
/**
* panic - halt the system
* @fmt: The text string to print
@@ -329,17 +343,7 @@ void panic(const char *fmt, ...)
#endif
console_unblank();
- /*
- * We may have ended up stopping the CPU holding the lock (in
- * smp_send_stop()) while still having some valuable data in the console
- * buffer. Try to acquire the lock then release it regardless of the
- * result. The release will also print the buffers out. Locks debug
- * should be disabled to avoid reporting bad unlock balance when
- * panic() is not being callled from OOPS.
- */
- debug_locks_off();
- console_flush_on_panic(CONSOLE_FLUSH_PENDING);
-
+ panic_console_flush();
panic_print_sys_info();
if (!panic_blink)
---
> > If everyone is fine then OK.
> >
> > But I _personally_ would look into changing this to something like this:
> >
> > #define EARLY_PANIC_MASK (PANIC_PRINT_FOO | PANIC_PRINT_BAR | ...)
> > #define LATE_PANIC_MASK (PANIC_PRINT_ALL_PRINTK_MSG)
>
> These lists cause merge and backporting conflicts. I vote to avoid
> this approach ;-)
OK :)
WARNING: multiple messages have this Message-ID (diff)
From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Petr Mladek <pmladek@suse.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
"Guilherme G. Piccoli" <gpiccoli@igalia.com>,
linux-kernel@vger.kernel.org, bhe@redhat.com,
akpm@linux-foundation.org, anton@enomsg.org, ccross@android.com,
dyoung@redhat.com, feng.tang@intel.com,
john.ogness@linutronix.de, keescook@chromium.org,
kernel@gpiccoli.net, kexec@lists.infradead.org,
rostedt@goodmis.org, tony.luck@intel.com, vgoyal@redhat.com
Subject: Re: [PATCH V6] panic: Move panic_print before kmsg dumpers
Date: Fri, 25 Feb 2022 14:18:22 +0900 [thread overview]
Message-ID: <YhhmnmgAlVCcVqSV@google.com> (raw)
In-Reply-To: <YheXRmmWr619Qxin@alley>
On (22/02/24 15:33), Petr Mladek wrote:
> > My bad! I did not spot the `return` at the end of the new branch.
> >
> > + if (console_flush) {
> > + if (panic_print & PANIC_PRINT_ALL_PRINTK_MSG)
> > + console_flush_on_panic(CONSOLE_REPLAY_ALL);
> > + return;
> > + }
> >
> > Hmm. Yeah, well, that's a bit of a tricky interface now
> >
> > panic()
> > // everything (if corresponding bits set), no console flush
> > panic_print_sys_info(false)
> > ...
> > // console flush only if corresponding bit set
> > panic_print_sys_info(true)
>
> I agree that self-explaining names are always better than true/false.
> It is pity that replay the log is handled in panic_print at all.
>
> I sometimes hide these tricks into wrappers. We could rename:
>
> panic_printk_sys_info() -> panic_print_handler()
>
> and add wrappers:
>
> void panic_print_sys_info()
> {
> panic_printk_handler(false);
> }
>
> void panic_print_log_replay()
> {
> panic_printk_handler(true);
> }
>
> Or just split panic_printk_sys_info() into these two functions.
Agreed. I also tend to think that panic_printk_sys_info() is needed anyway,
just because now we do
debug_locks_off();
console_flush_on_panic(CONSOLE_FLUSH_PENDING);
if (panic_print & PANIC_PRINT_ALL_PRINTK_MSG)
console_flush_on_panic(CONSOLE_REPLAY_ALL);
It probably would be better if we do
debug_locks_off();
if (panic_print & PANIC_PRINT_ALL_PRINTK_MSG)
console_flush_on_panic(CONSOLE_REPLAY_ALL);
else
console_flush_on_panic(CONSOLE_FLUSH_PENDING);
instead.
IOW move console_flush_on_panic() handling out of panic_print_sys_info().
console_flush_on_panic() isn't really related to "print sys info" stuff
that panic_print_sys_info() does.
Something like this may be:
---
static void panic_print_sys_info(void)
{
- if (panic_print & PANIC_PRINT_ALL_PRINTK_MSG)
- console_flush_on_panic(CONSOLE_REPLAY_ALL);
-
if (panic_print & PANIC_PRINT_ALL_CPU_BT)
trigger_all_cpu_backtrace();
@@ -196,6 +193,23 @@ static void panic_print_sys_info(void)
ftrace_dump(DUMP_ALL);
}
+static void panic_console_flush(void)
+{
+ /*
+ * We may have ended up stopping the CPU holding the lock (in
+ * smp_send_stop()) while still having some valuable data in the console
+ * buffer. Try to acquire the lock then release it regardless of the
+ * result. The release will also print the buffers out. Locks debug
+ * should be disabled to avoid reporting bad unlock balance when
+ * panic() is not being callled from OOPS.
+ */
+ debug_locks_off();
+ if (panic_print & PANIC_PRINT_ALL_PRINTK_MSG)
+ console_flush_on_panic(CONSOLE_REPLAY_ALL);
+ else
+ console_flush_on_panic(CONSOLE_FLUSH_PENDING);
+}
+
/**
* panic - halt the system
* @fmt: The text string to print
@@ -329,17 +343,7 @@ void panic(const char *fmt, ...)
#endif
console_unblank();
- /*
- * We may have ended up stopping the CPU holding the lock (in
- * smp_send_stop()) while still having some valuable data in the console
- * buffer. Try to acquire the lock then release it regardless of the
- * result. The release will also print the buffers out. Locks debug
- * should be disabled to avoid reporting bad unlock balance when
- * panic() is not being callled from OOPS.
- */
- debug_locks_off();
- console_flush_on_panic(CONSOLE_FLUSH_PENDING);
-
+ panic_console_flush();
panic_print_sys_info();
if (!panic_blink)
---
> > If everyone is fine then OK.
> >
> > But I _personally_ would look into changing this to something like this:
> >
> > #define EARLY_PANIC_MASK (PANIC_PRINT_FOO | PANIC_PRINT_BAR | ...)
> > #define LATE_PANIC_MASK (PANIC_PRINT_ALL_PRINTK_MSG)
>
> These lists cause merge and backporting conflicts. I vote to avoid
> this approach ;-)
OK :)
next prev parent reply other threads:[~2022-02-25 5:18 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-14 14:13 [PATCH V6] panic: Move panic_print before kmsg dumpers Guilherme G. Piccoli
2022-02-14 14:13 ` Guilherme G. Piccoli
2022-02-14 19:33 ` kernel test robot
2022-02-14 21:15 ` kernel test robot
2022-02-14 21:15 ` kernel test robot
2022-02-15 16:14 ` Petr Mladek
2022-02-15 16:14 ` Petr Mladek
2022-02-23 11:41 ` Sergey Senozhatsky
2022-02-23 11:41 ` Sergey Senozhatsky
2022-02-23 12:30 ` Guilherme G. Piccoli
2022-02-23 12:30 ` Guilherme G. Piccoli
2022-02-22 1:45 ` Sergey Senozhatsky
2022-02-22 1:45 ` Sergey Senozhatsky
2022-02-22 14:08 ` Guilherme G. Piccoli
2022-02-22 14:08 ` Guilherme G. Piccoli
2022-02-23 1:35 ` Sergey Senozhatsky
2022-02-23 1:35 ` Sergey Senozhatsky
2022-02-22 2:06 ` Sergey Senozhatsky
2022-02-22 2:06 ` Sergey Senozhatsky
2022-02-22 2:10 ` Sergey Senozhatsky
2022-02-22 2:10 ` Sergey Senozhatsky
2022-02-22 14:10 ` Guilherme G. Piccoli
2022-02-22 14:10 ` Guilherme G. Piccoli
2022-02-23 1:27 ` Sergey Senozhatsky
2022-02-23 1:27 ` Sergey Senozhatsky
2022-02-23 13:15 ` Guilherme G. Piccoli
2022-02-23 13:15 ` Guilherme G. Piccoli
2022-02-24 2:52 ` Sergey Senozhatsky
2022-02-24 2:52 ` Sergey Senozhatsky
2022-02-24 14:33 ` Petr Mladek
2022-02-24 14:33 ` Petr Mladek
2022-02-24 14:45 ` Guilherme G. Piccoli
2022-02-24 14:45 ` Guilherme G. Piccoli
2022-02-25 5:18 ` Sergey Senozhatsky [this message]
2022-02-25 5:18 ` Sergey Senozhatsky
2022-02-25 5:23 ` Sergey Senozhatsky
2022-02-25 5:23 ` Sergey Senozhatsky
2022-02-25 12:16 ` Petr Mladek
2022-02-25 12:16 ` Petr Mladek
2022-02-26 2:23 ` Sergey Senozhatsky
2022-02-26 2:23 ` Sergey Senozhatsky
2022-02-28 12:33 ` Guilherme G. Piccoli
2022-02-28 12:33 ` Guilherme G. Piccoli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YhhmnmgAlVCcVqSV@google.com \
--to=senozhatsky@chromium.org \
--cc=kexec@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.