sched: sched_best_cpu
PATCH 1/1 sched: sched_best_cpu
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 renamed from sched.c.orig +7 -6
@@ -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)))
Quoted 6 lines · Frank Cornelis
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.
You might need to rediff soon due to cpumask_t changes
sched.c line 780
Quoted 9 lines
sched.c renamed from sched.c.orig +1
-1@@ -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;
cpumask_t cpumask;
Quoted 20 lines
sched.c renamed from sched.c.orig +5
-4best_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) {
sched.c line 805
Quoted 10 lines
sched.c renamed from sched.c.orig +1
-1minload = load; node = i; } } - minload =10000000 ; + minload =INT_MAX ; cpumask =node_to_cpumask (node);for (i =0 ; i <NR_CPUS ; ++i) {if (!(cpumask & (1UL << i)))
if (!cpu_isset(i, cpumask))