UPSTREAM: sched/fair: Add per-CPU min capacity to sched_group_capacity
authorMorten Rasmussen <morten.rasmussen@arm.com>
Fri, 14 Oct 2016 13:41:09 +0000 (14:41 +0100)
committerAmit Pundir <amit.pundir@linaro.org>
Wed, 21 Jun 2017 11:07:24 +0000 (16:37 +0530)
struct sched_group_capacity currently represents the compute capacity
sum of all CPUs in the sched_group.

Unless it is divided by the group_weight to get the average capacity
per CPU, it hides differences in CPU capacity for mixed capacity systems
(e.g. high RT/IRQ utilization or ARM big.LITTLE).

But even the average may not be sufficient if the group covers CPUs of
different capacities.

Instead, by extending struct sched_group_capacity to indicate min per-CPU
capacity in the group a suitable group for a given task utilization can
more easily be found such that CPUs with reduced capacity can be avoided
for tasks with high utilization (not implemented by this patch).

Change-Id: If3cae1be62d01a199e752bca5abb45357d5d0fbd
Signed-off-by: Morten Rasmussen <morten.rasmussen@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: dietmar.eggemann@arm.com
Cc: freedom.tan@mediatek.com
Cc: keita.kobayashi.ym@renesas.com
Cc: mgalbraith@suse.de
Cc: sgurrappadi@nvidia.com
Cc: vincent.guittot@linaro.org
Cc: yuyang.du@intel.com
Link: http://lkml.kernel.org/r/1476452472-24740-4-git-send-email-morten.rasmussen@arm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
(cherry picked from commit bf475ce0a3dd75b5d1df6c6c14ae25168caa15ac)
Signed-off-by: Chris Redpath <chris.redpath@arm.com>
kernel/sched/core.c
kernel/sched/fair.c
kernel/sched/sched.h

index fcef2588712a2e141d782eda10a2586f15bc33ad..948ef2438606172256d3c9b453ec00210b58960a 100644 (file)
@@ -6459,6 +6459,7 @@ build_overlap_sched_groups(struct sched_domain *sd, int cpu)
                 */
                sg->sgc->capacity = SCHED_CAPACITY_SCALE * cpumask_weight(sg_span);
                sg->sgc->max_capacity = SCHED_CAPACITY_SCALE;
+               sg->sgc->min_capacity = SCHED_CAPACITY_SCALE;
 
                /*
                 * Make sure the first group of this domain contains the
index 82eb26bd4361e2f4f20fca366a09717ede0842e3..d18e2c7b67e59868a64d3ab15af49c394b15d524 100644 (file)
@@ -7268,13 +7268,14 @@ skip_unlock: __attribute__ ((unused));
        cpu_rq(cpu)->cpu_capacity = capacity;
        sdg->sgc->capacity = capacity;
        sdg->sgc->max_capacity = capacity;
+       sdg->sgc->min_capacity = capacity;
 }
 
 void update_group_capacity(struct sched_domain *sd, int cpu)
 {
        struct sched_domain *child = sd->child;
        struct sched_group *group, *sdg = sd->groups;
-       unsigned long capacity, max_capacity;
+       unsigned long capacity, max_capacity, min_capacity;
        unsigned long interval;
 
        interval = msecs_to_jiffies(sd->balance_interval);
@@ -7288,6 +7289,7 @@ void update_group_capacity(struct sched_domain *sd, int cpu)
 
        capacity = 0;
        max_capacity = 0;
+       min_capacity = ULONG_MAX;
 
        if (child->flags & SD_OVERLAP) {
                /*
@@ -7318,6 +7320,7 @@ void update_group_capacity(struct sched_domain *sd, int cpu)
                        }
 
                        max_capacity = max(capacity, max_capacity);
+                       min_capacity = min(capacity, min_capacity);
                }
        } else  {
                /*
@@ -7331,12 +7334,14 @@ void update_group_capacity(struct sched_domain *sd, int cpu)
 
                        capacity += sgc->capacity;
                        max_capacity = max(sgc->max_capacity, max_capacity);
+                       min_capacity = min(sgc->min_capacity, min_capacity);
                        group = group->next;
                } while (group != child->groups);
        }
 
        sdg->sgc->capacity = capacity;
        sdg->sgc->max_capacity = max_capacity;
+       sdg->sgc->min_capacity = min_capacity;
 }
 
 /*
index 237b0bcdd30479dcf8ccf54f3301125faf2db4cd..6bc2dd623b17c051e1b6d16136673cee3b41274a 100644 (file)
@@ -899,6 +899,7 @@ struct sched_group_capacity {
         */
        unsigned long capacity;
        unsigned long max_capacity; /* Max per-cpu capacity in group */
+       unsigned long min_capacity; /* Min per-CPU capacity in group */
        unsigned long next_update;
        int imbalance; /* XXX unrelated to capacity but shared group state */
        /*