sched: Add smt_gain
authorPeter Zijlstra <a.p.zijlstra@chello.nl>
Tue, 1 Sep 2009 08:34:35 +0000 (10:34 +0200)
committerIngo Molnar <mingo@elte.hu>
Fri, 4 Sep 2009 08:09:54 +0000 (10:09 +0200)
The idea is that multi-threading a core yields more work
capacity than a single thread, provide a way to express a
static gain for threads.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Tested-by: Andreas Herrmann <andreas.herrmann3@amd.com>
Acked-by: Andreas Herrmann <andreas.herrmann3@amd.com>
Acked-by: Gautham R Shenoy <ego@in.ibm.com>
Cc: Balbir Singh <balbir@in.ibm.com>
LKML-Reference: <20090901083826.073345955@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
include/linux/sched.h
include/linux/topology.h
kernel/sched.c

index 651dded257201a8a73a8dfee146626f11e1e78b3..9c81c921acb3bf188339fa68a7149a5bd6a97a60 100644 (file)
@@ -921,6 +921,7 @@ struct sched_domain {
        unsigned int newidle_idx;
        unsigned int wake_idx;
        unsigned int forkexec_idx;
+       unsigned int smt_gain;
        int flags;                      /* See SD_* */
        enum sched_domain_level level;
 
index 7402c1a27c4f5149e1fe71c02356a909ec99ccc0..6203ae5067ce73341b715fd8c5fcf80e17b29804 100644 (file)
@@ -99,6 +99,7 @@ int arch_update_cpu_topology(void);
                                | SD_SHARE_CPUPOWER,    \
        .last_balance           = jiffies,              \
        .balance_interval       = 1,                    \
+       .smt_gain               = 1178, /* 15% */       \
 }
 #endif
 #endif /* CONFIG_SCHED_SMT */
index ecb4a47d4214011685b957e71fa72cc6b2a6fc5e..55112261027b6d8e6a839b3f32cc700e09fbef06 100644 (file)
@@ -8523,9 +8523,15 @@ static void init_sched_groups_power(int cpu, struct sched_domain *sd)
                weight = cpumask_weight(sched_domain_span(sd));
                /*
                 * SMT siblings share the power of a single core.
+                * Usually multiple threads get a better yield out of
+                * that one core than a single thread would have,
+                * reflect that in sd->smt_gain.
                 */
-               if ((sd->flags & SD_SHARE_CPUPOWER) && weight > 1)
+               if ((sd->flags & SD_SHARE_CPUPOWER) && weight > 1) {
+                       power *= sd->smt_gain;
                        power /= weight;
+                       power >>= SCHED_LOAD_SHIFT;
+               }
                sg_inc_cpu_power(sd->groups, power);
                return;
        }