mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] small load-balancer clean-up in move_tasks()
@ 2005-04-24 16:09 Eric Piel
  0 siblings, 0 replies; only message in thread
From: Eric Piel @ 2005-04-24 16:09 UTC (permalink / raw)
  To: mingo; +Cc: linux-kernel

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

Hello,

Here is a small clean-up which changes some goto's into loops for 
move_tasks(). It makes the code a bit easier to read (the two loops are 
explicit now) and it also reduces the number of lines. I've checked the 
patch on x86 and IA-64 (with 4 processors).

Concerning the size of the binary, on x86, depending on the options, it 
can be one instruction (4 bytes) bigger to one instruction smaller. On 
IA-64, it suprisingly saves 4 instructions (64 bytes) most of the time.

This patch was done for 2.6.12-rc1 but should apply against 2.6.12-rc3 
cleanly. It's quite trivial and makes the clode cleaner, please apply.

Eric Piel

--

Small clean-up of move_tasks(). Converts the goto's into two eplicit loops.

Signed-off-by: Eric Piel <eric.piel@tremplin-utc.net>

[-- Attachment #2: sched-remove-goto-move-tasks-2.6.12-rc1.patch --]
[-- Type: text/x-patch, Size: 2164 bytes --]

--- linux-2.6.12-rc1/kernel/sched.c.bak	2005-04-03 00:21:07.000000000 +0200
+++ linux-2.6.12-rc1/kernel/sched.c	2005-04-03 01:08:28.000000000 +0200
@@ -1695,50 +1695,37 @@ static int move_tasks(runqueue_t *this_r
 
 new_array:
 	/* Start searching at priority 0: */
-	idx = 0;
-skip_bitmap:
-	if (!idx)
-		idx = sched_find_first_bit(array->bitmap);
-	else
-		idx = find_next_bit(array->bitmap, MAX_PRIO, idx);
-	if (idx >= MAX_PRIO) {
-		if (array == busiest->expired && busiest->active->nr_active) {
-			array = busiest->active;
-			dst_array = this_rq->active;
-			goto new_array;
-		}
-		goto out;
-	}
-
-	head = array->queue + idx;
-	curr = head->prev;
-skip_queue:
-	tmp = list_entry(curr, task_t, run_list);
-
-	curr = curr->prev;
-
-	if (!can_migrate_task(tmp, busiest, this_cpu, sd, idle)) {
-		if (curr != head)
-			goto skip_queue;
-		idx++;
-		goto skip_bitmap;
-	}
+	for (idx = sched_find_first_bit(array->bitmap);
+	     idx < MAX_PRIO;
+	     idx = find_next_bit(array->bitmap, MAX_PRIO, idx + 1)) {
+		head = array->queue + idx;
+		for (curr = head->prev;
+		     curr != head; ) {
+			tmp = list_entry(curr, task_t, run_list);
+
+			curr = curr->prev;
+			
+			if (!can_migrate_task(tmp, busiest, this_cpu, sd, idle))
+				continue;
 
 #ifdef CONFIG_SCHEDSTATS
-	if (task_hot(tmp, busiest->timestamp_last_tick, sd))
-		schedstat_inc(sd, lb_hot_gained[idle]);
+			if (task_hot(tmp, busiest->timestamp_last_tick, sd))
+				schedstat_inc(sd, lb_hot_gained[idle]);
 #endif
 
-	pull_task(busiest, array, tmp, this_rq, dst_array, this_cpu);
-	pulled++;
+			pull_task(busiest, array, tmp, this_rq, dst_array, this_cpu);
+			pulled++;
 
-	/* We only want to steal up to the prescribed number of tasks. */
-	if (pulled < max_nr_move) {
-		if (curr != head)
-			goto skip_queue;
-		idx++;
-		goto skip_bitmap;
+			/* We only want to steal up to the prescribed number of tasks. */
+			if (pulled >= max_nr_move) 
+				goto out;
+		}
 	}
+	if (array == busiest->expired && busiest->active->nr_active) {
+		array = busiest->active;
+		dst_array = this_rq->active;
+		goto new_array;
+ 	}
 out:
 	/*
 	 * Right now, this is the only place pull_task() is called,

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-04-24 16:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-24 16:09 [PATCH] small load-balancer clean-up in move_tasks() Eric Piel

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

all inboxes | Powered by JetHome®