Merge branch 'sched/core' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip...
authorTejun Heo <tj@kernel.org>
Sun, 4 Aug 2024 17:07:40 +0000 (07:07 -1000)
committerTejun Heo <tj@kernel.org>
Sun, 4 Aug 2024 17:36:54 +0000 (07:36 -1000)
Pull tip/sched/core to resolve the following four conflicts. While 2-4 are
simple context conflicts, 1 is a bit subtle and easy to resolve incorrectly.

1. 2c8d046d5d51 ("sched: Add normal_policy()")
   vs.
   faa42d29419d ("sched/fair: Make SCHED_IDLE entity be preempted in strict hierarchy")

The former converts direct test on p->policy to use the helper
normal_policy(). The latter moves the p->policy test to a different
location. Resolve by converting the test on p->plicy in the new location to
use normal_policy().

2. a7a9fc549293 ("sched_ext: Add boilerplate for extensible scheduler class")
   vs.
   a110a81c52a9 ("sched/deadline: Deferrable dl server")

Both add calls to put_prev_task_idle() and set_next_task_idle(). Simple
context conflict. Resolve by taking changes from both.

3. a7a9fc549293 ("sched_ext: Add boilerplate for extensible scheduler class")
   vs.
   c245910049d0 ("sched/core: Add clearing of ->dl_server in put_prev_task_balance()")

The former changes for_each_class() itertion to use for_each_active_class().
The latter moves away the adjacent dl_server handling code. Simple context
conflict. Resolve by taking changes from both.

4. 60c27fb59f6c ("sched_ext: Implement sched_ext_ops.cpu_online/offline()")
   vs.
   31b164e2e4af ("sched/smt: Introduce sched_smt_present_inc/dec() helper")
   2f027354122f ("sched/core: Introduce sched_set_rq_on/offline() helper")

The former adds scx_rq_deactivate() call. The latter two change code around
it. Simple context conflict. Resolve by taking changes from both.

Signed-off-by: Tejun Heo <tj@kernel.org>
1  2 
include/linux/sched.h
kernel/sched/core.c
kernel/sched/debug.c
kernel/sched/fair.c
kernel/sched/idle.c
kernel/sched/sched.h

Simple merge
index 22f86d5e9231575132113fad353ac1f5664f50b8,29fde993d3f8ba247caed4512381518862182e72..ec67b30f87c481b3e802fd00f4593dfd691e19e1
@@@ -5901,23 -5878,10 +5947,15 @@@ __pick_next_task(struct rq *rq, struct 
  restart:
        put_prev_task_balance(rq, prev, rf);
  
-       /*
-        * We've updated @prev and no longer need the server link, clear it.
-        * Must be done before ->pick_next_task() because that can (re)set
-        * ->dl_server.
-        */
-       if (prev->dl_server)
-               prev->dl_server = NULL;
 -      for_each_class(class) {
 +      for_each_active_class(class) {
                p = class->pick_next_task(rq);
 -              if (p)
 +              if (p) {
 +                      const struct sched_class *prev_class = prev->sched_class;
 +
 +                      if (class != prev_class && prev_class->switch_class)
 +                              prev_class->switch_class(rq, p);
                        return p;
 +              }
        }
  
        BUG(); /* The idle class should always have a runnable task. */
@@@ -8056,16 -8042,8 +8124,10 @@@ int sched_cpu_deactivate(unsigned int c
         */
        synchronize_rcu();
  
-       rq_lock_irqsave(rq, &rf);
-       if (rq->rd) {
-               BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span));
-               set_rq_offline(rq);
-       }
-       rq_unlock_irqrestore(rq, &rf);
+       sched_set_rq_offline(rq, cpu);
  
- #ifdef CONFIG_SCHED_SMT
 +      scx_rq_deactivate(rq);
 +
        /*
         * When going down, decrement the number of cores with SMT present.
         */
Simple merge
index 5904405ffc59d13e39affa81c20f6761956bb597,795ceef5e7e146f99ea05f8d86ea9aeae0c7df9c..8a37409c23f5c137819464fdf7c51595c16989b0
@@@ -8409,9 -8432,14 +8433,14 @@@ static void check_preempt_wakeup_fair(s
        if (cse_is_idle != pse_is_idle)
                return;
  
 -      if (unlikely(p->policy != SCHED_NORMAL))
+       /*
+        * BATCH and IDLE tasks do not preempt others.
+        */
++      if (unlikely(!normal_policy(p->policy)))
+               return;
        cfs_rq = cfs_rq_of(se);
        update_curr(cfs_rq);
        /*
         * XXX pick_eevdf(cfs_rq) != se ?
         */
index c7a218123b7ac6c7b62ec54acd7403f7b2feb058,d560f7ffa463f6e82a458634fe216e6c058bd1e3..e53e2da04ba45d9e37f7e3ac09d66ad89f9a0a9c
@@@ -452,14 -452,14 +452,16 @@@ static void wakeup_preempt_idle(struct 
  
  static void put_prev_task_idle(struct rq *rq, struct task_struct *prev)
  {
+       dl_server_update_idle_time(rq, prev);
 +      scx_update_idle(rq, false);
  }
  
  static void set_next_task_idle(struct rq *rq, struct task_struct *next, bool first)
  {
        update_idle_core(rq);
 +      scx_update_idle(rq, true);
        schedstat_inc(rq->sched_goidle);
+       next->se.exec_start = rq_clock_task(rq);
  }
  
  #ifdef CONFIG_SMP
index 42b4d1428c2c2ac648fa0c1098314e7ae4e8b45a,1e1d1b467af2c9690854f8b957ebd6ca48fe110c..c74ef008f3ae2762aedab4df0fe7a4b6686e21f5
@@@ -1106,10 -1046,9 +1109,12 @@@ struct rq 
        struct cfs_rq           cfs;
        struct rt_rq            rt;
        struct dl_rq            dl;
 +#ifdef CONFIG_SCHED_CLASS_EXT
 +      struct scx_rq           scx;
 +#endif
  
+       struct sched_dl_entity  fair_server;
  #ifdef CONFIG_FAIR_GROUP_SCHED
        /* list of leaf cfs_rq on this CPU: */
        struct list_head        leaf_cfs_rq_list;