Re: [PATCH 4/7] sched_ext: Add a DL server for sched_ext tasks
From: Peter Zijlstra
Date: Mon Feb 02 2026 - 14:54:30 EST
On Mon, Jan 26, 2026 at 10:59:02AM +0100, Andrea Righi wrote:
> @@ -3181,6 +3193,36 @@ void dl_add_task_root_domain(struct task_struct *p)
> raw_spin_unlock_irqrestore(&p->pi_lock, rf.flags);
> }
>
> +static void dl_server_add_bw(struct root_domain *rd, int cpu)
> +{
> + struct sched_dl_entity *dl_se;
> +
> + dl_se = &cpu_rq(cpu)->fair_server;
> + if (dl_server(dl_se) && cpu_active(cpu))
> + __dl_add(&rd->dl_bw, dl_se->dl_bw, dl_bw_cpus(cpu));
> +
> +#ifdef CONFIG_SCHED_CLASS_EXT
> + dl_se = &cpu_rq(cpu)->ext_server;
> + if (dl_server(dl_se) && cpu_active(cpu))
> + __dl_add(&rd->dl_bw, dl_se->dl_bw, dl_bw_cpus(cpu));
> +#endif
> +}
> +
> +static u64 dl_server_read_bw(int cpu)
> +{
> + u64 dl_bw = 0;
> +
> + if (cpu_rq(cpu)->fair_server.dl_server)
> + dl_bw += cpu_rq(cpu)->fair_server.dl_bw;
> +
> +#ifdef CONFIG_SCHED_CLASS_EXT
> + if (cpu_rq(cpu)->ext_server.dl_server)
> + dl_bw += cpu_rq(cpu)->ext_server.dl_bw;
> +#endif
> +
> + return dl_bw;
> +}
Should not this also depend on scx_enabled()? It seems unfortunate to
consume bandwidth if scx isn't even enabled.
> @@ -1501,6 +1503,10 @@ static void enqueue_task_scx(struct rq *rq, struct task_struct *p, int enq_flags
> if (enq_flags & SCX_ENQ_WAKEUP)
> touch_core_sched(rq, p);
>
> + /* Start dl_server if this is the first task being enqueued */
> + if (rq->scx.nr_running == 1)
> + dl_server_start(&rq->ext_server);
> +
> do_enqueue_task(rq, p, enq_flags, sticky_cpu);
> out:
> rq->scx.flags &= ~SCX_RQ_IN_WAKEUP;
So this starts the dl_server for the CPU the thing gets enqueued on, but
SCX being what it is, there is absolutely no guarantee its actually ever
pickable from there, right?
Does it make sense to delay this until its a DSQ_LOCAL enqueue? Or will
it never get that far without help?