sched: fix SCHED_OTHER balance iterator to include all tasks
authorGregory Haskins <ghaskins@novell.com>
Mon, 12 May 2008 19:21:14 +0000 (21:21 +0200)
committerIngo Molnar <mingo@elte.hu>
Fri, 6 Jun 2008 13:19:29 +0000 (15:19 +0200)
The currently logic inadvertently skips the last task on the run-queue,
resulting in missed balance opportunities.

Signed-off-by: Gregory Haskins <ghaskins@novell.com>
Signed-off-by: David Bahi <dbahi@novell.com>
CC: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
kernel/sched_fair.c

index 08ae848b71d4643429f67ef312a7bfd78a32aa0a..1fe4c65a8170b92fadbb5e35e03a3c50ff65ec90 100644 (file)
@@ -1275,23 +1275,18 @@ __load_balance_iterator(struct cfs_rq *cfs_rq, struct list_head *next)
        struct task_struct *p = NULL;
        struct sched_entity *se;
 
-       if (next == &cfs_rq->tasks)
-               return NULL;
-
-       /* Skip over entities that are not tasks */
-       do {
+       while (next != &cfs_rq->tasks) {
                se = list_entry(next, struct sched_entity, group_node);
                next = next->next;
-       } while (next != &cfs_rq->tasks && !entity_is_task(se));
 
-       if (next == &cfs_rq->tasks)
-               return NULL;
+               /* Skip over entities that are not tasks */
+               if (entity_is_task(se)) {
+                       p = task_of(se);
+                       break;
+               }
+       }
 
        cfs_rq->balance_iterator = next;
-
-       if (entity_is_task(se))
-               p = task_of(se);
-
        return p;
 }