sched: Restrict nohz balance kicks to stay in the HMP domain
authorChris Redpath <chris.redpath@arm.com>
Tue, 3 Feb 2015 05:03:11 +0000 (14:03 +0900)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Wed, 14 Dec 2016 04:41:39 +0000 (13:41 +0900)
There is little point in doing a nohz balance kick on a CPU from a
different HMP domain, since the unset SD_LOAD_BALANCE flag on the CPU
domain level prevents tasks from being balanced across clusters
except through the per-task load driven hmp_migrate/hmp_offload paths.

Further, the nohz balance kick is actively harmful to power usage if
all the tasks fit into the little domain since it causes the big
domain to wake up and do a lot of calculation to determine that
there is nothing to do.

A more generic solution is to walk the sched domain tree and determine
the intersection of potential idle balance cpus with visibility of
tasks on the current CPU, however HMP domains are more easily
accessible.

Signed-off-by: Chris Redpath <chris.redpath@arm.com>
[k.kozlowski: rebased on 4.1, no signed-off-by of previous committer]
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
kernel/sched/fair.c

index 573b848..af34e1e 100644 (file)
@@ -8054,6 +8054,12 @@ static inline int find_new_ilb(void)
 {
        int ilb = cpumask_first(nohz.idle_cpus_mask);
 
+#ifdef CONFIG_SCHED_HMP
+       /* restrict nohz balancing to occur in the same hmp domain */
+       ilb = cpumask_first_and(nohz.idle_cpus_mask,
+                       &((struct hmp_domain *)hmp_cpu_domain(call_cpu))->cpus);
+#endif
+
        if (ilb < nr_cpu_ids && idle_cpu(ilb))
                return ilb;
 
@@ -8369,6 +8375,18 @@ static inline bool nohz_kick_needed(struct rq *rq)
        if (time_before(now, nohz.next_balance))
                return false;
 
+#ifdef CONFIG_SCHED_HMP
+       /*
+        * Bail out if there are no nohz CPUs in our
+        * HMP domain, since we will move tasks between
+        * domains through wakeup and force balancing
+        * as necessary based upon task load.
+        */
+       if (cpumask_first_and(nohz.idle_cpus_mask,
+                       &((struct hmp_domain *)hmp_cpu_domain(cpu))->cpus) >= nr_cpu_ids)
+               return 0;
+#endif
+
        if (rq->nr_running >= 2)
                return true;