Skip to content

Commit 346fd9d

Browse files
committed
scx: Enforce either/or usage of DSQ FIFO/PRIQ dispatching
Currently, a user can do both FIFO and PRIQ dispatching to a DSQ. This can result in non-intuitive behavior. For example, if a user PRIQ-dispatches to a DSQ, and then subsequently FIFO dispatches, an scx_bpf_consume() operation will always favor the FIFO-dispatched task. While we could add something like an scx_bpf_consume_vtime() kfunc, given that there's not a clear use-case for doing both types of dispatching in a single DSQ, for now we'll elect to just enforce that only a single type is being used at any given time. Reported-by: Changwoo Min <[email protected]> Signed-off-by: David Vernet <[email protected]>
1 parent 25a5d10 commit 346fd9d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

kernel/sched/ext.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,11 +651,19 @@ static void dispatch_enqueue(struct scx_dispatch_q *dsq, struct task_struct *p,
651651
p->scx.dsq_flags |= SCX_TASK_DSQ_ON_PRIQ;
652652
rb_add_cached(&p->scx.dsq_node.priq, &dsq->priq,
653653
scx_dsq_priq_less);
654+
/* A DSQ should only be using either FIFO or PRIQ enqueuing. */
655+
if (unlikely(!list_empty(&dsq->fifo)))
656+
scx_ops_error("DSQ ID 0x%016llx already had FIFO-enqueued tasks",
657+
dsq->id);
654658
} else {
655659
if (enq_flags & (SCX_ENQ_HEAD | SCX_ENQ_PREEMPT))
656660
list_add(&p->scx.dsq_node.fifo, &dsq->fifo);
657661
else
658662
list_add_tail(&p->scx.dsq_node.fifo, &dsq->fifo);
663+
/* A DSQ should only be using either FIFO or PRIQ enqueuing. */
664+
if (unlikely(rb_first_cached(&dsq->priq)))
665+
scx_ops_error("DSQ ID 0x%016llx already had PRIQ-enqueued tasks",
666+
dsq->id);
659667
}
660668
dsq->nr++;
661669
p->scx.dsq = dsq;

0 commit comments

Comments
 (0)