Re: [PATCH RFC 3/8] sched/ext: Add a DL server for sched_ext tasks

From: Andrea Righi
Date: Sat Mar 15 2025 - 13:57:02 EST


Hi Joel,

On Fri, Mar 14, 2025 at 10:21:50PM -0400, Joel Fernandes wrote:
...
> @@ -7793,6 +7819,38 @@ BTF_ID_FLAGS(func, scx_bpf_task_cgroup, KF_RCU | KF_ACQUIRE)
> BTF_ID_FLAGS(func, scx_bpf_now)
> BTF_KFUNCS_END(scx_kfunc_ids_any)
>
> +/*
> + * Check if ext scheduler has tasks ready to run.
> + */
> +static bool ext_server_has_tasks(struct sched_dl_entity *dl_se)
> +{
> + return !!dl_se->rq->scx.nr_running;
> +}
> +
> +/*
> + * Select the next task to run from the ext scheduling class.
> + */
> +static struct task_struct *ext_server_pick_task(struct sched_dl_entity *dl_se,
> + void *flags)
> +{
> + struct rq_flags *rf = flags;
> +

It'd be nice to add a comment here to clarify that we need to call
balance_scx() before pick_task_scx(), so that we can trigger ops.dispatch()
and consume tasks that may be pending in the BPF scheduler's DSQs,
otherwise pick_task_scx() may not find any scx task to run, reducing the
effectiveness of the dl_server.

> + balance_scx(dl_se->rq, dl_se->rq->curr, rf);
> + return pick_task_scx(dl_se->rq, rf);
> +}

Thanks,
-Andrea