]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
sched_ext: Always use SMP versions in kernel/sched/ext.c
authorCheng-Yang Chou <yphbchou0911@gmail.com>
Wed, 11 Jun 2025 13:54:01 +0000 (21:54 +0800)
committerTejun Heo <tj@kernel.org>
Sat, 14 Jun 2025 00:29:39 +0000 (14:29 -1000)
Simplify the scheduler by making formerly SMP-only primitives and data
structures unconditional.

tj: Updated subject for clarity.

Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/sched/ext.c

index 3623ba98d7d83b8b94a80930f9a8e5d982ce7908..28bb6810e5d1804e54eda6916d3d551e17e41fa7 100644 (file)
@@ -1778,12 +1778,10 @@ static void run_deferred(struct rq *rq)
        process_ddsp_deferred_locals(rq);
 }
 
-#ifdef CONFIG_SMP
 static void deferred_bal_cb_workfn(struct rq *rq)
 {
        run_deferred(rq);
 }
-#endif
 
 static void deferred_irq_workfn(struct irq_work *irq_work)
 {
@@ -1806,7 +1804,6 @@ static void schedule_deferred(struct rq *rq)
 {
        lockdep_assert_rq_held(rq);
 
-#ifdef CONFIG_SMP
        /*
         * If in the middle of waking up a task, task_woken_scx() will be called
         * afterwards which will then run the deferred actions, no need to
@@ -1824,7 +1821,7 @@ static void schedule_deferred(struct rq *rq)
                                       deferred_bal_cb_workfn);
                return;
        }
-#endif
+
        /*
         * No scheduler hooks available. Queue an irq work. They are executed on
         * IRQ re-enable which may take a bit longer than the scheduler hooks.
@@ -2528,7 +2525,6 @@ static void move_local_task_to_local_dsq(struct task_struct *p, u64 enq_flags,
        p->scx.dsq = dst_dsq;
 }
 
-#ifdef CONFIG_SMP
 /**
  * move_remote_task_to_local_dsq - Move a task from a foreign rq to a local DSQ
  * @p: task to move
@@ -2695,11 +2691,6 @@ static bool consume_remote_task(struct rq *this_rq, struct task_struct *p,
                return false;
        }
 }
-#else  /* CONFIG_SMP */
-static inline void move_remote_task_to_local_dsq(struct task_struct *p, u64 enq_flags, struct rq *src_rq, struct rq *dst_rq) { WARN_ON_ONCE(1); }
-static inline bool task_can_run_on_remote_rq(struct scx_sched *sch, struct task_struct *p, struct rq *rq, bool enforce) { return false; }
-static inline bool consume_remote_task(struct rq *this_rq, struct task_struct *p, struct scx_dispatch_q *dsq, struct rq *task_rq) { return false; }
-#endif /* CONFIG_SMP */
 
 /**
  * move_task_between_dsqs() - Move a task from one DSQ to another
@@ -2872,9 +2863,7 @@ static void dispatch_to_local_dsq(struct scx_sched *sch, struct rq *rq,
 {
        struct rq *src_rq = task_rq(p);
        struct rq *dst_rq = container_of(dst_dsq, struct rq, scx.local_dsq);
-#ifdef CONFIG_SMP
        struct rq *locked_rq = rq;
-#endif
 
        /*
         * We're synchronized against dequeue through DISPATCHING. As @p can't
@@ -2888,7 +2877,6 @@ static void dispatch_to_local_dsq(struct scx_sched *sch, struct rq *rq,
                return;
        }
 
-#ifdef CONFIG_SMP
        if (src_rq != dst_rq &&
            unlikely(!task_can_run_on_remote_rq(sch, p, dst_rq, true))) {
                dispatch_enqueue(sch, find_global_dsq(p), p,
@@ -2948,9 +2936,6 @@ static void dispatch_to_local_dsq(struct scx_sched *sch, struct rq *rq,
                raw_spin_rq_unlock(locked_rq);
                raw_spin_rq_lock(rq);
        }
-#else  /* CONFIG_SMP */
-       BUG();  /* control can not reach here on UP */
-#endif /* CONFIG_SMP */
 }
 
 /**
@@ -3274,10 +3259,8 @@ static void set_next_task_scx(struct rq *rq, struct task_struct *p, bool first)
 static enum scx_cpu_preempt_reason
 preempt_reason_from_class(const struct sched_class *class)
 {
-#ifdef CONFIG_SMP
        if (class == &stop_sched_class)
                return SCX_CPU_PREEMPT_STOP;
-#endif
        if (class == &dl_sched_class)
                return SCX_CPU_PREEMPT_DL;
        if (class == &rt_sched_class)
@@ -3290,14 +3273,12 @@ static void switch_class(struct rq *rq, struct task_struct *next)
        struct scx_sched *sch = scx_root;
        const struct sched_class *next_class = next->sched_class;
 
-#ifdef CONFIG_SMP
        /*
         * Pairs with the smp_load_acquire() issued by a CPU in
         * kick_cpus_irq_workfn() who is waiting for this CPU to perform a
         * resched.
         */
        smp_store_release(&rq->scx.pnt_seq, rq->scx.pnt_seq + 1);
-#endif
        if (!(sch->ops.flags & SCX_OPS_HAS_CPU_PREEMPT))
                return;
 
@@ -3494,8 +3475,6 @@ bool scx_prio_less(const struct task_struct *a, const struct task_struct *b,
 }
 #endif /* CONFIG_SCHED_CORE */
 
-#ifdef CONFIG_SMP
-
 static int select_task_rq_scx(struct task_struct *p, int prev_cpu, int wake_flags)
 {
        struct scx_sched *sch = scx_root;
@@ -3625,7 +3604,6 @@ static void rq_offline_scx(struct rq *rq)
        rq->scx.flags &= ~SCX_RQ_ONLINE;
 }
 
-#endif /* CONFIG_SMP */
 
 static bool check_rq_for_timeouts(struct rq *rq)
 {
@@ -4285,14 +4263,12 @@ DEFINE_SCHED_CLASS(ext) = {
        .put_prev_task          = put_prev_task_scx,
        .set_next_task          = set_next_task_scx,
 
-#ifdef CONFIG_SMP
        .select_task_rq         = select_task_rq_scx,
        .task_woken             = task_woken_scx,
        .set_cpus_allowed       = set_cpus_allowed_scx,
 
        .rq_online              = rq_online_scx,
        .rq_offline             = rq_offline_scx,
-#endif
 
        .task_tick              = task_tick_scx,