Re: [PATCH v3] softlockup: remove hung_task_check_count

From: Mandeep Singh Baines
Date: Fri Jan 23 2009 - 21:56:41 EST

Ingo Molnar (mingo@xxxxxxx) wrote:
> not sure i like the whole idea of removing the max iterations check. In
> theory if there's a _ton_ of tasks, we could spend a lot of time looping
> there. So it always looked prudent to limit it somewhat.

We could go back to exporting max iterations to proc, and set the nice
value higher.


Instead of searching the tasklist from the beginning every time, continue
where you left off. On loaded systems, will take a while to search the
entire list but at least all tasks will be checked.

Something like this:

diff --git a/kernel/hung_task.c b/kernel/hung_task.c
index ba8ccd4..d220796 100644
--- a/kernel/hung_task.c
+++ b/kernel/hung_task.c
@@ -109,6 +109,15 @@ static void check_hung_task(struct task_struct *t, unsigned long now,
panic("hung_task: blocked tasks");

+static void wait_till_next_iteration(struct task_struct *t)
+ get_task_state(t);
+ read_unlock(&tasklist_lock);
+ schedule_timeout_interruptible(hung_task_poll_jiffies);
+ read_lock(&tasklist_lock);
+ put_task_state(t);
* Check whether a TASK_UNINTERRUPTIBLE does not get woken up for
* a really long time (120 seconds). If that happens, print out
@@ -129,8 +138,14 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout)

do_each_thread(g, t) {
- if (!--max_count)
- goto unlock;
+ if (!--max_count) {
+ max_count = HUNG_TASK_CHECK_COUNT;
+ wait_till_next_iteration(t);
+ timeout = sysctl_hung_task_timeout_secs;
+ /* Exit loop if t was unlinked or timeout set to 0. */
+ if (!timeout || t->state == TASK_DEAD)
+ goto unlock;
+ }
/* use "==" to skip the TASK_KILLABLE tasks waiting on NFS */
check_hung_task(t, now, timeout);
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at