Re: [PATCH 4/7] sched_ext: Add a DL server for sched_ext tasks
From: Andrea Righi
Date: Mon Feb 02 2026 - 15:32:46 EST
Hi Peter,
On Mon, Feb 02, 2026 at 08:50:35PM +0100, Peter Zijlstra wrote:
> 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.
Yeah, that's a good point. We can just add scx_enabled() here. Let me try
running some tests with this.
>
>
>
> > @@ -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?
We could probably move dl_server_start() to local_dsq_post_enq() and start
the dl server when a task is actually dispatched to the local DSQ. I think
it should work, but I'd like to do more extensive testing with this change.
In any case, IMHO these are improvements we can make later, even in its
current form, this is still better than what we have and it would at least
address the recurring bug reports about RT tasks starving scx tasks...
Thanks!
-Andrea