public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Newall <davidn@davidnewall.com>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] fix off-by-one in __iterator_load_balance
Date: Thu, 12 Mar 2009 01:19:11 +1030	[thread overview]
Message-ID: <49B7CF67.5070604@davidnewall.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 180 bytes --]

An off-by-one bug in __iterator_load_balance causes it to erroneously
return NULL if the next task on the list is also the last entry in the
list.  This patch corrects that fault.

[-- Attachment #2: sched_fair.patch --]
[-- Type: text/x-patch, Size: 908 bytes --]

--- sched_fair.c	2009-02-21 09:09:34.000000000 +1030
+++ sched_fair.c.dn	2009-03-12 01:09:46.000000000 +1030
@@ -1439,27 +1439,18 @@
 static struct task_struct *
 __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;
-
-	cfs_rq->balance_iterator = next;
-
-	if (entity_is_task(se))
-		p = task_of(se);
-
-	return p;
+		if (entity_is_task(se))
+		{
+			cfs_rq->balance_iterator = next;
+			return task_of(se);
+		}
+	}
+	return NULL;
 }
 
 static struct task_struct *load_balance_start_fair(void *arg)

             reply	other threads:[~2009-03-11 14:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-11 14:49 David Newall [this message]
2009-03-12  9:34 ` [PATCH] fix off-by-one in __iterator_load_balance David Newall
2009-03-12 10:02   ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49B7CF67.5070604@davidnewall.com \
    --to=davidn@davidnewall.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox