Re: [PATCH 7/7] sched_ext: Misc updates around scx_sched instance pointer

From: Andrea Righi

Date: Tue Sep 23 2025 - 04:37:05 EST


Hi Tejun,

On Mon, Sep 22, 2025 at 06:14:36AM -1000, Tejun Heo wrote:
> In preparation for multiple scheduler support:
>
> - Add the @sch parameter to find_global_dsq() and refill_task_slice_dfl().
>
> - Restructure scx_allow_ttwu_queue() and make it read scx_root into $sch.
>
> - Make RCU protection in scx_dsq_move() and scx_bpf_dsq_move_to_local()
> explicit.
>
> Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>
> ---
> kernel/sched/ext.c | 62 ++++++++++++++++++++++++++++++----------------
> 1 file changed, 40 insertions(+), 22 deletions(-)
>
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index 0c99a55f199b..32306203fba5 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
...
> @@ -3572,9 +3571,22 @@ bool task_should_scx(int policy)
>
> bool scx_allow_ttwu_queue(const struct task_struct *p)
> {
> - return !scx_enabled() ||
> - (scx_root->ops.flags & SCX_OPS_ALLOW_QUEUED_WAKEUP) ||
> - p->sched_class != &ext_sched_class;
> + struct scx_sched *sch;
> +
> + if (!scx_enabled())
> + return true;
> +
> + sch = rcu_dereference_sched(scx_root);
> + if (unlikely(!sch))
> + return true;
> +
> + if (scx_root->ops.flags & SCX_OPS_ALLOW_QUEUED_WAKEUP)

We should use sch->ops.flags here.

> + return true;
> +
> + if (unlikely(p->sched_class != &ext_sched_class))
> + return true;
> +
> + return false;
> }

Thanks,
-Andrea