Re: [PATCH] exit: skip IRQ disabled warning during power off

From: Mateusz Guzik
Date: Fri Apr 04 2025 - 01:41:06 EST


On Thu, Apr 3, 2025 at 8:01 PM Breno Leitao <leitao@xxxxxxxxxx> wrote:
>
> When the system is shutting down due to pid 1 exiting, which is common
> on virtual machines, a warning message is printed.
>
> WARNING: CPU: 0 PID: 1 at kernel/exit.c:897 do_exit+0x7e3/0xab0
>
> This occurs because do_exit() is called after kernel_power_off(), which
> disables interrupts. native_machine_shutdown() expliclty disable
> interrupt to avoid receiving the timer interrupt, forcing scheduler load
> balance during the power off phase.
>
> This is the simplified code path:
>
> kernel_power_off()
> - native_machine_shutdown()
> - local_irq_disable()
> do_exit()
>
> Modify the warning condition in do_exit() to only trigger the warning if
> the system is not powering off, since it is expected to have the irq
> disabled in that case.
>
> Signed-off-by: Breno Leitao <leitao@xxxxxxxxxx>
> ---
> kernel/exit.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/exit.c b/kernel/exit.c
> index 3485e5fc499e4..97ec4f8bfd98f 100644
> --- a/kernel/exit.c
> +++ b/kernel/exit.c
> @@ -878,7 +878,7 @@ void __noreturn do_exit(long code)
> struct task_struct *tsk = current;
> int group_dead;
>
> - WARN_ON(irqs_disabled());
> + WARN_ON(irqs_disabled() && system_state != SYSTEM_POWER_OFF);
>
> synchronize_group_exit(tsk, code);
>
>

Can you share the backtrace?

Note first thing synchronize_group_exit() is going to do is cycle
through an irq-protected lock, so by the time it unlocks irqs are
enabled again.

Preferably whatever the code path which ends up here would sort it out.

If that's not feasible, I think this warrants a comment above the warn.

--
Mateusz Guzik <mjguzik gmail.com>