Merge branch 'perfcounters-fixes-for-linus' of git://git.kernel.org/pub/scm/linux...
[linux-block.git] / kernel / hung_task.c
index 0c924de58cb2cdc5e17c1c0d2341f4d3c1fcacc6..022a4927b78539f5e123558d13e6c012d0188ead 100644 (file)
@@ -72,7 +72,13 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)
 {
        unsigned long switch_count = t->nvcsw + t->nivcsw;
 
-       if (t->flags & PF_FROZEN)
+       /*
+        * Ensure the task is not frozen.
+        * Also, when a freshly created task is scheduled once, changes
+        * its state to TASK_UNINTERRUPTIBLE without having ever been
+        * switched out once, it musn't be checked.
+        */
+       if (unlikely(t->flags & PF_FROZEN || !switch_count))
                return;
 
        if (switch_count != t->last_switch_count) {