OSDN Git Service

FROMLIST: cpufreq/schedutil: use rt utilization tracking
authorVincent Guittot <vincent.guittot@linaro.org>
Mon, 19 Feb 2018 09:14:49 +0000 (10:14 +0100)
committerAmit Pundir <amit.pundir@linaro.org>
Tue, 14 Aug 2018 12:17:11 +0000 (17:47 +0530)
Add both cfs and rt utilization when selecting an OPP for cfs tasks as rt
can preempt and steal cfs's running time.

rt util_avg is used to take into account the utilization of rt tasks
on the CPU when selecting OPP. If a rt task migrate, the rt utilization
will not migrate but will decay over time. On an overloaded CPU, cfs
utilization reflects the remaining utilization avialable on CPU. When rt
task migrates, the cfs utilization will increase when tasks will start to
use the newly available capacity. At the same pace, rt utilization will
decay and both variations will compensate each other  to keep unchanged
overall utilization and will prevent any OPP drop.

Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
Change-Id: Iaf97832858db8f857036f31b57058cee55e42cde

kernel/sched/cpufreq_schedutil.c

index 7447fd3..dd09c1c 100644 (file)
@@ -57,6 +57,7 @@ struct sugov_cpu {
        /* The fields below are only needed when sharing a policy: */
        unsigned long           util_cfs;
        unsigned long           util_dl;
+       unsigned long           util_rt;
        unsigned long           max;
 
        /* The field below is for single-CPU policies only: */
@@ -187,15 +188,21 @@ static void sugov_get_util(struct sugov_cpu *sg_cpu)
        sg_cpu->max = arch_scale_cpu_capacity(NULL, sg_cpu->cpu);
        sg_cpu->util_cfs = cpu_util_cfs(rq);
        sg_cpu->util_dl  = cpu_util_dl(rq);
+       sg_cpu->util_rt  = cpu_util_rt(rq);
 }
 
 static unsigned long sugov_aggregate_util(struct sugov_cpu *sg_cpu)
 {
        struct rq *rq = cpu_rq(sg_cpu->cpu);
+       unsigned long util;
 
        if (rt_rq_is_runnable(&rq->rt))
                return sg_cpu->max;
 
+       util = sg_cpu->util_dl;
+       util += sg_cpu->util_cfs;
+       util += sg_cpu->util_rt;
+
        /*
         * Utilization required by DEADLINE must always be granted while, for
         * FAIR, we use blocked utilization of IDLE CPUs as a mechanism to
@@ -206,7 +213,7 @@ static unsigned long sugov_aggregate_util(struct sugov_cpu *sg_cpu)
         * util_cfs + util_dl as requested freq. However, cpufreq is not yet
         * ready for such an interface. So, we only do the latter for now.
         */
-       return min(sg_cpu->max, (sg_cpu->util_dl + sg_cpu->util_cfs));
+       return min(sg_cpu->max, util);
 }
 
 /**