Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched_ext: Factor out abbreviated dispatch dequeue into dispatch_dequeue_locked()

move_task_between_dsqs() contains open-coded abbreviated dequeue logic when
moving tasks between non-local DSQs. Factor this out into
dispatch_dequeue_locked() which can be used when both the task's rq and dsq
locks are already held. Add lockdep assertions to both dispatch_dequeue() and
the new helper to verify locking requirements.

This prepares for the load balancer which will need the same abbreviated
dequeue pattern.

Cc: Andrea Righi <arighi@nvidia.com>
Cc: Dan Schatzberg <schatzberg.dan@gmail.com>
Cc: Emil Tsalapatis <etsal@meta.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

Tejun Heo d18b96ce d2974cc7

+17 -2
+17 -2
kernel/sched/ext.c
··· 1106 1106 struct scx_dispatch_q *dsq = p->scx.dsq; 1107 1107 bool is_local = dsq == &rq->scx.local_dsq; 1108 1108 1109 + lockdep_assert_rq_held(rq); 1110 + 1109 1111 if (!dsq) { 1110 1112 /* 1111 1113 * If !dsq && on-list, @p is on @rq's ddsp_deferred_locals. ··· 1152 1150 1153 1151 if (!is_local) 1154 1152 raw_spin_unlock(&dsq->lock); 1153 + } 1154 + 1155 + /* 1156 + * Abbreviated version of dispatch_dequeue() that can be used when both @p's rq 1157 + * and dsq are locked. 1158 + */ 1159 + static void dispatch_dequeue_locked(struct task_struct *p, 1160 + struct scx_dispatch_q *dsq) 1161 + { 1162 + lockdep_assert_rq_held(task_rq(p)); 1163 + lockdep_assert_held(&dsq->lock); 1164 + 1165 + task_unlink_from_dsq(p, dsq); 1166 + p->scx.dsq = NULL; 1155 1167 } 1156 1168 1157 1169 static struct scx_dispatch_q *find_dsq_for_dispatch(struct scx_sched *sch, ··· 1828 1812 * @p is going from a non-local DSQ to a non-local DSQ. As 1829 1813 * $src_dsq is already locked, do an abbreviated dequeue. 1830 1814 */ 1831 - task_unlink_from_dsq(p, src_dsq); 1832 - p->scx.dsq = NULL; 1815 + dispatch_dequeue_locked(p, src_dsq); 1833 1816 raw_spin_unlock(&src_dsq->lock); 1834 1817 1835 1818 dispatch_enqueue(sch, dst_dsq, p, enq_flags);