Re: [PATCH 12/18] sched_ext: Generalize the reject DSQ reenqueue path
From: Tejun Heo
Date: Thu Sep 03 2026 - 18:41:33 EST
Hello,
Nits follow.
On Mon, Aug 31, 2026 at 03:42:22PM +0200, Andrea Righi wrote:
> @@ -1599,11 +1599,10 @@ static void scx_dispatch_enqueue(struct scx_sched *sch, struct rq *rq,
> struct scx_dispatch_q *dsq, struct task_struct *p,
> u64 slice, u64 vtime, u64 enq_flags)
> {
> - bool is_rq_owned = false;
> + bool is_rq_owned = dsq_is_rq_owned(dsq);
>
> if (dsq->id == SCX_DSQ_LOCAL) {
> dsq = scx_resolve_local_dsq(sch, rq, p, &enq_flags);
> - is_rq_owned = true;
> }
No need for {}.
> @@ -2017,6 +2016,7 @@ void scx_do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags,
> __scx_exit(sch, SCX_EXIT_ERROR_REENQ, 0, cpu_of(rq),
> "%s[%d] reenqueued %u times without running",
> p->comm, p->pid, p->scx.reenq_cnt);
> + p->scx.flags &= ~SCX_TASK_REENQ_REASON_MASK;
> return;
> }
> }
> @@ -2067,6 +2067,8 @@ void scx_do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags,
>
> SCX_CALL_OP_TASK(sch, enqueue, rq, p, enq_flags);
>
> + /* The reason is input to ops.enqueue(), not to the resulting placement. */
> + p->scx.flags &= ~SCX_TASK_REENQ_REASON_MASK;
> *ddsp_taskp = NULL;
> if (p->scx.ddsp_dsq_id != SCX_DSQ_INVALID)
> goto direct;
> @@ -2085,9 +2087,11 @@ void scx_do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags,
> return;
>
> direct:
> + p->scx.flags &= ~SCX_TASK_REENQ_REASON_MASK;
> direct_dispatch(sch, p, enq_flags);
> return;
> local_norefill:
> + p->scx.flags &= ~SCX_TASK_REENQ_REASON_MASK;
> scx_dispatch_enqueue(sch, rq, &rq->scx.local_dsq, p, 0, 0, enq_flags);
> return;
> local:
> @@ -2101,6 +2105,7 @@ void scx_do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags,
> goto enqueue;
>
> enqueue:
> + p->scx.flags &= ~SCX_TASK_REENQ_REASON_MASK;
> refill_task_slice_dfl(sch, p);
> clear_direct_dispatch(p);
> scx_dispatch_enqueue(sch, rq, dsq, p, 0, 0, enq_flags);
This is too messy. The clearing is scattered all over and sometimes done
twice. Can't you add one label that everyone jumps to for exit and clear it
there?
Thanks.
--
tejun