[PATCH] sched_ext: Avoid relocking DSQ during remote DSQ moves

Usama Arif posted 1 patch 16 hours ago
kernel/sched/ext/ext.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] sched_ext: Avoid relocking DSQ during remote DSQ moves
Posted by Usama Arif 16 hours ago
When scx_bpf_dsq_move*() moves a task from a non-local DSQ to a
remote local DSQ, move_task_between_dsqs() drops src_dsq->lock while
leaving p->scx.dsq set. The following deactivate_task() then reacquires
src_dsq->lock in scx_dispatch_dequeue() to unlink the task and clear
p->scx.dsq.

Both the source rq and src_dsq are already locked before the source DSQ
lock is dropped. Call dispatch_dequeue_locked() there so that
deactivate_task() takes the !dsq path and avoids the redundant lock
acquisition.

Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Usama Arif <usama.arif@linux.dev>
---
 kernel/sched/ext/ext.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
index f95d1cf8d3d1c..56bc06a56bb34 100644
--- a/kernel/sched/ext/ext.c
+++ b/kernel/sched/ext/ext.c
@@ -2710,6 +2710,7 @@ static struct rq *move_task_between_dsqs(struct scx_sched *sch,
 			raw_spin_unlock(&src_dsq->lock);
 			scx_move_local_task_to_local_dsq(sch, p, enq_flags, dst_rq);
 		} else {
+			dispatch_dequeue_locked(p, src_dsq);
 			raw_spin_unlock(&src_dsq->lock);
 			move_remote_task_to_local_dsq(sch, p, enq_flags, src_rq, dst_rq);
 		}
-- 
2.53.0-Meta
Re: [PATCH] sched_ext: Avoid relocking DSQ during remote DSQ moves
Posted by Tejun Heo 14 hours ago
Applied to sched_ext/for-7.4 with the context adjusted (the patch was
against for-next).

Thanks.

--
tejun