Merge tag 'sched_urgent_for_v5.14' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-microblaze.git] / kernel / sched / sched.h
index c80d42e..ddefb04 100644 (file)
@@ -1093,7 +1093,7 @@ struct rq {
        unsigned int            core_sched_seq;
        struct rb_root          core_tree;
 
-       /* shared state */
+       /* shared state -- careful with sched_core_cpu_deactivate() */
        unsigned int            core_task_seq;
        unsigned int            core_pick_seq;
        unsigned long           core_cookie;
@@ -2255,6 +2255,9 @@ static inline struct task_struct *get_push_task(struct rq *rq)
        if (p->nr_cpus_allowed == 1)
                return NULL;
 
+       if (p->migration_disabled)
+               return NULL;
+
        rq->push_busy = true;
        return get_task_struct(p);
 }
@@ -2818,20 +2821,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