public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frank Cornelis <Frank.Cornelis@elis.ugent.be>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: Frank Cornelis <Frank.Cornelis@elis.ugent.be>
Subject: [PATCH] sched: sched_best_cpu
Date: 21 Aug 2003 11:47:07 +0200	[thread overview]
Message-ID: <1061459227.19789.22.camel@tom> (raw)

Hi,


Next patch slightly favors the local node when looking for the least
loaded cpu; when the task would not stay on our node we add 1 to the
load to simulate the influence the migration would have on the load.


Frank


--- sched.c.orig	2003-08-09 06:39:35.000000000 +0200
+++ sched.c	2003-08-21 11:45:04.000000000 +0200
@@ -776,29 +776,30 @@
  */
 static int sched_best_cpu(struct task_struct *p)
 {
-	int i, minload, load, best_cpu, node = 0;
+	int i, minload, load, best_cpu, node, pnode;
 	unsigned long cpumask;
 
 	best_cpu = task_cpu(p);
 	if (cpu_rq(best_cpu)->nr_running <= 2)
 		return best_cpu;
 
-	minload = 10000000;
+	minload = INT_MAX;
+	node = pnode = cpu_to_node(best_cpu);
 	for_each_node_with_cpus(i) {
 		/*
 		 * Node load is always divided by nr_cpus_node to normalise 
 		 * load values in case cpu count differs from node to node.
-		 * We first multiply node_nr_running by 10 to get a little
-		 * better resolution.   
+		 * If the node != our node we add the load of the task.
+		 * We multiply by NR_CPUS for better resolution.
 		 */
-		load = 10 * atomic_read(&node_nr_running[i]) / nr_cpus_node(i);
+		load = NR_CPUS * (atomic_read(&node_nr_running[i]) + (i != pnode)) / nr_cpus_node(i);
 		if (load < minload) {
 			minload = load;
 			node = i;
 		}
 	}
 
-	minload = 10000000;
+	minload = INT_MAX;
 	cpumask = node_to_cpumask(node);
 	for (i = 0; i < NR_CPUS; ++i) {
 		if (!(cpumask & (1UL << i)))


             reply	other threads:[~2003-08-21  9:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-21  9:47 Frank Cornelis [this message]
2003-08-21 10:00 ` [PATCH] sched: sched_best_cpu Zwane Mwaikambo
  -- strict thread matches above, loose matches on Subject: below --
2003-08-22 12:32 Frank Cornelis

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=1061459227.19789.22.camel@tom \
    --to=frank.cornelis@elis.ugent.be \
    --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