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

Chris Friesen
2008-09-12T15:53:18Z

Gautham R Shenoy wrote:
> sched: Fix __load_balance_iterator() for cfq with only one task.
>
> From: Gautham R Shenoy <ego@in.ibm.com>
>
> 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.

Chris