From: Tao Cui <cui.tao@linux.dev>
To: tj@kernel.org
Cc: sched-ext@lists.linux.dev, void@manifault.com, arighi@nvidia.com,
changwoo@igalia.com, linux-kernel@vger.kernel.org,
cui.tao@linux.dev, Tao Cui <cuitao@kylinos.cn>
Subject: [PATCH] sched_ext: don't rehome a dead task in scx_cgroup_task_migrated
Date: Tue, 11 Aug 2026 18:31:22 +0800 [thread overview]
Message-ID: <20260811103122.357067-1-cui.tao@linux.dev> (raw)
From: Tao Cui <cuitao@kylinos.cn>
A task can exit between cgroup migration commit and the MIGRATED callback:
sched_ext_dead() marks it SCX_TASK_DEAD before cgroup_task_dead() removes it
from the migration list, so scx_cgroup_task_migrated() can pick up a dead
task and call scx_rehome_task(), which re-enables it and leaks the BPF
scheduler's per-task resources. The other scx_rehome_task() callers already
check for this; do the same here.
Fixes: bf9dee58ab56 ("sched_ext: Re-home tasks on cgroup migration")
Signed-off-by: Tao Cui <cuitao@kylinos.cn>
---
kernel/sched/ext/sub.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/kernel/sched/ext/sub.c b/kernel/sched/ext/sub.c
index b81254be1b04..8f8d21b85abe 100644
--- a/kernel/sched/ext/sub.c
+++ b/kernel/sched/ext/sub.c
@@ -2083,6 +2083,13 @@ static void scx_cgroup_task_migrated(struct cgroup_task_migrate_ctx *ctx)
return;
rq = task_rq_lock(p, &rf);
+
+ if (scx_get_task_state(p) == SCX_TASK_DEAD) {
+ /* sched_ext_dead() raced us */
+ task_rq_unlock(rq, p, &rf);
+ return;
+ }
+
scx_rehome_task(to, p);
task_rq_unlock(rq, p, &rf);
}
--
2.43.0
reply other threads:[~2026-08-11 10:31 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=20260811103122.357067-1-cui.tao@linux.dev \
--to=cui.tao@linux.dev \
--cc=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=cuitao@kylinos.cn \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.