public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Con Kolivas <kernel@kolivas.org>
To: Andrew Morton <akpm@osdl.org>
Cc: linux kernel mailing list <linux-kernel@vger.kernel.org>,
	ck@vds.kolivas.org, Ingo Molnar <mingo@elte.hu>,
	Peter Williams <pwil3058@bigpond.net.au>
Subject: [PATCH] SCHED: smp nice bias busy queues on idle rebalance
Date: Sat, 28 May 2005 15:34:47 +1000	[thread overview]
Message-ID: <200505281534.50651.kernel@kolivas.org> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 35 bytes --]

SMP nice support tweaks.

Con
---


[-- Attachment #1.2: sched-smp_nice_bias_busy_queues_on_idle_rebalance.diff --]
[-- Type: text/x-diff, Size: 2809 bytes --]

To intensify the 'nice' support across physical cpus on SMP we can bias the
loads on idle rebalancing. To prevent idle rebalance from trying to pull tasks
from queues that appear heavily loaded we only bias the load if there is more
than one task running. 

Add some minor micro-optimisations and have only one return from __source_load
and __target_load functions.

Fix the fact that target_load was not biased by priority when type==0.

Signed-off-by: Con Kolivas <kernel@kolivas.org>

Index: linux-2.6.12-rc5-mm1/kernel/sched.c
===================================================================
--- linux-2.6.12-rc5-mm1.orig/kernel/sched.c	2005-05-28 15:08:08.000000000 +1000
+++ linux-2.6.12-rc5-mm1/kernel/sched.c	2005-05-28 15:20:12.000000000 +1000
@@ -970,22 +970,26 @@ void kick_process(task_t *p)
 static inline unsigned long __source_load(int cpu, int type, enum idle_type idle)
 {
 	runqueue_t *rq = cpu_rq(cpu);
-	unsigned long cpu_load = rq->cpu_load[type-1],
+	unsigned long source_load, cpu_load = rq->cpu_load[type-1],
 		load_now = rq->nr_running * SCHED_LOAD_SCALE;
 
-	if (idle == NOT_IDLE) {
+	if (type == 0)
+		source_load = load_now;
+	else
+		source_load = min(cpu_load, load_now);
+
+	if (idle == NOT_IDLE || rq->nr_running > 1)
 		/*
-		 * If we are balancing busy runqueues the load is biased by
-		 * priority to create 'nice' support across cpus.
+		 * If we are busy rebalancing the load is biased by
+		 * priority to create 'nice' support across cpus. When
+		 * idle rebalancing we should only bias the source_load if
+		 * there is more than one task running on that queue to
+		 * prevent idle rebalance from trying to pull tasks from a
+		 * queue with only one running task.
 		 */
-		cpu_load *= rq->prio_bias;
-		load_now *= rq->prio_bias;
-	}
+		source_load *= rq->prio_bias;
 
-	if (type == 0)
-		return load_now;
-
-	return min(cpu_load, load_now);
+	return source_load;
 }
 
 static inline unsigned long source_load(int cpu, int type)
@@ -999,17 +1003,18 @@ static inline unsigned long source_load(
 static inline unsigned long __target_load(int cpu, int type, enum idle_type idle)
 {
 	runqueue_t *rq = cpu_rq(cpu);
-	unsigned long cpu_load = rq->cpu_load[type-1],
+	unsigned long target_load, cpu_load = rq->cpu_load[type-1],
 		load_now = rq->nr_running * SCHED_LOAD_SCALE;
 
 	if (type == 0)
-		return load_now;
+		target_load = load_now;
+	else
+		target_load = max(cpu_load, load_now);
 
-	if (idle == NOT_IDLE) {
-		cpu_load *= rq->prio_bias;
-		load_now *= rq->prio_bias;
-	}
-	return max(cpu_load, load_now);
+	if (idle == NOT_IDLE || rq->nr_running > 1)
+		target_load *= rq->prio_bias;
+
+	return target_load;
 }
 
 static inline unsigned long target_load(int cpu, int type)

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

                 reply	other threads:[~2005-05-28  5:34 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=200505281534.50651.kernel@kolivas.org \
    --to=kernel@kolivas.org \
    --cc=akpm@osdl.org \
    --cc=ck@vds.kolivas.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=pwil3058@bigpond.net.au \
    /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