Re: [PATCH] hung_task: configurable hung-task stacktrace loglevel

From: Petr Mladek
Date: Thu Apr 24 2025 - 06:59:06 EST


On Thu 2025-04-24 16:02:43, Sergey Senozhatsky wrote:
> Currently, hung-task watchdog uses two different loglevels
> to report hung-tasks: a) KERN_INFO for all the important task
> information (e.g. sched_show_task()) and b) KERN_ERR for the
> rest.

IMHO, the two different loglevels make sense. The KERN_ERR
message seems to inform about that a task gets blocked for too long.
And KERN_INFO is used for an extra debug information.

> This makes it a little inconvenient, especially for
> automated kernel logs parsing.

Anyway, what is the exact problem, please?
Are the KERN_INFO messages filtered because of console_loglevel?
Or is it a problem to match all the related lines?

> Introduce CONFIG_HUNG_TASK_STACKTRACE_LOGLEVEL so that (a)
> becomes configurable.

I am not sure if adding hung-task-specific config option is
the right solution. I guess that other watchdogs or other
similar reports have the same problem.

It seems that several other reports, for example,
watchdog_hardlockup_check(), or __die(), are using KERN_DEFAULT
which is configurable via CONFIG_MESSAGE_LOGLEVEL_DEFAULT.

A solution might be using KERN_DEFAULT for sched_show_task()
in hung_tasks detector as well.

Alternatively, if the problem is console_loglevel filtering then
it might make sense to create a config option which would force
using the same loglevel in all similar reports. I would call it:

CONFIG_FULL_REPORT_USING_SAME_LOGLEVEL

And support it for other reports.

If the problem is matching all related lines. Then a solution
would be printing some help lines around the report, similar
to

------------[ cut here ]------------

in include/asm-generic/bug.h

Plus, it would be needed to filter out messages from other CPUs.
CONFIG_PRINTK_CALLER should help with this.

Best Regards,
Petr