The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] sched: fix SCHED_OTHER balance iterator to include all tasks
@ 2008-05-05 14:31 Gregory Haskins
  2008-05-06 12:06 ` Ingo Molnar
  0 siblings, 1 reply; 3+ messages in thread
From: Gregory Haskins @ 2008-05-05 14:31 UTC (permalink / raw)
  To: mingo, peterz
  Cc: linux-kernel, Gregory Haskins, David Bahi, Ingo Molnar,
	Peter Zijlstra

Hi Ingo,
 The follow patch applies to sched-devel.  I know the original function was
 somehow trying to protect against dequeueing by pre-iterating.  I am not sure
 if I captured the intent properly in that regard.  What I can say is that the
 old algorithm would miss tasks, and that is now fixed.  It may need further
 adjustment if I missed the pre-iterating operation.

Hi Peter,
 I was wrong earlier when I mentioned there might be a problem with
 entity_is_task().  I think this was the root cause of what I was seeing.
 Sorry for the red-herring.

Regards,
-Greg

-----------------------
sched: fix SCHED_OTHER balance iterator to include all tasks

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: Ingo Molnar <mingo@elte.hu>
CC: Peter Zijlstra <peterz@infradead.org>
---

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

diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index 87b7300..e8c289a 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -1700,23 +1700,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;
 }
 


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] sched: fix SCHED_OTHER balance iterator to include all tasks
  2008-05-05 14:31 [PATCH] sched: fix SCHED_OTHER balance iterator to include all tasks Gregory Haskins
@ 2008-05-06 12:06 ` Ingo Molnar
  2008-05-08  8:11   ` Peter Zijlstra
  0 siblings, 1 reply; 3+ messages in thread
From: Ingo Molnar @ 2008-05-06 12:06 UTC (permalink / raw)
  To: Gregory Haskins; +Cc: peterz, linux-kernel, David Bahi


* Gregory Haskins <ghaskins@novell.com> wrote:

> Hi Ingo,
>  The follow patch applies to sched-devel.  I know the original 
>  function was somehow trying to protect against dequeueing by 
>  pre-iterating.  I am not sure if I captured the intent properly in 
>  that regard.  What I can say is that the old algorithm would miss 
>  tasks, and that is now fixed.  It may need further adjustment if I 
>  missed the pre-iterating operation.
> 
> Hi Peter,
>  I was wrong earlier when I mentioned there might be a problem with 
>  entity_is_task().  I think this was the root cause of what I was 
>  seeing. Sorry for the red-herring.

applied Gregory, thanks. Nice fix! Peter, do you concur with Gregory's 
analysis?

	Ingo

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sched: fix SCHED_OTHER balance iterator to include all tasks
  2008-05-06 12:06 ` Ingo Molnar
@ 2008-05-08  8:11   ` Peter Zijlstra
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2008-05-08  8:11 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Gregory Haskins, linux-kernel, David Bahi

On Tue, 2008-05-06 at 14:06 +0200, Ingo Molnar wrote:
> * Gregory Haskins <ghaskins@novell.com> wrote:
> 
> > Hi Ingo,
> >  The follow patch applies to sched-devel.  I know the original 
> >  function was somehow trying to protect against dequeueing by 
> >  pre-iterating.  I am not sure if I captured the intent properly in 
> >  that regard.  What I can say is that the old algorithm would miss 
> >  tasks, and that is now fixed.  It may need further adjustment if I 
> >  missed the pre-iterating operation.
> > 
> > Hi Peter,
> >  I was wrong earlier when I mentioned there might be a problem with 
> >  entity_is_task().  I think this was the root cause of what I was 
> >  seeing. Sorry for the red-herring.
> 
> applied Gregory, thanks. Nice fix! Peter, do you concur with Gregory's 
> analysis?

Yeah,

Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-05-08  8:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-05 14:31 [PATCH] sched: fix SCHED_OTHER balance iterator to include all tasks Gregory Haskins
2008-05-06 12:06 ` Ingo Molnar
2008-05-08  8:11   ` Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox