Commit 304ae427 authored by Tetsuo Handa's avatar Tetsuo Handa Committed by Linus Torvalds

kernel/hung_task.c: break RCU locks based on jiffies

check_hung_uninterruptible_tasks() is currently calling rcu_lock_break()
for every 1024 threads.  But check_hung_task() is very slow if printk()
was called, and is very fast otherwise.

If many threads within some 1024 threads called printk(), the RCU grace
period might be extended enough to trigger RCU stall warnings.
Therefore, calling rcu_lock_break() for every some fixed jiffies will be

Link: default avatarTetsuo Handa <>
Acked-by: default avatarPaul E. McKenney <>
Cc: Petr Mladek <>
Cc: Sergey Senozhatsky <>
Cc: Dmitry Vyukov <>
Cc: "Rafael J. Wysocki" <>
Cc: Vitaly Kuznetsov <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 168e06f7
......@@ -34,7 +34,7 @@ int __read_mostly sysctl_hung_task_check_count = PID_MAX_LIMIT;
* is disabled during the critical section. It also controls the size of
* the RCU grace period. So it needs to be upper-bound.
#define HUNG_TASK_LOCK_BREAK (HZ / 10)
* Zero means infinite timeout - no checking done:
......@@ -171,7 +171,7 @@ static bool rcu_lock_break(struct task_struct *g, struct task_struct *t)
static void check_hung_uninterruptible_tasks(unsigned long timeout)
int max_count = sysctl_hung_task_check_count;
int batch_count = HUNG_TASK_BATCHING;
unsigned long last_break = jiffies;
struct task_struct *g, *t;
......@@ -186,10 +186,10 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout)
for_each_process_thread(g, t) {
if (!max_count--)
goto unlock;
if (!--batch_count) {
batch_count = HUNG_TASK_BATCHING;
if (time_after(jiffies, last_break + HUNG_TASK_LOCK_BREAK)) {
if (!rcu_lock_break(g, t))
goto unlock;
last_break = jiffies;
/* use "==" to skip the TASK_KILLABLE tasks waiting on NFS */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment