1 Subject: fix __load_balance_iterator() for cfs with only one task
2 From: Gautham R Shenoy <ego@in.ibm.com>
3 References: 457594 - LTC50544
5 The __load_balance_iterator() returns a NULL when there's only one
6 sched_entity which is a task. It is caused by the following code-path.
8 /* Skip over entities that are not tasks */
10 se = list_entry(next, struct sched_entity, group_node);
12 } while (next != &cfs_rq->tasks && !entity_is_task(se));
14 if (next == &cfs_rq->tasks)
16 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17 This will return NULL even when se is a task.
19 As a side-effect, there was a regression in sched_mc behavior since 2.6.25,
20 since iter_move_one_task() when it calls load_balance_start_fair(),
21 would not get any tasks to move!
23 Fix this by checking if the last entity was a task or not.
25 Signed-off-by: Gautham R Shenoy <ego@in.ibm.com>
26 Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
27 Signed-off-by: Ingo Molnar <mingo@elte.hu>
28 Signed-off-by: Olaf Hering <olh@suse.de>
30 kernel/sched_fair.c | 2 +-
31 1 file changed, 1 insertion(+), 1 deletion(-)
33 --- a/kernel/sched_fair.c
34 +++ b/kernel/sched_fair.c
35 @@ -1410,7 +1410,7 @@ __load_balance_iterator(struct cfs_rq *c
37 } while (next != &cfs_rq->tasks && !entity_is_task(se));
39 - if (next == &cfs_rq->tasks)
40 + if (next == &cfs_rq->tasks && !entity_is_task(se))
43 cfs_rq->balance_iterator = next;