Merge branch 'sched/core'
[platform/kernel/linux-rpi.git] / kernel / sched / sched.h
index e7e2bba..a9a660c 100644 (file)
@@ -2844,20 +2844,27 @@ static __always_inline
 unsigned long uclamp_rq_util_with(struct rq *rq, unsigned long util,
                                  struct task_struct *p)
 {
-       unsigned long min_util;
-       unsigned long max_util;
+       unsigned long min_util = 0;
+       unsigned long max_util = 0;
 
        if (!static_branch_likely(&sched_uclamp_used))
                return util;
 
-       min_util = READ_ONCE(rq->uclamp[UCLAMP_MIN].value);
-       max_util = READ_ONCE(rq->uclamp[UCLAMP_MAX].value);
-
        if (p) {
-               min_util = max(min_util, uclamp_eff_value(p, UCLAMP_MIN));
-               max_util = max(max_util, uclamp_eff_value(p, UCLAMP_MAX));
+               min_util = uclamp_eff_value(p, UCLAMP_MIN);
+               max_util = uclamp_eff_value(p, UCLAMP_MAX);
+
+               /*
+                * Ignore last runnable task's max clamp, as this task will
+                * reset it. Similarly, no need to read the rq's min clamp.
+                */
+               if (rq->uclamp_flags & UCLAMP_FLAG_IDLE)
+                       goto out;
        }
 
+       min_util = max_t(unsigned long, min_util, READ_ONCE(rq->uclamp[UCLAMP_MIN].value));
+       max_util = max_t(unsigned long, max_util, READ_ONCE(rq->uclamp[UCLAMP_MAX].value));
+out:
        /*
         * Since CPU's {min,max}_util clamps are MAX aggregated considering
         * RUNNABLE tasks with _different_ clamps, we can end up with an