Skip to content

Commit 6557133

Browse files
committed
sched_ext: Move sanity check and dsq_mod_nr() into task_unlink_from_dsq()
All task_unlink_from_dsq() users are doing dsq_mod_nr(dsq, -1). Move it into task_unlink_from_dsq(). Also move sanity check into it. No functional changes intended. Signed-off-by: Tejun Heo <[email protected]> Acked-by: David Vernet <[email protected]>
1 parent 1389f49 commit 6557133

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

kernel/sched/ext.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,13 +1719,16 @@ static void dispatch_enqueue(struct scx_dispatch_q *dsq, struct task_struct *p,
17191719
static void task_unlink_from_dsq(struct task_struct *p,
17201720
struct scx_dispatch_q *dsq)
17211721
{
1722+
WARN_ON_ONCE(list_empty(&p->scx.dsq_list.node));
1723+
17221724
if (p->scx.dsq_flags & SCX_TASK_DSQ_ON_PRIQ) {
17231725
rb_erase(&p->scx.dsq_priq, &dsq->priq);
17241726
RB_CLEAR_NODE(&p->scx.dsq_priq);
17251727
p->scx.dsq_flags &= ~SCX_TASK_DSQ_ON_PRIQ;
17261728
}
17271729

17281730
list_del_init(&p->scx.dsq_list.node);
1731+
dsq_mod_nr(dsq, -1);
17291732
}
17301733

17311734
static void dispatch_dequeue(struct rq *rq, struct task_struct *p)
@@ -1762,9 +1765,7 @@ static void dispatch_dequeue(struct rq *rq, struct task_struct *p)
17621765
*/
17631766
if (p->scx.holding_cpu < 0) {
17641767
/* @p must still be on @dsq, dequeue */
1765-
WARN_ON_ONCE(list_empty(&p->scx.dsq_list.node));
17661768
task_unlink_from_dsq(p, dsq);
1767-
dsq_mod_nr(dsq, -1);
17681769
} else {
17691770
/*
17701771
* We're racing against dispatch_to_local_dsq() which already
@@ -2217,7 +2218,6 @@ static void consume_local_task(struct task_struct *p,
22172218
WARN_ON_ONCE(p->scx.holding_cpu >= 0);
22182219
task_unlink_from_dsq(p, dsq);
22192220
list_add_tail(&p->scx.dsq_list.node, &rq->scx.local_dsq.list);
2220-
dsq_mod_nr(dsq, -1);
22212221
dsq_mod_nr(&rq->scx.local_dsq, 1);
22222222
p->scx.dsq = &rq->scx.local_dsq;
22232223
raw_spin_unlock(&dsq->lock);
@@ -2307,7 +2307,6 @@ static bool unlink_dsq_and_lock_src_rq(struct task_struct *p,
23072307

23082308
WARN_ON_ONCE(p->scx.holding_cpu >= 0);
23092309
task_unlink_from_dsq(p, dsq);
2310-
dsq_mod_nr(dsq, -1);
23112310
p->scx.holding_cpu = cpu;
23122311

23132312
raw_spin_unlock(&dsq->lock);

0 commit comments

Comments
 (0)