Re: netconsole: HARDIRQ-safe -> HARDIRQ-unsafe lock order warning

From: Petr Mladek

Date: Wed Sep 10 2025 - 11:52:00 EST


On Mon 2025-09-08 13:27:05, Calvin Owens wrote:
> On Friday 09/05 at 14:54 +0206, John Ogness wrote:
> > <snip>
> >
> > NBCON is meant to deprecate @oops_in_progress. However, it is true that
> > consoles not implementing ->write_atomic() will never print panic
> > output.
>
> Below is a silly little testcase that makes it more convenient to test
> if crashes are getting out in a few canned cases, in case anyone else
> finds it useful.
>
> Testing this on 6.17-rc5 on a Pi 4b, I don't get any netconsole output
> at all for any crash case over wifi, so that already doesn't work. All
> the cases currently work over ethernet.

I like this test module. IMHO, it would make sense to get it upstream.
What do you think?

Some comments below.

> ----8<----
> From: Calvin Owens <calvin@xxxxxxxxxx>
> Subject: [PATCH] Quick and dirty testcase for netconsole (and other consoles)
>
> Signed-off-by: Calvin Owens <calvin@xxxxxxxxxx>
> ---
> drivers/tty/Kconfig | 9 ++
> drivers/tty/Makefile | 1 +
> drivers/tty/crashtest.c | 178 ++++++++++++++++++++++++++++++++++++++++

I would put it into lib/test_crash.c. It is similar to
the existing lib/test_lockup.c

> --- /dev/null
> +++ b/drivers/tty/crashtest.c
> @@ -0,0 +1,178 @@
[...]
> +
> +static ssize_t __crash(void)
> +{
> + pr_emerg("BANG!\n");
> + *(volatile unsigned char *)NULL = '!';
> + return -ENOSYS;

I would use similar trick as SysRq-c and call panic() directly,
see sysrq_handle_crash(). Something like:

static void __crash(const char *context)
{
panic(Triggered crash in context: %s\n");
}

> +}
> +
> +static void __crash_irq_work(struct irq_work *work)
> +{
> + __crash();

and call it like:

__crash("irq");

> +}
> +
> +static int __init setup_crashtest(void)
> +{
> + INIT_WORK(&bh_crash_work, __crash_bh_work);
> + init_irq_work(&irq_crash_work, __crash_irq_work);
> + crashtest_dentry = debugfs_create_file("crashtest", 0600, NULL, NULL,
> + &crashtest_fops);

Match it with the module name: test_crash.

Maybe, do "sed -e s/crashtest/test_crash/g".

> + if (IS_ERR(crashtest_dentry))
> + return PTR_ERR(crashtest_dentry);
> +
> + return 0;
> +}

Best Regards,
Petr