[tip:sched/core] sched/topology: Add SD_ASYM_CPUCAPACITY flag detection

2018-09-10 Thread tip-bot for Morten Rasmussen
Commit-ID:  05484e0984487d42e97c417cbb0697fa9d16e7e9
Gitweb: https://git.kernel.org/tip/05484e0984487d42e97c417cbb0697fa9d16e7e9
Author: Morten Rasmussen 
AuthorDate: Fri, 20 Jul 2018 14:32:31 +0100
Committer:  Ingo Molnar 
CommitDate: Mon, 10 Sep 2018 11:05:45 +0200

sched/topology: Add SD_ASYM_CPUCAPACITY flag detection

The SD_ASYM_CPUCAPACITY sched_domain flag is supposed to mark the
sched_domain in the hierarchy where all CPU capacities are visible for
any CPU's point of view on asymmetric CPU capacity systems. The
scheduler can then take to take capacity asymmetry into account when
balancing at this level. It also serves as an indicator for how wide
task placement heuristics have to search to consider all available CPU
capacities as asymmetric systems might often appear symmetric at
smallest level(s) of the sched_domain hierarchy.

The flag has been around for while but so far only been set by
out-of-tree code in Android kernels. One solution is to let each
architecture provide the flag through a custom sched_domain topology
array and associated mask and flag functions. However,
SD_ASYM_CPUCAPACITY is special in the sense that it depends on the
capacity and presence of all CPUs in the system, i.e. when hotplugging
all CPUs out except those with one particular CPU capacity the flag
should disappear even if the sched_domains don't collapse. Similarly,
the flag is affected by cpusets where load-balancing is turned off.
Detecting when the flags should be set therefore depends not only on
topology information but also the cpuset configuration and hotplug
state. The arch code doesn't have easy access to the cpuset
configuration.

Instead, this patch implements the flag detection in generic code where
cpusets and hotplug state is already taken care of. All the arch is
responsible for is to implement arch_scale_cpu_capacity() and force a
full rebuild of the sched_domain hierarchy if capacities are updated,
e.g. later in the boot process when cpufreq has initialized.

Signed-off-by: Morten Rasmussen 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: dietmar.eggem...@arm.com
Cc: valentin.schnei...@arm.com
Cc: vincent.guit...@linaro.org
Link: 
http://lkml.kernel.org/r/1532093554-30504-2-git-send-email-morten.rasmus...@arm.com
[ Fixed 'CPU' capitalization. ]
Signed-off-by: Ingo Molnar 
---
 include/linux/sched/topology.h |  6 ++--
 kernel/sched/topology.c| 81 ++
 2 files changed, 78 insertions(+), 9 deletions(-)

diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h
index 26347741ba50..6b9976180c1e 100644
--- a/include/linux/sched/topology.h
+++ b/include/linux/sched/topology.h
@@ -23,10 +23,10 @@
 #define SD_BALANCE_FORK0x0008  /* Balance on fork, clone */
 #define SD_BALANCE_WAKE0x0010  /* Balance on wakeup */
 #define SD_WAKE_AFFINE 0x0020  /* Wake task to waking CPU */
-#define SD_ASYM_CPUCAPACITY0x0040  /* Groups have different max cpu 
capacities */
-#define SD_SHARE_CPUCAPACITY   0x0080  /* Domain members share cpu capacity */
+#define SD_ASYM_CPUCAPACITY0x0040  /* Domain members have different CPU 
capacities */
+#define SD_SHARE_CPUCAPACITY   0x0080  /* Domain members share CPU capacity */
 #define SD_SHARE_POWERDOMAIN   0x0100  /* Domain members share power domain */
-#define SD_SHARE_PKG_RESOURCES 0x0200  /* Domain members share cpu pkg 
resources */
+#define SD_SHARE_PKG_RESOURCES 0x0200  /* Domain members share CPU pkg 
resources */
 #define SD_SERIALIZE   0x0400  /* Only a single load balancing 
instance */
 #define SD_ASYM_PACKING0x0800  /* Place busy groups earlier in 
the domain */
 #define SD_PREFER_SIBLING  0x1000  /* Prefer to place tasks in a sibling 
domain */
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 505a41c42b96..5c4d583d53ee 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -1061,7 +1061,6 @@ static struct cpumask 
***sched_domains_numa_masks;
  *   SD_SHARE_PKG_RESOURCES - describes shared caches
  *   SD_NUMA- describes NUMA topologies
  *   SD_SHARE_POWERDOMAIN   - describes shared power domain
- *   SD_ASYM_CPUCAPACITY- describes mixed capacity topologies
  *
  * Odd one out, which beside describing the topology has a quirk also
  * prescribes the desired behaviour that goes along with it:
@@ -1073,13 +1072,12 @@ static struct cpumask   
***sched_domains_numa_masks;
 SD_SHARE_PKG_RESOURCES |   \
 SD_NUMA|   \
 SD_ASYM_PACKING|   \
