Re: [RFC PATCH v5 14/29] sched/rt: Update task event callbacks for HCBS scheduling
From: Peter Zijlstra
Date: Tue May 05 2026 - 09:21:06 EST
On Thu, Apr 30, 2026 at 11:38:18PM +0200, Yuri Andriaccio wrote:
> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> index defb812b0e48..67fbf4bbe461 100644
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -975,7 +975,58 @@ static int balance_rt(struct rq *rq, struct task_struct *p, struct rq_flags *rf)
> static void wakeup_preempt_rt(struct rq *rq, struct task_struct *p, int flags)
> {
> struct task_struct *donor = rq->donor;
> + struct sched_dl_entity *woken_dl_se = NULL;
> + struct sched_dl_entity *donor_dl_se = NULL;
> +
> + if (!rt_group_sched_enabled())
> + goto no_group_sched;
>
> + /*
> + * Preemption checks are different if the waking task and the current task
> + * are running on the global runqueue or in a cgroup. The following rules
> + * apply:
> + * - dl-tasks (and equally dl_servers) always preempt FIFO/RR tasks.
> + * - if curr is a FIFO/RR task inside a cgroup (i.e. run by a
> + * dl_server), or curr is a DEADLINE task and waking is a FIFO/RR task
> + * on the root cgroup, do nothing.
> + * - if waking is inside a cgroup but curr is a FIFO/RR task in the root
> + * cgroup, always reschedule.
> + * - if they are both on the global runqueue, run the standard code.
> + * - if they are both in the same cgroup, check for tasks priorities.
> + * - if they are both in a cgroup, but not the same one, check whether the
> + * woken task's dl_server preempts the current's dl_server.
> + * - if curr is a DEADLINE task and waking is in a cgroup, check whether
> + * the woken task's server preempts curr.
> + */
> + if (is_dl_group(rt_rq_of_se(&p->rt)))
> + woken_dl_se = dl_group_of(rt_rq_of_se(&p->rt));
> + if (is_dl_group(rt_rq_of_se(&donor->rt)))
> + donor_dl_se = dl_group_of(rt_rq_of_se(&donor->rt));
> + else if (task_has_dl_policy(donor))
> + donor_dl_se = &donor->dl;
> +
> + if (woken_dl_se != NULL && donor_dl_se != NULL) {
> + if (woken_dl_se == donor_dl_se) {
> + if (p->prio < donor->prio)
> + resched_curr(rq);
> +
> + return;
This is effectively the traditional test, why not goto no_group_sched at
this point and share that code rather than duplicate?
> + }
> +
> + if (dl_entity_preempt(woken_dl_se, donor_dl_se))
> + resched_curr(rq);
> +
> + return;
> +
> + } else if (woken_dl_se != NULL) {
> + resched_curr(rq);
> + return;
> +
> + } else if (donor_dl_se != NULL) {
> + return;
> + }
> +
> +no_group_sched:
> /*
> * XXX If we're preempted by DL, queue a push?
> */