From: Changwoo Min <changwoo@igalia.com>
To: tj@kernel.org, void@manifault.com, arighi@nvidia.com,
changwoo@igalia.com
Cc: david.dai@linux.dev, Gavin Guo <gavinguo@igalia.com>,
kernel-dev@igalia.com, sched-ext@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 1/8] sched_ext: Reset task fields after ops.exit_task()
Date: Thu, 3 Dec 2026 13:56:11 +0900 [thread overview]
Message-ID: <20261203045618.982539-2-changwoo@igalia.com> (raw)
In-Reply-To: <20261203045618.982539-1-changwoo@igalia.com>
__scx_disable_and_exit_task() resets the task fields before
ops.exit_task(). ops.exit_task() runs while @p is still on the scheduler,
so scx_bpf_task_set_dsq_vtime() accepts its writes, and they outlive the
reset. When @p moves between a parent scheduler and a sub-scheduler, the
next scheduler's ops.enable() then finds the vtime the previous one left.
Reset after ops.exit_task() instead. ops.disable() and ops.exit_task()
still see the final values, and a cancelled init now gets the reset too.
Fixes: 5771e79e461e ("sched_ext: Reset dsq_vtime and slice when a task leaves SCX")
Reported-by: Andrea Righi <arighi@nvidia.com>
Link: https://lore.kernel.org/r/aw57uMvkiKrLBBBI@gpd4
Signed-off-by: Changwoo Min <changwoo@igalia.com>
---
kernel/sched/ext/ext.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
index a3cf580b0333..eaa68a1e9198 100644
--- a/kernel/sched/ext/ext.c
+++ b/kernel/sched/ext/ext.c
@@ -4814,12 +4814,9 @@ void __scx_disable_and_exit_task(struct scx_sched *sch, struct task_struct *p)
args.cancelled = true;
break;
case SCX_TASK_READY:
- scx_reset_task_fields(task_rq(p), p);
break;
case SCX_TASK_ENABLED:
scx_disable_task(sch, p);
- /* after ops.disable() has seen the final values */
- scx_reset_task_fields(task_rq(p), p);
break;
default:
WARN_ON_ONCE(true);
@@ -4828,6 +4825,12 @@ void __scx_disable_and_exit_task(struct scx_sched *sch, struct task_struct *p)
if (SCX_HAS_OP(sch, exit_task))
SCX_CALL_OP_TASK(sch, exit_task, task_rq(p), p, &args);
+
+ /*
+ * After ops.disable() and ops.exit_task() have seen the final values.
+ * ops.exit_task() can still write them while @p is on @sch.
+ */
+ scx_reset_task_fields(task_rq(p), p);
}
/*
--
2.56.1
next prev parent reply other threads:[~2026-12-03 4:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 4:56 [PATCH v2 0/8] sched_ext: Add p->scx.bpf_priv for O(1) task context lookup Changwoo Min
2026-12-03 4:56 ` Changwoo Min [this message]
2026-12-03 4:56 ` [PATCH v2 2/8] sched_ext: Mark a task enabled before ops.enable() Changwoo Min
2026-12-03 4:56 ` [PATCH v2 3/8] sched_ext: Add scx_bpf_sched_id() and scx_bpf_task_sched_id() Changwoo Min
2026-12-03 4:56 ` [PATCH v2 4/8] selftests/sched_ext: Test " Changwoo Min
2026-12-03 4:56 ` [PATCH v2 5/8] sched_ext: Add p->scx.bpf_priv for O(1) task context lookup Changwoo Min
2026-12-03 4:56 ` [PATCH v2 6/8] sched_ext: scx_qmap: Cache task_ctx in p->scx.bpf_priv Changwoo Min
2026-12-03 4:56 ` [PATCH v2 7/8] selftests/sched_ext: Test p->scx.bpf_priv across class changes Changwoo Min
2026-12-03 4:56 ` [PATCH v2 8/8] selftests/sched_ext: Test task field reset across sub-scheduler handoffs Changwoo Min
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=20261203045618.982539-2-changwoo@igalia.com \
--to=changwoo@igalia.com \
--cc=arighi@nvidia.com \
--cc=david.dai@linux.dev \
--cc=gavinguo@igalia.com \
--cc=kernel-dev@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®