Re: [PATCH 03/12] sched_ext: Split curr|donor references properly

From: Aiqun(Maria) Yu

Date: Fri Jul 03 2026 - 02:10:23 EST


On 7/3/2026 1:09 AM, Andrea Righi wrote:
> From: John Stultz <jstultz@xxxxxxxxxx>
>
> With proxy-exec, we want to do the accounting against the donor most of
> the time. Without proxy-exec, there should be no difference as the
> rq->donor and rq->curr are the same.

Trying to understand more of the situation when donor and curr in
different sched_class? one is in scx and the other is not.
could you pls help to explain more with this information in commit message?

>
> So rework the logic to reference the rq->donor where appropriate.
>
> Also add donor info to scx_dump_state().
>
> Since CONFIG_SCHED_PROXY_EXEC currently depends on
> !CONFIG_SCHED_CLASS_EXT, this should have no effect (other than the
> extra donor output in scx_dump_state), but this is one step needed to
> eventually remove that constraint for proxy-exec.
>
> Signed-off-by: John Stultz <jstultz@xxxxxxxxxx>
> ---
> kernel/sched/ext/ext.c | 28 ++++++++++++++++------------
> 1 file changed, 16 insertions(+), 12 deletions(-)
>
> diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
> index 1a0ec985da77d..1588565050679 100644
> --- a/kernel/sched/ext/ext.c
> +++ b/kernel/sched/ext/ext.c
> @@ -1145,17 +1145,17 @@ static void touch_core_sched_dispatch(struct rq *rq, struct task_struct *p)
>
> static void update_curr_scx(struct rq *rq)
> {
> - struct task_struct *curr = rq->curr;
> + struct task_struct *donor = rq->donor;
> s64 delta_exec;
>
> delta_exec = update_curr_common(rq);
> if (unlikely(delta_exec <= 0))
> return;
>
> - if (curr->scx.slice != SCX_SLICE_INF) {
> - curr->scx.slice -= min_t(u64, curr->scx.slice, delta_exec);
> - if (!curr->scx.slice)
> - touch_core_sched(rq, curr);
> + if (donor->scx.slice != SCX_SLICE_INF) {
> + donor->scx.slice -= min_t(u64, donor->scx.slice, delta_exec);
> + if (!donor->scx.slice)
> + touch_core_sched(rq, donor);
> }
>
> dl_server_update(&rq->ext_server, delta_exec);
> @@ -1316,8 +1316,8 @@ static void local_dsq_post_enq(struct scx_sched *sch, struct scx_dispatch_q *dsq
> if (rq->scx.flags & SCX_RQ_IN_BALANCE)
> return;
>
> - if ((enq_flags & SCX_ENQ_PREEMPT) && p != rq->curr &&
> - rq->curr->sched_class == &ext_sched_class) {
> + if ((enq_flags & SCX_ENQ_PREEMPT) && p != rq->donor &&
> + rq->donor->sched_class == &ext_sched_class) {
> rq->curr->scx.slice = 0;

Do you forget to update rq->curr with rq->donor here?

> resched_curr(rq);
> }
> @@ -2464,7 +2464,8 @@ static void dispatch_to_local_dsq(struct scx_sched *sch, struct rq *rq,
> }
>
> /* if the destination CPU is idle, wake it up */
> - if (!fallback && sched_class_above(p->sched_class, dst_rq->curr->sched_class))
> + if (!fallback && sched_class_above(p->sched_class,
> + dst_rq->donor->sched_class))
> resched_curr(dst_rq);
> }
>
> @@ -2876,7 +2877,7 @@ static struct task_struct *first_local_task(struct rq *rq)
> static struct task_struct *
> do_pick_task_scx(struct rq *rq, struct rq_flags *rf, bool force_scx)
> {
> - struct task_struct *prev = rq->curr;
> + struct task_struct *prev = rq->donor;
> bool keep_prev;
> struct task_struct *p;
>
> @@ -4029,7 +4030,7 @@ static void run_deferred(struct rq *rq)
> #ifdef CONFIG_NO_HZ_FULL
> bool scx_can_stop_tick(struct rq *rq)
> {
> - struct task_struct *p = rq->curr;
> + struct task_struct *p = rq->donor;
> struct scx_sched *sch = scx_task_sched(p);
>
> if (p->sched_class != &ext_sched_class)
> @@ -6007,6 +6008,9 @@ static void scx_dump_cpu(struct scx_sched *sch, struct seq_buf *s,
> dump_line(&ns, " curr=%s[%d] class=%ps",
> rq->curr->comm, rq->curr->pid,
> rq->curr->sched_class);
> + dump_line(&ns, " donor=%s[%d] class=%ps",
> + rq->donor->comm, rq->donor->pid,
> + rq->donor->sched_class);
> if (!cpumask_empty(rq->scx.cpus_to_kick))
> dump_line(&ns, " cpus_to_kick : %*pb",
> cpumask_pr_args(rq->scx.cpus_to_kick));
> @@ -7452,7 +7456,7 @@ static bool kick_one_cpu(s32 cpu, struct rq *this_rq, unsigned long *ksyncs)
> unsigned long flags;
>
> raw_spin_rq_lock_irqsave(rq, flags);
> - cur_class = rq->curr->sched_class;
> + cur_class = rq->donor->sched_class;
>
> /*
> * During CPU hotplug, a CPU may depend on kicking itself to make
> @@ -7464,7 +7468,7 @@ static bool kick_one_cpu(s32 cpu, struct rq *this_rq, unsigned long *ksyncs)
> !sched_class_above(cur_class, &ext_sched_class)) {
> if (cpumask_test_cpu(cpu, this_scx->cpus_to_preempt)) {
> if (cur_class == &ext_sched_class)
> - rq->curr->scx.slice = 0;
> + rq->donor->scx.slice = 0;
> cpumask_clear_cpu(cpu, this_scx->cpus_to_preempt);
> }
>


--
Thx and BRs,
Aiqun(Maria) Yu