Skip to content

Commit

Permalink
sched: fix SCHED_OTHER balance iterator to include all tasks
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Gregory Haskins authored and Ingo Molnar committed Jun 6, 2008
1 parent 6e0534f commit 6d299f1
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions kernel/sched_fair.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 6d299f1

Please sign in to comment.