From: John Ogness <john.ogness@linutronix.de>
To: takakura@valinux.co.jp, pmladek@suse.com
Cc: rostedt@goodmis.org, senozhatsky@chromium.org,
akpm@linux-foundation.org, bhe@redhat.com, lukas@wunner.de,
wangkefeng.wang@huawei.com, ubizjak@gmail.com,
feng.tang@intel.com, j.granados@samsung.com,
stephen.s.brennan@oracle.com, linux-kernel@vger.kernel.org,
nishimura@valinux.co.jp, taka@valinux.co.jp
Subject: Re: [PATCH] printk: CPU backtrace not printing on panic
Date: Mon, 29 Jul 2024 14:21:29 +0206 [thread overview]
Message-ID: <875xsofl7i.fsf@jogness.linutronix.de> (raw)
In-Reply-To: <20240729114601.176047-1-takakura@valinux.co.jp>
Hi Ryo,
On 2024-07-29, takakura@valinux.co.jp wrote:
> Or can we use cpu_sync for checking wheather non-panicked CPUs can
> write to ringbuffer and let nbcon_atomic_flush_pending() do the
> printing
Yes, I like this. Let the non-panic CPUs write their messages, but keep
the actual printing to the panic CPU.
Right after the call to panic_other_cpus_shutdown() we plan [0] on
calling printk_legacy_allow_panic_sync(), which will handle flushing the
legacy consoles.
> something like:
>
> ----- BEGIN -----
> diff --git a/kernel/panic.c b/kernel/panic.c
> index 7e207092576b..eed76e3e061b 100644
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
> @@ -252,8 +252,10 @@ void check_panic_on_warn(const char *origin)
> */
> static void panic_other_cpus_shutdown(bool crash_kexec)
> {
> - if (panic_print & PANIC_PRINT_ALL_CPU_BT)
> + if (panic_print & PANIC_PRINT_ALL_CPU_BT) {
> trigger_all_cpu_backtrace();
> + nbcon_atomic_flush_pending();
> + }
>
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index d0bff0b0abfd..b8132801ea07 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -2354,7 +2354,7 @@ asmlinkage int vprintk_emit(int facility, int level,
> * non-panic CPUs are generating any messages, they will be
> * silently dropped.
> */
> - if (other_cpu_in_panic())
> + if (other_cpu_in_panic() && !__printk_cpu_sync_owner())
> return 0;
>
> if (level == LOGLEVEL_SCHED) {
> @@ -4511,6 +4511,11 @@ void __printk_cpu_sync_wait(void)
> }
> EXPORT_SYMBOL(__printk_cpu_sync_wait);
>
> +bool __printk_cpu_sync_owner(void)
> +{
> + return (atomic_read(&printk_cpu_sync_owner) == raw_smp_processor_id());
> +}
> +
> ----- END -----
Note that printing on the non-panic CPUs is guaranteed for nbcon
consoles because of the other_cpu_in_panic() in
nbcon_context_try_acquire_direct() and for the legacy consoles because
the cpu_sync holder must defer printing [1].
I am curious what Petr has to say.
John
[0] https://lore.kernel.org/lkml/20240527063749.391035-26-john.ogness@linutronix.de
[1] https://lore.kernel.org/lkml/87plrcqyii.fsf@jogness.linutronix.de
next prev parent reply other threads:[~2024-07-29 12:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-26 9:44 [PATCH] printk: CPU backtrace not printing on panic takakura
2024-07-26 10:46 ` Petr Mladek
2024-07-26 13:56 ` John Ogness
2024-07-29 11:46 ` takakura
2024-07-29 12:15 ` John Ogness [this message]
2024-07-29 12:19 ` John Ogness
2024-07-30 12:14 ` Petr Mladek
2024-08-01 8:27 ` takakura
2024-08-01 11:12 ` Petr Mladek
2024-08-03 7:51 ` takakura
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=875xsofl7i.fsf@jogness.linutronix.de \
--to=john.ogness@linutronix.de \
--cc=akpm@linux-foundation.org \
--cc=bhe@redhat.com \
--cc=feng.tang@intel.com \
--cc=j.granados@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=nishimura@valinux.co.jp \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=stephen.s.brennan@oracle.com \
--cc=taka@valinux.co.jp \
--cc=takakura@valinux.co.jp \
--cc=ubizjak@gmail.com \
--cc=wangkefeng.wang@huawei.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox