]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
sched: Micro-optimize the smart wake-affine logic
authorPeter Zijlstra <peterz@infradead.org>
Thu, 4 Jul 2013 04:56:46 +0000 (12:56 +0800)
committerIngo Molnar <mingo@kernel.org>
Tue, 23 Jul 2013 10:22:06 +0000 (12:22 +0200)
Smart wake-affine is using node-size as the factor currently, but the overhead
of the mask operation is high.

Thus, this patch introduce the 'sd_llc_size' percpu variable, which will record
the highest cache-share domain size, and make it to be the new factor, in order
to reduce the overhead and make it more reasonable.

Tested-by: Davidlohr Bueso <davidlohr.bueso@hp.com>
Tested-by: Michael Wang <wangyun@linux.vnet.ibm.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: Michael Wang <wangyun@linux.vnet.ibm.com>
Cc: Mike Galbraith <efault@gmx.de>
Link: http://lkml.kernel.org/r/51D5008E.6030102@linux.vnet.ibm.com
[ Tidied up the changelog. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/sched/core.c
kernel/sched/fair.c
kernel/sched/sched.h

index b7c32cb7bfebbd5912f06a421decb87b15c34bf9..6df0fbe53767bcce281f6e6bd0764fc41fc1abe1 100644 (file)
@@ -5083,18 +5083,23 @@ static void destroy_sched_domains(struct sched_domain *sd, int cpu)
  * two cpus are in the same cache domain, see cpus_share_cache().
  */
 DEFINE_PER_CPU(struct sched_domain *, sd_llc);
+DEFINE_PER_CPU(int, sd_llc_size);
 DEFINE_PER_CPU(int, sd_llc_id);
 
 static void update_top_cache_domain(int cpu)
 {
        struct sched_domain *sd;
        int id = cpu;
+       int size = 1;
 
        sd = highest_flag_domain(cpu, SD_SHARE_PKG_RESOURCES);
-       if (sd)
+       if (sd) {
                id = cpumask_first(sched_domain_span(sd));
+               size = cpumask_weight(sched_domain_span(sd));
+       }
 
        rcu_assign_pointer(per_cpu(sd_llc, cpu), sd);
+       per_cpu(sd_llc_size, cpu) = size;
        per_cpu(sd_llc_id, cpu) = id;
 }
 
index 860063a8c8491dc2da01cce86fb5567b04f3be3a..f237437446e55873a9955b8cf12b030c956c4370 100644 (file)
@@ -3175,7 +3175,7 @@ static inline unsigned long effective_load(struct task_group *tg, int cpu,
 
 static int wake_wide(struct task_struct *p)
 {
-       int factor = nr_cpus_node(cpu_to_node(smp_processor_id()));
+       int factor = this_cpu_read(sd_llc_size);
 
        /*
         * Yeah, it's the switching-frequency, could means many wakee or
index 5e129efb84ce950d21e37e3dff2c933d5d586fbf..4c1cb8029feb484d81cd1c5f8c9c3ecd03d21795 100644 (file)
@@ -594,6 +594,7 @@ static inline struct sched_domain *highest_flag_domain(int cpu, int flag)
 }
 
 DECLARE_PER_CPU(struct sched_domain *, sd_llc);
+DECLARE_PER_CPU(int, sd_llc_size);
 DECLARE_PER_CPU(int, sd_llc_id);
 
 struct sched_group_power {