Re: [PATCH v3 1/3] sched: Give root domain moves their own sched_class callbacks

From: Li kunyu

Date: Mon Nov 23 2026 - 00:57:12 EST


Hi Qiliang,

On 2026/11/21 10:57, Qiliang Yuan wrote:
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -8553,6 +8553,8 @@ void set_rq_online(struct rq *rq)
> rq->online = 1;
>
> for_each_class(class) {
> + if (class->rq_attach_root)
> + class->rq_attach_root(rq);
> if (class->rq_online)
> class->rq_online(rq);
> }
> @@ -8569,6 +8571,8 @@ void set_rq_offline(struct rq *rq)
> for_each_class(class) {
> if (class->rq_offline)
> class->rq_offline(rq);
> + if (class->rq_detach_root)
> + class->rq_detach_root(rq);
> }
>
>
> /* Assumes rq->lock is held */
> -static void rq_offline_dl(struct rq *rq)
> +static void rq_detach_root_dl(struct rq *rq)
> {
> if (rq->dl.overloaded)
> dl_clear_overload(rq);
> @@ -3664,8 +3664,8 @@ DEFINE_SCHED_CLASS(dl) = {
> .select_task_rq = select_task_rq_dl,
> .migrate_task_rq = migrate_task_rq_dl,
> .set_cpus_allowed = set_cpus_allowed_dl,
> - .rq_online = rq_online_dl,
> - .rq_offline = rq_offline_dl,
> + .rq_attach_root = rq_attach_root_dl,
> + .rq_detach_root = rq_detach_root_dl,
> .task_woken = task_woken_dl,
> .find_lock_rq = find_lock_later_rq,
>
>
> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> index 81a71aa5f094a..45d10334f7253 100644
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -2398,7 +2398,7 @@ static void task_woken_rt(struct rq *rq, struct task_struct *p)
> }
>
> /* Assumes rq->lock is held */
> -static void rq_online_rt(struct rq *rq)
> +static void rq_attach_root_rt(struct rq *rq)
> {
> if (rq->rt.overloaded)
> rt_set_overload(rq);
> @@ -2409,7 +2409,7 @@ static void rq_online_rt(struct rq *rq)
> }
>
> /* Assumes rq->lock is held */
> -static void rq_offline_rt(struct rq *rq)
> +static void rq_detach_root_rt(struct rq *rq)
> {
> if (rq->rt.overloaded)
> rt_clear_overload(rq);
> @@ -2626,8 +2626,8 @@ DEFINE_SCHED_CLASS(rt) = {
> .balance = balance_rt,
> .select_task_rq = select_task_rq_rt,
> .set_cpus_allowed = set_cpus_allowed_common,
> - .rq_online = rq_online_rt,
> - .rq_offline = rq_offline_rt,
> + .rq_attach_root = rq_attach_root_rt,
> + .rq_detach_root = rq_detach_root_rt,
>
> + /*
> + * Move an online rq to or from a root domain: rq->lock
> + */
> + void (*rq_attach_root)(struct rq *rq);
> + void (*rq_detach_root)(struct rq *rq);
> +

The newly introduced abstraction function cleanly separates the RT and DL
handling of the root domain, while leaving the CFS scheduling class entirely
unaffected, resulting in a well-structured design.

--
thanks,
kunyu