Skip to content

Commit 0aab263

Browse files
committed
sched_ext: Fix processs_ddsp_deferred_locals() by unifying DTL_INVALID handling
With the preceding update, the only return value which makes meaningful difference is DTL_INVALID, for which one caller, finish_dispatch(), falls back to the global DSQ and the other, process_ddsp_deferred_locals(), doesn't do anything. It should always fallback to the global DSQ. Move the global DSQ fallback into dispatch_to_local_dsq() and remove the return value. v2: Patch title and description updated to reflect the behavior fix for process_ddsp_deferred_locals(). Signed-off-by: Tejun Heo <[email protected]> Acked-by: David Vernet <[email protected]>
1 parent e683949 commit 0aab263

File tree

1 file changed

+10
-31
lines changed

1 file changed

+10
-31
lines changed

kernel/sched/ext.c

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2370,12 +2370,6 @@ static bool consume_dispatch_q(struct rq *rq, struct scx_dispatch_q *dsq)
23702370
return false;
23712371
}
23722372

2373-
enum dispatch_to_local_dsq_ret {
2374-
DTL_DISPATCHED, /* successfully dispatched */
2375-
DTL_LOST, /* lost race to dequeue */
2376-
DTL_INVALID, /* invalid local dsq_id */
2377-
};
2378-
23792373
/**
23802374
* dispatch_to_local_dsq - Dispatch a task to a local dsq
23812375
* @rq: current rq which is locked
@@ -2390,9 +2384,8 @@ enum dispatch_to_local_dsq_ret {
23902384
* The caller must have exclusive ownership of @p (e.g. through
23912385
* %SCX_OPSS_DISPATCHING).
23922386
*/
2393-
static enum dispatch_to_local_dsq_ret
2394-
dispatch_to_local_dsq(struct rq *rq, struct scx_dispatch_q *dst_dsq,
2395-
struct task_struct *p, u64 enq_flags)
2387+
static void dispatch_to_local_dsq(struct rq *rq, struct scx_dispatch_q *dst_dsq,
2388+
struct task_struct *p, u64 enq_flags)
23962389
{
23972390
struct rq *src_rq = task_rq(p);
23982391
struct rq *dst_rq = container_of(dst_dsq, struct rq, scx.local_dsq);
@@ -2405,13 +2398,11 @@ dispatch_to_local_dsq(struct rq *rq, struct scx_dispatch_q *dst_dsq,
24052398
*/
24062399
if (rq == src_rq && rq == dst_rq) {
24072400
dispatch_enqueue(dst_dsq, p, enq_flags | SCX_ENQ_CLEAR_OPSS);
2408-
return DTL_DISPATCHED;
2401+
return;
24092402
}
24102403

24112404
#ifdef CONFIG_SMP
24122405
if (likely(task_can_run_on_remote_rq(p, dst_rq, true))) {
2413-
bool dsp;
2414-
24152406
/*
24162407
* @p is on a possibly remote @src_rq which we need to lock to
24172408
* move the task. If dequeue is in progress, it'd be locking
@@ -2436,10 +2427,8 @@ dispatch_to_local_dsq(struct rq *rq, struct scx_dispatch_q *dst_dsq,
24362427
}
24372428

24382429
/* task_rq couldn't have changed if we're still the holding cpu */
2439-
dsp = p->scx.holding_cpu == raw_smp_processor_id() &&
2440-
!WARN_ON_ONCE(src_rq != task_rq(p));
2441-
2442-
if (likely(dsp)) {
2430+
if (likely(p->scx.holding_cpu == raw_smp_processor_id()) &&
2431+
!WARN_ON_ONCE(src_rq != task_rq(p))) {
24432432
/*
24442433
* If @p is staying on the same rq, there's no need to
24452434
* go through the full deactivate/activate cycle.
@@ -2467,11 +2456,11 @@ dispatch_to_local_dsq(struct rq *rq, struct scx_dispatch_q *dst_dsq,
24672456
raw_spin_rq_lock(rq);
24682457
}
24692458

2470-
return dsp ? DTL_DISPATCHED : DTL_LOST;
2459+
return;
24712460
}
24722461
#endif /* CONFIG_SMP */
24732462

2474-
return DTL_INVALID;
2463+
dispatch_enqueue(&scx_dsq_global, p, enq_flags | SCX_ENQ_CLEAR_OPSS);
24752464
}
24762465

24772466
/**
@@ -2548,20 +2537,10 @@ static void finish_dispatch(struct rq *rq, struct task_struct *p,
25482537

25492538
dsq = find_dsq_for_dispatch(this_rq(), dsq_id, p);
25502539

2551-
if (dsq->id == SCX_DSQ_LOCAL) {
2552-
switch (dispatch_to_local_dsq(rq, dsq, p, enq_flags)) {
2553-
case DTL_DISPATCHED:
2554-
break;
2555-
case DTL_LOST:
2556-
break;
2557-
case DTL_INVALID:
2558-
dispatch_enqueue(&scx_dsq_global, p,
2559-
enq_flags | SCX_ENQ_CLEAR_OPSS);
2560-
break;
2561-
}
2562-
} else {
2540+
if (dsq->id == SCX_DSQ_LOCAL)
2541+
dispatch_to_local_dsq(rq, dsq, p, enq_flags);
2542+
else
25632543
dispatch_enqueue(dsq, p, enq_flags | SCX_ENQ_CLEAR_OPSS);
2564-
}
25652544
}
25662545

25672546
static void flush_dispatch_buf(struct rq *rq)

0 commit comments

Comments
 (0)