Skip to contentSkip to conversation

fix off-by-one in __iterator_load_balance

PATCH In review David Newall 2 participants 3 messages Mar 11, 2009 – Mar 12, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix off-by-one in __iterator_load_balance

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.

sched_fair.c.dn renamed from sched_fair.c +9 -18
@@ -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)
#1 lore raw
Quoted 4 lines · David Newall

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.

Patch withdrawn. Who'd have thought 2.6.27.19 was so out of date?

#2 lore raw
Quoted 7 lines · David Newall
Quoted 4 lines · David Newall

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.

Patch withdrawn. Who'd have thought 2.6.27.19 was so out of date?

Yeah, the 2.6.27 -> latest-sched-devel distance is more than 250 commits already - that's a lot of commits for the scheduler which is only 15 KLOC. Patches done on .27 are unlikely to apply
- and bugs are often fixed already.

Ingo