* Re: [linux-next:master] [serial] d353934702: BUG:kernel_reboot-without-warning_in_test_stage
2026-09-23 13:14 ` Petr Mladek
@ 2026-09-23 15:37 ` John Ogness
2026-09-24 13:10 ` John Ogness
2026-09-23 15:59 ` Bradley Morgan
2026-10-20 6:34 ` kernel test robot
2 siblings, 1 reply; 8+ messages in thread
From: John Ogness @ 2026-09-23 15:37 UTC (permalink / raw)
To: Petr Mladek
Cc: kernel test robot, oe-lkp, lkp, Greg Kroah-Hartman, linux-serial,
Sergey Senozhatsky, Steven Rostedt
On 2026-09-23, Petr Mladek <pmladek@suse.com> wrote:
> The above patch handles only emergency_restart(). The similar problem
> would be even in other code paths where the system is going down.
> I think about using NBCON_EMERGENCY_PRIO automatically in all
> these states, something like:
>
> diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
> index d17704fe93ae..48446926dc50 100644
> --- a/kernel/printk/nbcon.c
> +++ b/kernel/printk/nbcon.c
> @@ -1446,6 +1446,10 @@ enum nbcon_prio nbcon_get_default_prio(void)
> if (panic_on_this_cpu())
> return NBCON_PRIO_PANIC;
>
> + /* Do not rely on kthreads when the system is going down. */
> + if (system_state > SYSTEM_RUNNING)
> + return NBCON_PRIO_EMERGENCY;
> +
> cpu_emergency_nesting = nbcon_get_cpu_emergency_nesting();
> if (*cpu_emergency_nesting)
> return NBCON_PRIO_EMERGENCY;
> diff --git a/kernel/reboot.c b/kernel/reboot.c
> index d177d89fcc33..776784a82499 100644
> --- a/kernel/reboot.c
> +++ b/kernel/reboot.c
> @@ -8,6 +8,7 @@
> #define pr_fmt(fmt) "reboot: " fmt
>
> #include <linux/atomic.h>
> +#include <linux/console.h>
> #include <linux/ctype.h>
> #include <linux/export.h>
> #include <linux/kexec.h>
> @@ -94,6 +95,7 @@ void emergency_restart(void)
> {
> kmsg_dump(KMSG_DUMP_EMERG);
> system_state = SYSTEM_RESTART;
> + printk_trigger_flush();
> machine_emergency_restart();
> }
> EXPORT_SYMBOL_GPL(emergency_restart);
> @@ -102,6 +104,7 @@ void kernel_restart_prepare(char *cmd)
> {
> blocking_notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd);
> system_state = SYSTEM_RESTART;
> + printk_trigger_flush();
> usermodehelper_disable();
> device_shutdown();
> }
> @@ -305,6 +308,7 @@ static void kernel_shutdown_prepare(enum system_states state)
> blocking_notifier_call_chain(&reboot_notifier_list,
> (state == SYSTEM_HALT) ? SYS_HALT : SYS_POWER_OFF, NULL);
> system_state = state;
> + printk_trigger_flush();
> usermodehelper_disable();
> device_shutdown();
> }
>
> Note that it would use NBCON_EMERGENCY_PRIO even in SYSTEM_SUSPEND
> state. But I think that it does not have any real effect because
> it seems to be done after the consoles are suspended. at least
> in hibernation_platform_enter().
And we transition to atomic printing for suspend anyway if
"no_console_suspend" is specified.
I am OK with this change. My only concern is that it is best effort. If
some of these callbacks are always called from task context, using an
_additional_ pr_flush() might make sense.
John
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [linux-next:master] [serial] d353934702: BUG:kernel_reboot-without-warning_in_test_stage
2026-09-23 15:37 ` John Ogness
@ 2026-09-24 13:10 ` John Ogness
0 siblings, 0 replies; 8+ messages in thread
From: John Ogness @ 2026-09-24 13:10 UTC (permalink / raw)
To: Petr Mladek
Cc: kernel test robot, oe-lkp, lkp, Greg Kroah-Hartman, linux-serial,
Sergey Senozhatsky, Steven Rostedt
Hi Petr,
On 2026-09-23, John Ogness <john.ogness@linutronix.de> wrote:
>> diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
>> index d17704fe93ae..48446926dc50 100644
>> --- a/kernel/printk/nbcon.c
>> +++ b/kernel/printk/nbcon.c
>> @@ -1446,6 +1446,10 @@ enum nbcon_prio nbcon_get_default_prio(void)
>> if (panic_on_this_cpu())
>> return NBCON_PRIO_PANIC;
>>
>> + /* Do not rely on kthreads when the system is going down. */
>> + if (system_state > SYSTEM_RUNNING)
>> + return NBCON_PRIO_EMERGENCY;
>> +
>> cpu_emergency_nesting = nbcon_get_cpu_emergency_nesting();
>> if (*cpu_emergency_nesting)
>> return NBCON_PRIO_EMERGENCY;
>> diff --git a/kernel/reboot.c b/kernel/reboot.c
>> index d177d89fcc33..776784a82499 100644
>> --- a/kernel/reboot.c
>> +++ b/kernel/reboot.c
>> @@ -8,6 +8,7 @@
>> #define pr_fmt(fmt) "reboot: " fmt
>>
>> #include <linux/atomic.h>
>> +#include <linux/console.h>
>> #include <linux/ctype.h>
>> #include <linux/export.h>
>> #include <linux/kexec.h>
>> @@ -94,6 +95,7 @@ void emergency_restart(void)
>> {
>> kmsg_dump(KMSG_DUMP_EMERG);
>> system_state = SYSTEM_RESTART;
>> + printk_trigger_flush();
>> machine_emergency_restart();
>> }
>> EXPORT_SYMBOL_GPL(emergency_restart);
>> @@ -102,6 +104,7 @@ void kernel_restart_prepare(char *cmd)
>> {
>> blocking_notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd);
>> system_state = SYSTEM_RESTART;
>> + printk_trigger_flush();
>> usermodehelper_disable();
>> device_shutdown();
>> }
>> @@ -305,6 +308,7 @@ static void kernel_shutdown_prepare(enum system_states state)
>> blocking_notifier_call_chain(&reboot_notifier_list,
>> (state == SYSTEM_HALT) ? SYS_HALT : SYS_POWER_OFF, NULL);
>> system_state = state;
>> + printk_trigger_flush();
>> usermodehelper_disable();
>> device_shutdown();
>> }
>
> I am OK with this change.
If you want to roll this into an official patch:
Reviewed-by: John Ogness <john.ogness@linutronix.de>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [linux-next:master] [serial] d353934702: BUG:kernel_reboot-without-warning_in_test_stage
2026-09-23 13:14 ` Petr Mladek
2026-09-23 15:37 ` John Ogness
@ 2026-09-23 15:59 ` Bradley Morgan
2026-10-20 6:34 ` kernel test robot
2 siblings, 0 replies; 8+ messages in thread
From: Bradley Morgan @ 2026-09-23 15:59 UTC (permalink / raw)
To: pmladek
Cc: gregkh, john.ogness, linux-serial, lkp, oe-lkp, oliver.sang,
rostedt, senozhatsky
On 23 September 2026 14:14:40 BST, Petr Mladek <pmladek@suse.com> wrote:
>On Wed 2026-09-23 12:47:22, John Ogness wrote:
>> (Added printk folks To/Cc.)
>>
>> Hi Oliver,
>>
>> On 2026-08-06, kernel test robot <oliver.sang@intel.com> wrote:
>> > similar to
>> > https://lore.kernel.org/all/202602271552.c972ef9e-lkp@intel.com/
>> > we still found we have kernel_reboot-without-warning_in_test_stage by
>this
>> > change in our tests.
>> >
>> > hard for us to understand the connection, and we cannot capture more
>useful
>> > information from serail. just report FYI what we observed in our
>tests.
>> >
>> >
>> > kernel test robot noticed
>"BUG:kernel_reboot-without-warning_in_test_stage" on:
>> >
>> > commit: d3539347022ad4eeb9dbd29c50bfca17b9d8a146 ("serial: 8250:
>Switch to nbcon console, take 2")
>> > https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git
>master
>> >
>> > in testcase: boot
>> >
>> > config: i386-randconfig-2006-20250825
>> > compiler: gcc-14
>> > test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2
>-m 32G
>> >
>> > (please refer to attached dmesg/kmsg for entire log/backtrace)
>> >
>> >
>> > If you fix the issue in a separate patch/commit (i.e. not just a new
>version of
>> > the same patch/commit), kindly add following tags
>> > | Reported-by: kernel test robot <oliver.sang@intel.com>
>> > | Closes:
>https://lore.kernel.org/oe-lkp/202608061008.48a1e76e-lkp@intel.com
>> >
>> >
>> >
>> > [ 65.107802][ T272] INFO: lkp CACHE_DIR is /tmp/cache
>> > [ 65.107809][ T272]
>> > BUG: kernel reboot-without-warning in test stage
>> >
>> >
>> >
>> > The kernel config and materials to reproduce are available at:
>> >
>https://download.01.org/0day-ci/archive/20260806/202608061008.48a1e76e-lkp@intel.com
>>
>> This problem is because the kernel buffer is not flushed before
>> performing the sysrq-triggered emergency restart. The following patch
>> sort of addresses this:
>>
>> ----- BEGIN RFC PATCH -----
>> diff --git a/kernel/reboot.c b/kernel/reboot.c
>> index 695c33e75efd9..5d1ff39b21f90 100644
>> --- a/kernel/reboot.c
>> +++ b/kernel/reboot.c
>> @@ -8,6 +8,7 @@
>> #define pr_fmt(fmt) "reboot: " fmt
>>
>> #include <linux/atomic.h>
>> +#include <linux/console.h>
>> #include <linux/ctype.h>
>> #include <linux/export.h>
>> #include <linux/kexec.h>
>> @@ -92,8 +93,11 @@ static BLOCKING_NOTIFIER_HEAD(reboot_notifier_list);
>> void emergency_restart(void)
>> {
>> kmsg_dump(KMSG_DUMP_EMERG);
>> + nbcon_cpu_emergency_enter();
>> + printk_trigger_flush();
>> system_state = SYSTEM_RESTART;
>> machine_emergency_restart();
>> + nbcon_cpu_emergency_exit();
>> }
>> EXPORT_SYMBOL_GPL(emergency_restart);
>>
>> ----- END RFC PATCH -----
>>
>> @pmladek:
>>
>> It is necessary to put the CPU into an emergency state, otherwise atomic
>> printing will not be used. This is kind of a best effort, as opposed to
>> panic() where eventually unsafe flushes are attempted. So if the sysrq-b
>> is triggered while another CPU is printing to the console, the user
>> still might not see any of the pending messages on reset.
>>
>> Any comments from your side on this?
>
>I think that it is a reasonable approach in principle.
>
>The above patch handles only emergency_restart(). The similar problem
>would be even in other code paths where the system is going down.
>I think about using NBCON_EMERGENCY_PRIO automatically in all
>these states, something like:
>
>diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
>index d17704fe93ae..48446926dc50 100644
>--- a/kernel/printk/nbcon.c
>+++ b/kernel/printk/nbcon.c
>@@ -1446,6 +1446,10 @@ enum nbcon_prio nbcon_get_default_prio(void)
> if (panic_on_this_cpu())
> return NBCON_PRIO_PANIC;
>
>+ /* Do not rely on kthreads when the system is going down. */
>+ if (system_state > SYSTEM_RUNNING)
>+ return NBCON_PRIO_EMERGENCY;
>+
> cpu_emergency_nesting = nbcon_get_cpu_emergency_nesting();
> if (*cpu_emergency_nesting)
> return NBCON_PRIO_EMERGENCY;
>diff --git a/kernel/reboot.c b/kernel/reboot.c
>index d177d89fcc33..776784a82499 100644
>--- a/kernel/reboot.c
>+++ b/kernel/reboot.c
>@@ -8,6 +8,7 @@
> #define pr_fmt(fmt) "reboot: " fmt
>
> #include <linux/atomic.h>
>+#include <linux/console.h>
> #include <linux/ctype.h>
> #include <linux/export.h>
> #include <linux/kexec.h>
>@@ -94,6 +95,7 @@ void emergency_restart(void)
> {
> kmsg_dump(KMSG_DUMP_EMERG);
> system_state = SYSTEM_RESTART;
>+ printk_trigger_flush();
> machine_emergency_restart();
> }
> EXPORT_SYMBOL_GPL(emergency_restart);
>@@ -102,6 +104,7 @@ void kernel_restart_prepare(char *cmd)
> {
> blocking_notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd);
> system_state = SYSTEM_RESTART;
>+ printk_trigger_flush();
> usermodehelper_disable();
> device_shutdown();
> }
>@@ -305,6 +308,7 @@ static void kernel_shutdown_prepare(enum system_states state)
> blocking_notifier_call_chain(&reboot_notifier_list,
> (state == SYSTEM_HALT) ? SYS_HALT : SYS_POWER_OFF, NULL);
> system_state = state;
>+ printk_trigger_flush();
> usermodehelper_disable();
> device_shutdown();
> }
>
Hmm.... this is ok?
Reviewed-by: Bradley Morgan <brads@mainlining.org> (this review was based on correctness :D)
>Note that it would use NBCON_EMERGENCY_PRIO even in SYSTEM_SUSPEND
>state. But I think that it does not have any real effect because
>it seems to be done after the consoles are suspended. at least
>in hibernation_platform_enter().
>
>Best Regards,
>Petr
>
>
--- Thanks!
"I'm not a very positive person" - Linus torvalds
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [linux-next:master] [serial] d353934702: BUG:kernel_reboot-without-warning_in_test_stage
2026-09-23 13:14 ` Petr Mladek
2026-09-23 15:37 ` John Ogness
2026-09-23 15:59 ` Bradley Morgan
@ 2026-10-20 6:34 ` kernel test robot
2026-10-20 7:27 ` John Ogness
2 siblings, 1 reply; 8+ messages in thread
From: kernel test robot @ 2026-10-20 6:34 UTC (permalink / raw)
To: Petr Mladek
Cc: John Ogness, kernel test robot, oe-lkp, lkp, Greg Kroah-Hartman,
linux-serial, Sergey Senozhatsky, Steven Rostedt
On Wed, Sep 23, 2026 at 03:14:40PM +0200, Petr Mladek wrote:
> On Wed 2026-09-23 12:47:22, John Ogness wrote:
> > (Added printk folks To/Cc.)
> >
> > Hi Oliver,
> >
> > On 2026-08-06, kernel test robot <oliver.sang@intel.com> wrote:
> > > similar to
> > > https://lore.kernel.org/all/202602271552.c972ef9e-lkp@intel.com/
> > > we still found we have kernel_reboot-without-warning_in_test_stage by this
> > > change in our tests.
> > >
> > > hard for us to understand the connection, and we cannot capture more useful
> > > information from serail. just report FYI what we observed in our tests.
> > >
> > >
> > > kernel test robot noticed "BUG:kernel_reboot-without-warning_in_test_stage" on:
> > >
> > > commit: d3539347022ad4eeb9dbd29c50bfca17b9d8a146 ("serial: 8250: Switch to nbcon console, take 2")
> > > https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git master
> > >
> > > in testcase: boot
> > >
> > > config: i386-randconfig-2006-20250825
> > > compiler: gcc-14
> > > test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 32G
> > >
> > > (please refer to attached dmesg/kmsg for entire log/backtrace)
> > >
> > >
> > > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > > the same patch/commit), kindly add following tags
> > > | Reported-by: kernel test robot <oliver.sang@intel.com>
> > > | Closes: https://lore.kernel.org/oe-lkp/202608061008.48a1e76e-lkp@intel.com
> > >
> > >
> > >
> > > [ 65.107802][ T272] INFO: lkp CACHE_DIR is /tmp/cache
> > > [ 65.107809][ T272]
> > > BUG: kernel reboot-without-warning in test stage
> > >
> > >
> > >
> > > The kernel config and materials to reproduce are available at:
> > > https://download.01.org/0day-ci/archive/20260806/202608061008.48a1e76e-lkp@intel.com
> >
> > This problem is because the kernel buffer is not flushed before
> > performing the sysrq-triggered emergency restart. The following patch
> > sort of addresses this:
> >
> > ----- BEGIN RFC PATCH -----
> > diff --git a/kernel/reboot.c b/kernel/reboot.c
> > index 695c33e75efd9..5d1ff39b21f90 100644
> > --- a/kernel/reboot.c
> > +++ b/kernel/reboot.c
> > @@ -8,6 +8,7 @@
> > #define pr_fmt(fmt) "reboot: " fmt
> >
> > #include <linux/atomic.h>
> > +#include <linux/console.h>
> > #include <linux/ctype.h>
> > #include <linux/export.h>
> > #include <linux/kexec.h>
> > @@ -92,8 +93,11 @@ static BLOCKING_NOTIFIER_HEAD(reboot_notifier_list);
> > void emergency_restart(void)
> > {
> > kmsg_dump(KMSG_DUMP_EMERG);
> > + nbcon_cpu_emergency_enter();
> > + printk_trigger_flush();
> > system_state = SYSTEM_RESTART;
> > machine_emergency_restart();
> > + nbcon_cpu_emergency_exit();
> > }
> > EXPORT_SYMBOL_GPL(emergency_restart);
> >
> > ----- END RFC PATCH -----
> >
> > @pmladek:
> >
> > It is necessary to put the CPU into an emergency state, otherwise atomic
> > printing will not be used. This is kind of a best effort, as opposed to
> > panic() where eventually unsafe flushes are attempted. So if the sysrq-b
> > is triggered while another CPU is printing to the console, the user
> > still might not see any of the pending messages on reset.
> >
> > Any comments from your side on this?
>
> I think that it is a reasonable approach in principle.
>
> The above patch handles only emergency_restart(). The similar problem
> would be even in other code paths where the system is going down.
> I think about using NBCON_EMERGENCY_PRIO automatically in all
> these states, something like:
>
> diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
> index d17704fe93ae..48446926dc50 100644
> --- a/kernel/printk/nbcon.c
> +++ b/kernel/printk/nbcon.c
> @@ -1446,6 +1446,10 @@ enum nbcon_prio nbcon_get_default_prio(void)
> if (panic_on_this_cpu())
> return NBCON_PRIO_PANIC;
>
> + /* Do not rely on kthreads when the system is going down. */
> + if (system_state > SYSTEM_RUNNING)
> + return NBCON_PRIO_EMERGENCY;
> +
> cpu_emergency_nesting = nbcon_get_cpu_emergency_nesting();
> if (*cpu_emergency_nesting)
> return NBCON_PRIO_EMERGENCY;
> diff --git a/kernel/reboot.c b/kernel/reboot.c
> index d177d89fcc33..776784a82499 100644
> --- a/kernel/reboot.c
> +++ b/kernel/reboot.c
> @@ -8,6 +8,7 @@
> #define pr_fmt(fmt) "reboot: " fmt
>
> #include <linux/atomic.h>
> +#include <linux/console.h>
> #include <linux/ctype.h>
> #include <linux/export.h>
> #include <linux/kexec.h>
> @@ -94,6 +95,7 @@ void emergency_restart(void)
> {
> kmsg_dump(KMSG_DUMP_EMERG);
> system_state = SYSTEM_RESTART;
> + printk_trigger_flush();
> machine_emergency_restart();
> }
> EXPORT_SYMBOL_GPL(emergency_restart);
> @@ -102,6 +104,7 @@ void kernel_restart_prepare(char *cmd)
> {
> blocking_notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd);
> system_state = SYSTEM_RESTART;
> + printk_trigger_flush();
> usermodehelper_disable();
> device_shutdown();
> }
> @@ -305,6 +308,7 @@ static void kernel_shutdown_prepare(enum system_states state)
> blocking_notifier_call_chain(&reboot_notifier_list,
> (state == SYSTEM_HALT) ? SYS_HALT : SYS_POWER_OFF, NULL);
> system_state = state;
> + printk_trigger_flush();
> usermodehelper_disable();
> device_shutdown();
> }
>
> Note that it would use NBCON_EMERGENCY_PRIO even in SYSTEM_SUSPEND
> state. But I think that it does not have any real effect because
> it seems to be done after the consoles are suspended. at least
> in hibernation_platform_enter().
>
Applied this fix on top of the commit d353934702. The
kernel_reboot-without-warning issue cannot be reproduced.
> Best Regards,
> Petr
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [linux-next:master] [serial] d353934702: BUG:kernel_reboot-without-warning_in_test_stage
2026-10-20 6:34 ` kernel test robot
@ 2026-10-20 7:27 ` John Ogness
0 siblings, 0 replies; 8+ messages in thread
From: John Ogness @ 2026-10-20 7:27 UTC (permalink / raw)
To: kernel test robot, Petr Mladek
Cc: kernel test robot, oe-lkp, lkp, Greg Kroah-Hartman, linux-serial,
Sergey Senozhatsky, Steven Rostedt
On 2026-10-20, kernel test robot <yi1.lai@intel.com> wrote:
> Applied this fix on top of the commit d353934702. The
> kernel_reboot-without-warning issue cannot be reproduced.
Thank for testing.
Note that the 7.3 release includes commit d8e5fc300229 ("nbcon/reboot:
Switch NBCON consoles into the emergency mode in emergency_restart()"),
which also fixes the issue.
John
^ permalink raw reply [flat|nested] 8+ messages in thread