-SD_ASYM_CPUCAPACITY|   \
 SD_SHARE_POWERDOMAIN)
 
 static struct sched_domain *
 sd_init(struct sched_domain_topology_level *tl,
const struct cpumask *cpu_map,
-   struct sched_domain *child, int cpu)
+   struct sched_domain *child, int dflags, int cpu)
 {

[tip:sched/core] sched/topology: Add SD_ASYM_CPUCAPACITY flag detection

2018-09-10 Thread tip-bot for Morten Rasmussen
Commit-ID:  05484e0984487d42e97c417cbb0697fa9d16e7e9
Gitweb: https://git.kernel.org/tip/05484e0984487d42e97c417cbb0697fa9d16e7e9
Author: Morten Rasmussen 
AuthorDate: Fri, 20 Jul 2018 14:32:31 +0100
Committer:  Ingo Molnar 
CommitDate: Mon, 10 Sep 2018 11:05:45 +0200

sched/topology: Add SD_ASYM_CPUCAPACITY flag detection

The SD_ASYM_CPUCAPACITY sched_domain flag is supposed to mark the
sched_domain in the hierarchy where all CPU capacities are visible for
any CPU's point of view on asymmetric CPU capacity systems. The
scheduler can then take to take capacity asymmetry into account when
balancing at this level. It also serves as an indicator for how wide
task placement heuristics have to search to consider all available CPU
capacities as asymmetric systems might often appear symmetric at
smallest level(s) of the sched_domain hierarchy.

The flag has been around for while but so far only been set by
out-of-tree code in Android kernels. One solution is to let each
architecture provide the flag through a custom sched_domain topology
array and associated mask and flag functions. However,
SD_ASYM_CPUCAPACITY is special in the sense that it depends on the
capacity and presence of all CPUs in the system, i.e. when hotplugging
all CPUs out except those with one particular CPU capacity the flag
should disappear even if the sched_domains don't collapse. Similarly,
the flag is affected by cpusets where load-balancing is turned off.
Detecting when the flags should be set therefore depends not only on
topology information but also the cpuset configuration and hotplug
state. The arch code doesn't have easy access to the cpuset
configuration.

Instead, this patch implements the flag detection in generic code where
cpusets and hotplug state is already taken care of. All the arch is
responsible for is to implement arch_scale_cpu_capacity() and force a
full rebuild of the sched_domain hierarchy if capacities are updated,
e.g. later in the boot process when cpufreq has initialized.

Signed-off-by: Morten Rasmussen 
Signed-off-by: Peter Zijlstra (Intel) 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: dietmar.eggem...@arm.com
Cc: valentin.schnei...@arm.com
Cc: vincent.guit...@linaro.org
Link: 
http://lkml.kernel.org/r/1532093554-30504-2-git-send-email-morten.rasmus...@arm.com
[ Fixed 'CPU' capitalization. ]
Signed-off-by: Ingo Molnar 
---
 include/linux/sched/topology.h |  6 ++--
 kernel/sched/topology.c| 81 ++
 2 files changed, 78 insertions(+), 9 deletions(-)

diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h
index 26347741ba50..6b9976180c1e 100644
--- a/include/linux/sched/topology.h
+++ b/include/linux/sched/topology.h
@@ -23,10 +23,10 @@
 #define SD_BALANCE_FORK0x0008  /* Balance on fork, clone */
 #define SD_BALANCE_WAKE0x0010  /* Balance on wakeup */
 #define SD_WAKE_AFFINE 0x0020  /* Wake task to waking CPU */
-#define SD_ASYM_CPUCAPACITY0x0040  /* Groups have different max cpu 
capacities */
-#define SD_SHARE_CPUCAPACITY   0x0080  /* Domain members share cpu capacity */
+#define SD_ASYM_CPUCAPACITY0x0040  /* Domain members have different CPU 
capacities */
+#define SD_SHARE_CPUCAPACITY   0x0080  /* Domain members share CPU capacity */
 #define SD_SHARE_POWERDOMAIN   0x0100  /* Domain members share power domain */
-#define SD_SHARE_PKG_RESOURCES 0x0200  /* Domain members share cpu pkg 
resources */
+#define SD_SHARE_PKG_RESOURCES 0x0200  /* Domain members share CPU pkg 
resources */
 #define SD_SERIALIZE   0x0400  /* Only a single load balancing 
instance */
 #define SD_ASYM_PACKING0x0800  /* Place busy groups earlier in 
the domain */
 #define SD_PREFER_SIBLING  0x1000  /* Prefer to place tasks in a sibling 
domain */
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 505a41c42b96..5c4d583d53ee 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -1061,7 +1061,6 @@ static struct cpumask 
***sched_domains_numa_masks;
  *   SD_SHARE_PKG_RESOURCES - describes shared caches
  *   SD_NUMA- describes NUMA topologies
  *   SD_SHARE_POWERDOMAIN   - describes shared power domain
- *   SD_ASYM_CPUCAPACITY- describes mixed capacity topologies
  *
  * Odd one out, which beside describing the topology has a quirk also
  * prescribes the desired behaviour that goes along with it:
@@ -1073,13 +1072,12 @@ static struct cpumask   
***sched_domains_numa_masks;
 SD_SHARE_PKG_RESOURCES |   \
 SD_NUMA|   \
 SD_ASYM_PACKING|   \
-SD_ASYM_CPUCAPACITY|   \
 SD_SHARE_POWERDOMAIN)
 
 static struct sched_domain *
 sd_init(struct sched_domain_topology_level *tl,
const struct cpumask *cpu_map,
-   struct sched_domain *child, int cpu)
+   struct sched_domain *child, int dflags, int cpu)
 {