Merge tag 'mips_5.12_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux
[linux-2.6-microblaze.git] / kernel / sched / cpufreq_schedutil.c
index 6931f0c..50cbad8 100644 (file)
@@ -26,7 +26,7 @@ struct sugov_policy {
        struct sugov_tunables   *tunables;
        struct list_head        tunables_hook;
 
-       raw_spinlock_t          update_lock;    /* For shared policies */
+       raw_spinlock_t          update_lock;
        u64                     last_freq_update_time;
        s64                     freq_update_delay_ns;
        unsigned int            next_freq;
@@ -171,112 +171,6 @@ static unsigned int get_next_freq(struct sugov_policy *sg_policy,
        return cpufreq_driver_resolve_freq(policy, freq);
 }
 
-/*
- * This function computes an effective utilization for the given CPU, to be
- * used for frequency selection given the linear relation: f = u * f_max.
- *
- * The scheduler tracks the following metrics:
- *
- *   cpu_util_{cfs,rt,dl,irq}()
- *   cpu_bw_dl()
- *
- * Where the cfs,rt and dl util numbers are tracked with the same metric and
- * synchronized windows and are thus directly comparable.
- *
- * The cfs,rt,dl utilization are the running times measured with rq->clock_task
- * which excludes things like IRQ and steal-time. These latter are then accrued
- * in the irq utilization.
- *
- * The DL bandwidth number otoh is not a measured metric but a value computed
- * based on the task model parameters and gives the minimal utilization
- * required to meet deadlines.
- */
-unsigned long schedutil_cpu_util(int cpu, unsigned long util_cfs,
-                                unsigned long max, enum schedutil_type type,
-                                struct task_struct *p)
-{
-       unsigned long dl_util, util, irq;
-       struct rq *rq = cpu_rq(cpu);
-
-       if (!uclamp_is_used() &&
-           type == FREQUENCY_UTIL && rt_rq_is_runnable(&rq->rt)) {
-               return max;
-       }
-
-       /*
-        * Early check to see if IRQ/steal time saturates the CPU, can be
-        * because of inaccuracies in how we track these -- see
-        * update_irq_load_avg().
-        */
-       irq = cpu_util_irq(rq);
-       if (unlikely(irq >= max))
-               return max;
-
-       /*
-        * Because the time spend on RT/DL tasks is visible as 'lost' time to
-        * CFS tasks and we use the same metric to track the effective
-        * utilization (PELT windows are synchronized) we can directly add them
-        * to obtain the CPU's actual utilization.
-        *
-        * CFS and RT utilization can be boosted or capped, depending on
-        * utilization clamp constraints requested by currently RUNNABLE
-        * tasks.
-        * When there are no CFS RUNNABLE tasks, clamps are released and
-        * frequency will be gracefully reduced with the utilization decay.
-        */
-       util = util_cfs + cpu_util_rt(rq);
-       if (type == FREQUENCY_UTIL)
-               util = uclamp_rq_util_with(rq, util, p);
-
-       dl_util = cpu_util_dl(rq);
-
-       /*
-        * For frequency selection we do not make cpu_util_dl() a permanent part
-        * of this sum because we want to use cpu_bw_dl() later on, but we need
-        * to check if the CFS+RT+DL sum is saturated (ie. no idle time) such
-        * that we select f_max when there is no idle time.
-        *
-        * NOTE: numerical errors or stop class might cause us to not quite hit
-        * saturation when we should -- something for later.
-        */
-       if (util + dl_util >= max)
-               return max;
-
-       /*
-        * OTOH, for energy computation we need the estimated running time, so
-        * include util_dl and ignore dl_bw.
-        */
-       if (type == ENERGY_UTIL)
-               util += dl_util;
-
-       /*
-        * There is still idle time; further improve the number by using the
-        * irq metric. Because IRQ/steal time is hidden from the task clock we
-        * need to scale the task numbers:
-        *
-        *              max - irq
-        *   U' = irq + --------- * U
-        *                 max
-        */
-       util = scale_irq_capacity(util, irq, max);
-       util += irq;
-
-       /*
-        * Bandwidth required by DEADLINE must always be granted while, for
-        * FAIR and RT, we use blocked utilization of IDLE CPUs as a mechanism
-        * to gracefully reduce the frequency when no tasks show up for longer
-        * periods of time.
-        *
-        * Ideally we would like to set bw_dl as min/guaranteed freq and util +
-        * bw_dl as requested freq. However, cpufreq is not yet ready for such
-        * an interface. So, we only do the latter for now.
-        */
-       if (type == FREQUENCY_UTIL)
-               util += cpu_bw_dl(rq);
-
-       return min(max, util);
-}
-
 static void sugov_get_util(struct sugov_cpu *sg_cpu)
 {
        struct rq *rq = cpu_rq(sg_cpu->cpu);
@@ -284,7 +178,7 @@ static void sugov_get_util(struct sugov_cpu *sg_cpu)
 
        sg_cpu->max = max;
        sg_cpu->bw_dl = cpu_bw_dl(rq);
-       sg_cpu->util = schedutil_cpu_util(sg_cpu->cpu, cpu_util_cfs(rq), max,
+       sg_cpu->util = effective_cpu_util(sg_cpu->cpu, cpu_util_cfs(rq), max,
                                          FREQUENCY_UTIL, NULL);
 }
 
@@ -426,23 +320,21 @@ static inline bool sugov_cpu_is_busy(struct sugov_cpu *sg_cpu) { return false; }
  * Make sugov_should_update_freq() ignore the rate limit when DL
  * has increased the utilization.
  */
-static inline void ignore_dl_rate_limit(struct sugov_cpu *sg_cpu, struct sugov_policy *sg_policy)
+static inline void ignore_dl_rate_limit(struct sugov_cpu *sg_cpu)
 {
        if (cpu_bw_dl(cpu_rq(sg_cpu->cpu)) > sg_cpu->bw_dl)
-               sg_policy->limits_changed = true;
+               sg_cpu->sg_policy->limits_changed = true;
 }
 
 static inline bool sugov_update_single_common(struct sugov_cpu *sg_cpu,
                                              u64 time, unsigned int flags)
 {
-       struct sugov_policy *sg_policy = sg_cpu->sg_policy;
-
        sugov_iowait_boost(sg_cpu, time, flags);
        sg_cpu->last_update = time;
 
-       ignore_dl_rate_limit(sg_cpu, sg_policy);
+       ignore_dl_rate_limit(sg_cpu);
 
-       if (!sugov_should_update_freq(sg_policy, time))
+       if (!sugov_should_update_freq(sg_cpu->sg_policy, time))
                return false;
 
        sugov_get_util(sg_cpu);
@@ -557,7 +449,7 @@ sugov_update_shared(struct update_util_data *hook, u64 time, unsigned int flags)
        sugov_iowait_boost(sg_cpu, time, flags);
        sg_cpu->last_update = time;
 
-       ignore_dl_rate_limit(sg_cpu, sg_policy);
+       ignore_dl_rate_limit(sg_cpu);
 
        if (sugov_should_update_freq(sg_policy, time)) {
                next_f = sugov_next_freq_shared(sg_cpu, time);