[RFC PATCH v2 2/7] sched: Fix __load_balance_iterator() for cfq with only one task.

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Vaidyanathan Srinivasan
Date: Monday, September 8, 2008 - 6:17 am

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.

As a side-effect, there was a regression in sched_mc behavior since 2.6.25,
since iter_move_one_task() when it calls load_balance_start_fair(),
would not get any tasks to move!

Fix this by checking if the last entity was a task or not.

Reference:
http://lkml.org/lkml/2008/9/5/135

Signed-off-by: Gautham R Shenoy <ego@in.ibm.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
---

 kernel/sched_fair.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index fb8994c..f1c96e3 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -1451,7 +1451,7 @@ __load_balance_iterator(struct cfs_rq *cfs_rq, struct list_head *next)
 		next = next->next;
 	} while (next != &cfs_rq->tasks && !entity_is_task(se));
 
-	if (next == &cfs_rq->tasks)
+	if (next == &cfs_rq->tasks && !entity_is_task(se))
 		return NULL;
 
 	cfs_rq->balance_iterator = next;

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC PATCH v2 0/7] Tunable sched_mc_power_savings=n, Vaidyanathan Srinivasan, (Mon Sep 8, 6:14 am)
[RFC PATCH v2 1/7] sched: arch_reinit_sched_domains() must ..., Vaidyanathan Srinivasan, (Mon Sep 8, 6:16 am)
[RFC PATCH v2 2/7] sched: Fix __load_balance_iterator() fo ..., Vaidyanathan Srinivasan, (Mon Sep 8, 6:17 am)
[RFC PATCH v2 3/7] sched: Framework for sched_mc/smt_power ..., Vaidyanathan Srinivasan, (Mon Sep 8, 6:18 am)
[RFC PATCH v2 4/7] sched: favour lower logical cpu number ..., Vaidyanathan Srinivasan, (Mon Sep 8, 6:20 am)
[RFC PATCH v2 5/7] sched: nominate preferred wakeup cpu, Vaidyanathan Srinivasan, (Mon Sep 8, 6:21 am)
[RFC PATCH v2 6/7] sched: bias task wakeups to preferred s ..., Vaidyanathan Srinivasan, (Mon Sep 8, 6:22 am)
[RFC PATCH v2 7/7] sched: activate active load balancing i ..., Vaidyanathan Srinivasan, (Mon Sep 8, 6:23 am)
Re: [RFC PATCH v2 0/7] Tunable sched_mc_power_savings=n, Peter Zijlstra, (Mon Sep 8, 6:25 am)
Re: [RFC PATCH v2 5/7] sched: nominate preferred wakeup cpu, Vaidyanathan Srinivasan, (Mon Sep 8, 6:43 am)
Re: [RFC PATCH v2 0/7] Tunable sched_mc_power_savings=n, Vaidyanathan Srinivasan, (Mon Sep 8, 6:48 am)
Re: [RFC PATCH v2 0/7] Tunable sched_mc_power_savings=n, Peter Zijlstra, (Mon Sep 8, 6:56 am)
Re: [RFC PATCH v2 0/7] Tunable sched_mc_power_savings=n, Suresh Siddha, (Mon Sep 8, 6:20 pm)
Re: [RFC PATCH v2 0/7] Tunable sched_mc_power_savings=n, Peter Zijlstra, (Mon Sep 8, 11:18 pm)
Re: [RFC PATCH v2 0/7] Tunable sched_mc_power_savings=n, Peter Zijlstra, (Mon Sep 8, 11:54 pm)
Re: [RFC PATCH v2 0/7] Tunable sched_mc_power_savings=n, Peter Zijlstra, (Tue Sep 9, 1:25 am)
Re: [RFC PATCH v2 0/7] Tunable sched_mc_power_savings=n, Vaidyanathan Srinivasan, (Wed Sep 10, 6:45 am)