[PATCH] softlockup: ensure the task has been scheduled once

From: Frederic Weisbecker
Date: Sat Feb 07 2009 - 11:45:12 EST


When we check if the task has been scheduled since the last scan, we might
have a race condition if the task has been inserted on the task list but not
yet scheduled once. So we just add a small check to ensure it has been switched
in at least one time to avoid false positive.

Signed-off-by: Frederic Weisbecker <fweisbec@xxxxxxxxx>
---
kernel/hung_task.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/kernel/hung_task.c b/kernel/hung_task.c
index 4a10756..7f57a71 100644
--- a/kernel/hung_task.c
+++ b/kernel/hung_task.c
@@ -72,7 +72,11 @@ 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 and that it has been scheduled
+ * at least once.
+ */
+ if (t->flags & PF_FROZEN || !switch_count)
return;

if (switch_count != t->last_switch_count) {
--
1.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/