Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@nvidia.com>
To: stable@vger.kernel.org, Tejun Heo <tj@kernel.org>,
	David Vernet <void@manifault.com>,
	Changwoo Min <changwoo@igalia.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sasha Levin <sashal@kernel.org>,
	Kuba Piecuch <jpiecuch@google.com>,
	fangqiurong <fangqiurong@kylinos.cn>,
	Rahad Bhuiya <rahadbhuiya2021@gmail.com>,
	sched-ext@lists.linux.dev
Subject: [PATCH 7.1.y 8/8] sched_ext: Reset task fields on exit of an SCX_TASK_READY task
Date: Sat, 28 Nov 2026 11:23:51 +0100	[thread overview]
Message-ID: <20261128102535.655465-9-arighi@nvidia.com> (raw)
In-Reply-To: <20261128102535.655465-1-arighi@nvidia.com>

From: Rahad Bhuiya <rahadbhuiya2021@gmail.com>

commit 564405c424f49d70b13debe7fe5b550234ad6b84 upstream.

Tasks in SCX_TASK_READY are attached to a scheduler but outside the ext
class, such as RT/DL tasks, or non-SCHED_EXT tasks under a partial
switch. The scheduler's BPF code can still update their dsq_vtime and
slice (for instance, via ops.cgroup_move() as done by scx_flatcg).

Because __scx_disable_and_exit_task() currently breaks out of the state
switch for SCX_TASK_READY without calling scx_reset_task_fields(), these
fields are not cleared when the task leaves the scheduler. If the task
is subsequently moved to another cgroup/sub-scheduler and later switches
to SCHED_NORMAL, the new scheduler's ops.enable() sees stale dsq_vtime
from the previous scheduler's clock.

Call scx_reset_task_fields() in the SCX_TASK_READY case of
__scx_disable_and_exit_task() to ensure SCX-managed fields are properly
reset when leaving the scheduler.

Fixes: 5771e79e461e ("sched_ext: Reset dsq_vtime and slice when a task leaves SCX")
Signed-off-by: Rahad Bhuiya <rahadbhuiya2021@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
[arighi: Reset the fields directly in the older ext.c exit path.
There is no scx_reset_task_fields() helper in this tree.]
Signed-off-by: Andrea Righi <arighi@nvidia.com>
---
 kernel/sched/ext.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index b2bb60ff78d39..c5124279ebb38 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -3724,6 +3724,8 @@ static void __scx_disable_and_exit_task(struct scx_sched *sch,
 		args.cancelled = true;
 		break;
 	case SCX_TASK_READY:
+		p->scx.dsq_vtime = 0;
+		p->scx.slice = 0;
 		break;
 	case SCX_TASK_ENABLED:
 		scx_disable_task(sch, p);
-- 
2.56.1


      parent reply	other threads:[~2026-11-28 10:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28 10:23 [PATCH 7.1.y 0/8] sched_ext: Backport dispatch and task-state fixes Andrea Righi
2026-11-28 10:23 ` [PATCH 7.1.y 1/8] sched_ext: Check remote rq eligibility under task's rq lock Andrea Righi
2026-11-28 10:23 ` [PATCH 7.1.y 2/8] sched_ext: Don't run ops.dequeue() with a DSQ lock held Andrea Righi
2026-11-28 10:23 ` [PATCH 7.1.y 3/8] sched_ext: Call ops.dequeue() when a task arrives on a remote local DSQ Andrea Righi
2026-11-28 10:23 ` [PATCH 7.1.y 4/8] sched_ext: Wait for SCX_OPSS_DISPATCHING before reenqueueing a task Andrea Righi
2026-11-28 10:23 ` [PATCH 7.1.y 5/8] sched_ext: Wait for SCX_OPSS_DISPATCHING before moving tasks off DSQs Andrea Righi
2026-11-28 10:23 ` [PATCH 7.1.y 6/8] sched_ext: Generate qseq from a per-task counter Andrea Righi
2026-11-28 10:23 ` [PATCH 7.1.y 7/8] sched_ext: Reset dsq_vtime and slice when a task leaves SCX Andrea Righi
2026-11-28 10:23 ` Andrea Righi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261128102535.655465-9-arighi@nvidia.com \
    --to=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=fangqiurong@kylinos.cn \
    --cc=gregkh@linuxfoundation.org \
    --cc=jpiecuch@google.com \
    --cc=rahadbhuiya2021@gmail.com \
    --cc=sashal@kernel.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=void@manifault.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox