Re: [PATCH 4/7] sched_ext: Add a DL server for sched_ext tasks
From: Andrea Righi
Date: Mon Feb 02 2026 - 17:19:16 EST
On Mon, Feb 02, 2026 at 10:10:04PM +0100, Peter Zijlstra wrote:
> On Mon, Feb 02, 2026 at 09:32:32PM +0100, Andrea Righi wrote:
> > 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.
>
> I suspect you need some callbacks around where scx_enabled() is changed
> to add/stop/remove things.
Ah that's right, simply checking scx_enabled() isn't enough, because the
state can change at runtime, we need callbacks in scx_enable() and
scx_disable_workfn(). I'll test this tomorrow. :)
Thanks!
-Andrea