Re: [PATCH] sched: Fix __load_balance_iterator() for cfq with onlyone task

From: Chris Friesen
Date: Fri Sep 12 2008 - 11:53:19 EST

Gautham R Shenoy wrote:
sched: Fix __load_balance_iterator() for cfq with only one task.

From: Gautham R Shenoy <ego@xxxxxxxxxx>

The __load_balance_iterator() returns a NULL when there's only one
sched_entity which is a task. It is caused by the following code-path.

/* Skip over entities that are not tasks */
do {
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;
This will return NULL even when se is a task.

Thank you! I'd been looking suspiciously at this routine as well due to strange load-balancing behaviour that I saw while testing the fair group code, but I hadn't yet tracked down the exact problem.

Peter/Ingo, this appears to explain the issues described in the mail I sent on the 4th. After applying this change the imbalance between tasks in the same group is substantially reduced.

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