mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Piel <Eric.Piel@tremplin-utc.net>
To: mingo@elte.hu
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] small load-balancer clean-up in move_tasks()
Date: Sun, 24 Apr 2005 18:09:57 +0200	[thread overview]
Message-ID: <426BC4D5.50401@tremplin-utc.net> (raw)

[-- 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,

                 reply	other threads:[~2005-04-24 16:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=426BC4D5.50401@tremplin-utc.net \
    --to=eric.piel@tremplin-utc.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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

all inboxes | Powered by JetHome®