From: Andrea Righi <arighi@nvidia.com>
To: Tejun Heo <tj@kernel.org>, David Vernet <void@manifault.com>,
Changwoo Min <changwoo@igalia.com>
Cc: sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH sched_ext/for-7.1-fixes] sched_ext: Reset dsq_vtime and slice when a task leaves SCX
Date: Mon, 8 Jun 2026 15:49:08 +0200 [thread overview]
Message-ID: <20260608134908.3232097-1-arighi@nvidia.com> (raw)
When a task switches out of the sched_ext class, p->scx.dsq_vtime and
p->scx.slice keep whatever values they last held. On enable, slice is
reset to slice_dfl, but dsq_vtime is owned by the BPF scheduler and is
never cleared by the core, so a task that leaves SCX and later returns
carries a stale dsq_vtime across the round-trip.
The stale values are also visible to other SCX schedulers if they
inspects the scx fields of non-SCX tasks.
Zero dsq_vtime and slice in switched_from_scx() after scx_disable_task()
so the fields are reset to the same baseline a freshly forked task has.
The reset is done after the disable callback so the BPF scheduler can
still observe the task's final values.
Signed-off-by: Andrea Righi <arighi@nvidia.com>
---
kernel/sched/ext.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 8e88a25bc602f..915d5ece5d277 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -3942,10 +3942,11 @@ static void switched_from_scx(struct rq *rq, struct task_struct *p)
* scx_disable_task() would WARN on the non-%ENABLED state and trigger a
* NONE -> READY validation failure.
*/
- if (scx_get_task_state(p) == SCX_TASK_NONE)
- return;
+ if (scx_get_task_state(p) != SCX_TASK_NONE)
+ scx_disable_task(scx_task_sched(p), p);
- scx_disable_task(scx_task_sched(p), p);
+ p->scx.dsq_vtime = 0;
+ p->scx.slice = 0;
}
static void switched_to_scx(struct rq *rq, struct task_struct *p) {}
--
2.54.0
reply other threads:[~2026-06-08 13:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260608134908.3232097-1-arighi@nvidia.com \
--to=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sched-ext@lists.linux.dev \
--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
all inboxes | Powered by JetHome®