mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Wang Jinchao <wangjinchao600@gmail.com>
Cc: John Ogness <john.ogness@linutronix.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	Joel Granados <joel.granados@kernel.org>,
	Dave Jiang <dave.jiang@intel.com>,
	Josh Poimboeuf <jpoimboe@kernel.org>,
	Sravan Kumar Gundu <sravankumarlpu@gmail.com>,
	Ryo Takakura <takakura@valinux.co.jp>,
	linux-kernel@vger.kernel.org, Wei Liu <wei.liu@kernel.org>,
	Jason Gunthorpe <jgg@ziepe.ca>
Subject: Re: [PATCH] panic: call hardlockup_detector_perf_stop in panic
Date: Tue, 19 Aug 2025 17:01:33 +0200	[thread overview]
Message-ID: <aKSRzbUvuEkVz-Gk@pathway.suse.cz> (raw)
In-Reply-To: <20250730030638.65355-1-wangjinchao600@gmail.com>

On Wed 2025-07-30 11:06:33, Wang Jinchao wrote:
> When a panic happens, it blocks the cpu, which may
> trigger the hardlockup detector if some dump is slow.
> So call hardlockup_detector_perf_stop() to disable
> hardlockup dector.

Could you please provide more details, especially the log showing
the problem?

I wonder if this is similar to
https://lore.kernel.org/all/SN6PR02MB4157A4C5E8CB219A75263A17D46DA@SN6PR02MB4157.namprd02.prod.outlook.com/

There was a problem that a non-panic CPU might get stuck in
pl011_console_write_thread() or any other con->write_thread()
callback because nbcon_reacquire_nobuf(wctxt) ended in an infinite
loop.

It was a real lockup. It has got recently fixed in 6.17-rc1 by
the commit 571c1ea91a73db56bd94 ("printk: nbcon: Allow reacquire
during panic"), see
https://patch.msgid.link/20250606185549.900611-1-john.ogness@linutronix.de
It is possible that it fixed your problem as well.

That said, it might make sense to disable the hardlockup
detector during panic. But I do not like the proposed way,
see below.

> --- a/kernel/panic.c
> +++ b/kernel/panic.c
> @@ -339,6 +339,7 @@ void panic(const char *fmt, ...)
>  	 */
>  	local_irq_disable();
>  	preempt_disable_notrace();
> +	hardlockup_detector_perf_stop();

I see the following in kernel/watchdog_perf.c:

/**
 * hardlockup_detector_perf_stop - Globally stop watchdog events
 *
 * Special interface for x86 to handle the perf HT bug.
 */
void __init hardlockup_detector_perf_stop(void)
{
[...]
	lockdep_assert_cpus_held();
[...]
}

1. It is suspicious to see an x86-specific "hacky" function called in
   the generic panic().

   Is this safe?
   What about other hardlockup detectors?


2. I expect that lockdep_assert_cpus_held() would complain
   when CONFIG_LOCKDEP was enabled.


Anyway, it does not look safe. panic() might be called in any context,
including NMI, and I see:

 + hardlockup_detector_perf_stop()
   + perf_event_disable()
     + perf_event_ctx_lock()
       + mutex_lock_nested()

This might cause deadlock when called in NMI, definitely.

Alternative:

A conservative approach would be to update watchdog_hardlockup_check()
so that it does nothing when panic_in_progress() returns true. It
would even work for both hardlockup detectors implementation.

Best Regards,
Petr

  reply	other threads:[~2025-08-19 15:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-30  3:06 Wang Jinchao
2025-08-19 15:01 ` Petr Mladek [this message]
2025-08-20  6:22   ` Jinchao Wang
2025-08-20 10:22     ` Petr Mladek
2025-08-21  1:35       ` Jinchao Wang

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=aKSRzbUvuEkVz-Gk@pathway.suse.cz \
    --to=pmladek@suse.com \
    --cc=dave.jiang@intel.com \
    --cc=jgg@ziepe.ca \
    --cc=joel.granados@kernel.org \
    --cc=john.ogness@linutronix.de \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sravankumarlpu@gmail.com \
    --cc=takakura@valinux.co.jp \
    --cc=tglx@linutronix.de \
    --cc=wangjinchao600@gmail.com \
    --cc=wei.liu@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®