FAILED: patch "[PATCH] sched_ext: Wait for SCX_OPSS_DISPATCHING before moving tasks" failed to apply to 7.2-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 7.2-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-7.2.y
git checkout FETCH_HEAD
git cherry-pick -x 2935062be77113c1c4565ca9d0c72180449aafee
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026102109-rejoice-reboot-d810@gregkh' --subject-prefix 'PATCH 7.2.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 2935062be77113c1c4565ca9d0c72180449aafee Mon Sep 17 00:00:00 2001
From: Kuba Piecuch <[email protected]>
Date: Mon, 12 Oct 2026 21:07:46 +0000
Subject: [PATCH] sched_ext: Wait for SCX_OPSS_DISPATCHING before moving tasks
off DSQs
A task can be found on a non-local DSQ while the CPU which dispatched it is still running ops.dequeue() and hasn't cleared SCX_OPSS_DISPATCHING. The DSQ consume and move paths don't wait for the dispatch to finish and can operate on the task concurrently with the dispatcher.
Call scx_wait_dispatching() in scx_move_local_task_to_local_dsq(), unlink_dsq_and_switch_rq_lock() and move_task_between_dsqs() before they operate on the task. In scx_move_local_task_to_local_dsq(), wait before scx_resolve_local_dsq() as it may update p->scx.flags.
kernel/sched/ext/ext.c +12 -3
@@ -2407,11 +2407,14 @@ static void wakeup_preempt_scx(struct rq *rq, struct task_struct *p, int wake_flvoid scx_move_local_task_to_local_dsq (struct scx_sched *sch,struct task_struct *p,u64 enq_flags,struct rq *dst_rq) { -struct scx_dispatch_q *dst_dsq =scx_resolve_local_dsq (sch, dst_rq, p, &enq_flags); +struct scx_dispatch_q *dst_dsq;lockdep_assert_rq_held (dst_rq);WARN_ON_ONCE (p->scx.holding_cpu >=0 ); +scx_wait_dispatching (p); + + dst_dsq =scx_resolve_local_dsq (sch, dst_rq, p, &enq_flags);if (enq_flags & (SCX_ENQ_HEAD |SCX_ENQ_PREEMPT ))dsq_insert_head (dst_dsq, p);
@@ -2591,8 +2594,12 @@ static bool unlink_dsq_and_switch_rq_lock(struct task_struct *p,switch_rq_lock (locked_rq, src_rq);/* task_rq couldn't have changed if we're still the holding cpu */ -return likely (p->scx.holding_cpu == cpu) && - !WARN_ON_ONCE (src_rq !=task_rq (p)); +if (likely (p->scx.holding_cpu == cpu) && !WARN_ON_ONCE (src_rq !=task_rq (p))) { +scx_wait_dispatching (p); +return true; + } + +return false; } static bool consume_remote_task(struct scx_sched *sch, struct rq *this_rq,
@@ -2635,6 +2642,8 @@ static struct rq *move_task_between_dsqs(struct scx_sched *sch,lockdep_assert_held (&src_dsq->lock);lockdep_assert_rq_held (src_rq); +scx_wait_dispatching (p); +if (dst_dsq->id ==SCX_DSQ_LOCAL ) { dst_rq = container_of(dst_dsq, struct rq, scx.local_dsq); if (src_rq != dst_rq &&
PATCH 1/1 sched_ext: Wait for SCX_OPSS_DISPATCHING before moving tasks off DSQs
From: Kuba Piecuch <[email protected]>
A task can be found on a non-local DSQ while the CPU which dispatched it is still running ops.dequeue() and hasn't cleared SCX_OPSS_DISPATCHING. The DSQ consume and move paths don't wait for the dispatch to finish and can operate on the task concurrently with the dispatcher.
Call scx_wait_dispatching() in scx_move_local_task_to_local_dsq(), unlink_dsq_and_switch_rq_lock() and move_task_between_dsqs() before they operate on the task. In scx_move_local_task_to_local_dsq(), wait before scx_resolve_local_dsq() as it may update p->scx.flags.
[ Inlined scx_wait_dispatching(), which 7.2.y doesn't have, into
move_local_task_to_local_dsq(), unlink_dsq_and_lock_src_rq() and move_task_between_dsqs(), as was done for the reenqueue paths in 7.2.y. 7.2.y has no scx_resolve_local_dsq(), so move_local_task_to_local_dsq() waits before linking the task. ]
--- kernel/sched/ext/ext.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
kernel/sched/ext/ext.c +12 -2
@@ -2288,6 +2288,8 @@ static void move_local_task_to_local_dsq(struct scx_sched *sch,lockdep_assert_rq_held (dst_rq);WARN_ON_ONCE (p->scx.holding_cpu >=0 ); +if (unlikely (atomic_long_read_acquire (&p->scx.ops_state) ==SCX_OPSS_DISPATCHING )) +wait_ops_state (p,SCX_OPSS_DISPATCHING );if (enq_flags & (SCX_ENQ_HEAD |SCX_ENQ_PREEMPT ))list_add (&p->scx.dsq_list.node, &dst_dsq->list);
@@ -2458,8 +2460,13 @@ static bool unlink_dsq_and_lock_src_rq(struct task_struct *p,raw_spin_rq_lock (src_rq);/* task_rq couldn't have changed if we're still the holding cpu */ -return likely (p->scx.holding_cpu == cpu) && - !WARN_ON_ONCE (src_rq !=task_rq (p)); +if (likely (p->scx.holding_cpu == cpu) && !WARN_ON_ONCE (src_rq !=task_rq (p))) { +if (unlikely (atomic_long_read_acquire (&p->scx.ops_state) ==SCX_OPSS_DISPATCHING )) +wait_ops_state (p,SCX_OPSS_DISPATCHING ); +return true; + } + +return false; } static bool consume_remote_task(struct rq *this_rq,
@@ -2507,6 +2514,9 @@ static struct rq *move_task_between_dsqs(struct scx_sched *sch,lockdep_assert_held (&src_dsq->lock);lockdep_assert_rq_held (src_rq); +if (unlikely (atomic_long_read_acquire (&p->scx.ops_state) ==SCX_OPSS_DISPATCHING )) +wait_ops_state (p,SCX_OPSS_DISPATCHING ); +if (dst_dsq->id ==SCX_DSQ_LOCAL ) { dst_rq = container_of(dst_dsq, struct rq, scx.local_dsq); if (src_rq != dst_rq &&
Signature · 1 line
2.56.0
Re: [PATCH 7.2.y] sched_ext: Wait for SCX_OPSS_DISPATCHING before moving tasks off DSQs
Quoted 4 lines
A task can be found on a non-local DSQ while the CPU which dispatched it is still running
ops.dequeue()and hasn't clearedSCX_OPSS_DISPATCHING. The DSQ consume and move paths don't wait for the dispatch to finish and can operate on the task concurrently with the dispatcher.
Queued for 7.2, thanks.
Signature · 2 lines
Thanks, Sasha