From: sashiko-bot@kernel.org
To: "Chris Mason" <mason@kernel.org>, sched-ext@lists.linux.dev
Subject: Re: [PATCH sched_ext/for-7.4-fixes] sched_ext: Don't skip NONE tasks in sched_ext_dead()
Date: Thu, 03 Dec 2026 20:50:40 +0000 [thread overview]
Message-ID: <sashiko-outbox-248650@kernel.org> (raw)
In-Reply-To: <20261203202815.32456-1-mason@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] sched_ext: unconditional task_rq_lock() in sched_ext_dead()
on every exit
--
commit 7328cb855c524883a9be737f7233e948be1c4e7b
Author: Chris Mason <mason@kernel.org>
sched_ext: Don't skip NONE tasks in sched_ext_dead()
This commit removes the SCX_TASK_NONE skip in sched_ext_dead() so that every
exiting task takes its runqueue lock, calls scx_disable_and_exit_task(), and
transitions to SCX_TASK_DEAD.
> diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
> index efa1d01d03afa..fd3d3d49be145 100644
> --- a/kernel/sched/ext/ext.c
> +++ b/kernel/sched/ext/ext.c
[ ... ]
> @@ -4992,24 +4995,19 @@ void sched_ext_dead(struct task_struct *p)
> * ENABLED transitions can't race us. Disable ops for @p.
> *
> * %SCX_TASK_DEAD synchronizes against cgroup task iteration - see
> - * scx_task_iter_next_locked(). NONE tasks need no marking: cgroup
> - * iteration is only used from sub-sched paths, which require root
> - * enabled. Root enable transitions every live task to at least READY.
> + * scx_task_iter_next_locked(). NONE tasks go through this too: the
> + * sub-sched paths change the state under @p's rq lock, and
> + * scx_punt_task() leaves a live task at NONE with its sched set.
> *
> * %INIT_BEGIN means ops.init_task() is running for @p. Don't call
> * into ops; transition to %DEAD so the post-init recheck unwinds
> * via scx_sub_init_cancel_task().
> */
> - if (scx_get_task_state(p) != SCX_TASK_NONE) {
> - struct rq_flags rf;
> - struct rq *rq;
> -
> - rq = task_rq_lock(p, &rf);
> - if (scx_get_task_state(p) != SCX_TASK_INIT_BEGIN)
> - scx_disable_and_exit_task(scx_task_sched(p), p);
> - scx_set_task_state(p, SCX_TASK_DEAD);
> - task_rq_unlock(rq, p, &rf);
> - }
> + rq = task_rq_lock(p, &rf);
> + if (scx_get_task_state(p) != SCX_TASK_INIT_BEGIN)
> + scx_disable_and_exit_task(scx_task_sched(p), p);
> + scx_set_task_state(p, SCX_TASK_DEAD);
> + task_rq_unlock(rq, p, &rf);
> }
[Severity: Medium]
Does dropping the SCX_TASK_NONE check add an extra rq->__lock acquisition on
every task exit even when no BPF scheduler is loaded?
finish_task_switch() calls sched_ext_dead() on every TASK_DEAD exit right
after finish_lock_switch() drops rq->__lock and re-enables interrupts. Now
every exiting task disables interrupts again, takes p->pi_lock and
rq->__lock, and runs scx_reset_task_fields(), hurting exit-heavy workloads.
Could this keep a fast path by checking scx_enable_state() == SCX_DISABLED
under scx_tasks_lock, since scx_root_enable_workfn() leaves SCX_DISABLED
before taking scx_tasks_lock and scx_root_disable() returns to it only after
draining all tasks and synchronize_rcu()?
If the unconditional lock is kept, the commit message itself should also
note this task-exit locking impact rather than leaving it below the ---
separator.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203202815.32456-1-mason@kernel.org?part=1
next prev parent reply other threads:[~2026-12-03 20:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 20:28 [PATCH sched_ext/for-7.4-fixes] sched_ext: Don't skip NONE tasks in sched_ext_dead() Chris Mason
2026-12-03 20:50 ` sashiko-bot [this message]
2026-12-03 22:45 ` Andrea Righi
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=sashiko-outbox-248650@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=mason@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sched-ext@lists.linux.dev \
/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