hung_task: allow printing warnings every check interval

Hung task detector has one timeout and has two associated actions on it:

- issuing warnings with names and stacks of blocked tasks
- panic()

We want switches to panic (and reboot) if there's a task in
uninterruptible sleep for some minutes - at that moment something ugly has
happened and the box needs a reboot.  But we also want to detect
conditions that are "out of range" or approaching the point of failure. 
Under such conditions we want to issue an "early warning" of an impending
failure, minutes before the switch is going to panic.

Those "early warnings" serve a purpose while monitoring the network
infrastructure.  Those are also valuable on post-mortem analysis, when the
logs from userspace applications aren't enough.  Furthermore, we have a
test pool of long-running duts that are constantly under close to
real-world load for weeks.  And such early warnings allowed to figure out
some bottle necks without much engineer work intervention.

There are also not yet upstream patches for other kinds of "early
warnings" as prints whenever a mutex/semaphore is released after being
held for long time, but those patches are much more intricate and have
their runtime cost.

It seems rather easy to add printing tasks and their stacks for
notification and debugging purposes into hung task detector without
complicating the code or major cost (prints are with KERN_INFO loglevel
and so don't go on console, only into dmesg log).

Since a2e514453861 ("kernel/hung_task.c: allow to set checking interval
separately from timeout") it's possible to set checking interval for hung
task detector with `hung_task_check_interval_secs`.

Provide `hung_task_interval_warnings` sysctl that allows printing hung
tasks every detection interval.  It's not ratelimited, so the root should
be cautious configuring it.

Signed-off-by: Dmitry Safonov <>
Cc: Dmitry Vyukov <>
Cc: Ingo Molnar <>
Cc: Jonathan Corbet <>
Cc: Tetsuo Handa <>
Cc: Thomas Gleixner <>
Cc: "Peter Zijlstra (Intel)" <>
Cc: Vasiliy Khoruzhick <>
Signed-off-by: Andrew Morton <>
4 files changed