public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Matthew Dobson <colpatch@us.ibm.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: Michael Hohnbaum <hohnbaum@us.ibm.com>
Subject: [rfc][patch] kernel/sched.c oddness?
Date: Wed, 02 Oct 2002 11:41:08 -0700	[thread overview]
Message-ID: <3D9B3DC4.4030209@us.ibm.com> (raw)

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

This snippet of code appears wrong...  Either that, or the accompanying 
comment is wrong?

from kernel/sched.c::find_busiest_queue():

| 
*imbalance = (max_load - nr_running) / 2;
|
| 
/* It needs an at least ~25% imbalance to trigger balancing. */
| 
if (!idle && (*imbalance < (max_load + 3)/4)) {
| 
	busiest = NULL;
| 
	goto out;
| 
}

The comment says 25% imbalance, but the code is really checking for a 
~50% imbalance.  The attatched patch moves the division by two to the 
pull_task function where the imbalance number is actually used.  This 
patch makes the code match the comment, and divides the imbalance by two 
where it is needed.

Please let me know if I've misinterpreted what this code is supposed to 
be doing, -or- if we really want the comment to match the current code.

Cheers!

-Matt

[-- Attachment #2: sched_cleanup-2.5.40.patch --]
[-- Type: text/plain, Size: 826 bytes --]

diff -Nur --exclude-from=/usr/src/.dontdiff linux-2.5.40-vanilla/kernel/sched.c linux-2.5.40-sched_cleanup/kernel/sched.c
--- linux-2.5.40-vanilla/kernel/sched.c	Tue Oct  1 00:07:35 2002
+++ linux-2.5.40-sched_cleanup/kernel/sched.c	Wed Oct  2 11:22:41 2002
@@ -689,7 +689,7 @@
 	if (likely(!busiest))
 		goto out;
 
-	*imbalance = (max_load - nr_running) / 2;
+	*imbalance = (max_load - nr_running);
 
 	/* It needs an at least ~25% imbalance to trigger balancing. */
 	if (!idle && (*imbalance < (max_load + 3)/4)) {
@@ -746,6 +746,11 @@
 	task_t *tmp;
 
 	busiest = find_busiest_queue(this_rq, this_cpu, idle, &imbalance);
+	/*
+	 * We only want to steal a number of tasks equal to 1/2 the imbalance,
+ 	 * otherwise, we'll just shift the imbalance to the new queue.
+	 */
+	imbalance >>= 1;
 	if (!busiest)
 		goto out;
 

             reply	other threads:[~2002-10-02 18:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-02 18:41 Matthew Dobson [this message]
2002-10-03  0:06 ` [rfc][patch] kernel/sched.c oddness? Nick Piggin
2002-10-03  0:30   ` Matthew Dobson
2002-10-03  6:54   ` Ingo Molnar
2002-10-03  8:32     ` Nick Piggin
2002-10-03 21:15     ` Matthew Dobson
2002-10-04  7:46       ` 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=3D9B3DC4.4030209@us.ibm.com \
    --to=colpatch@us.ibm.com \
    --cc=hohnbaum@us.ibm.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