From: sashiko-bot@kernel.org
To: "Kuba Piecuch" <jpiecuch@google.com>
Cc: sched-ext@lists.linux.dev
Subject: Re: [PATCH sched_ext/for-7.3] sched_ext: skip ops.set_weight() for disabled tasks
Date: Fri, 10 Jul 2026 15:02:32 +0000 [thread overview]
Message-ID: <20260710150233.7F4611F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260710144342.3802587-1-jpiecuch@google.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] reweight_task_scx() fails to update p->se.load, causing tasks to have permanently stale load weights when their priority changes or when transitioning from sched_ext back to sched_fair (CFS).
--
--- Patch [1]: [PATCH sched_ext/for-7.3] sched_ext: skip ops.set_weight() for disabled tasks ---
commit 009696d9cb0a5605e8759533b00b9204ec011c72
Author: Kuba Piecuch <jpiecuch@google.com>
sched_ext: skip ops.set_weight() for disabled tasks
When switching a task's sched_class away from sched_ext, ops.set_weight()
is currently called after ops.disable(). This commit skips the weight
adjustment for disabled tasks to respect the expected callback semantics,
allowing the weight to be recalculated later if the task rejoins SCX.
> diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
> index 691d53fe0f648..ff22f31594c5c 100644
> --- a/kernel/sched/ext/ext.c
> +++ b/kernel/sched/ext/ext.c
> @@ -3925,6 +3925,17 @@ static void reweight_task_scx(struct rq *rq, struct task_struct *p,
> if (task_dead_and_done(p))
> return;
>
> + /*
> + * When switching sched_class away from SCX, reweight_task_scx()
> + * is called _after_ scx_disable_task(). Skip calling ops.set_weight()
> + * since the BPF scheduler may have already forgotten the task in
> + * ops.disable().
> + * p->scx.weight will be recalculated in scx_enable_task() if the task
> + * ever returns to SCX class.
> + */
> + if (scx_get_task_state(p) != SCX_TASK_ENABLED)
> + return;
> +
> p->scx.weight = sched_weight_to_cgroup(scale_load_down(lw->weight));
> if (SCX_HAS_OP(sch, set_weight))
> SCX_CALL_OP_TASK(sch, set_weight, rq, p, p->scx.weight);
[Severity: High]
This is a pre-existing issue, but does reweight_task_scx() need to update
p->se.load as well?
Looking at set_load_weight() in kernel/sched/core.c, it delegates the load
weight update to the current scheduling class's callback if available:
kernel/sched/core.c:set_load_weight() {
...
if (update_load && p->sched_class->reweight_task)
p->sched_class->reweight_task(task_rq(p), p, &lw);
else
p->se.load = lw;
...
}
When a task's priority is modified while it is in the sched_ext class,
set_load_weight() calls reweight_task_scx(). Because reweight_task_scx()
only updates p->scx.weight and entirely skips updating p->se.load, does the
CFS entity end up with a permanently stale load weight?
If the task's scheduling policy is later switched back to sched_fair, it
seems it would enter CFS with this incorrect load weight. Could this bypass
nice limits and break CFS fairness since the load weight dictates the task's
share of CPU time?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260710144342.3802587-1-jpiecuch@google.com?part=1
next prev parent reply other threads:[~2026-07-10 15:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 14:43 [PATCH sched_ext/for-7.3] sched_ext: skip ops.set_weight() for disabled tasks Kuba Piecuch
2026-07-10 15:02 ` sashiko-bot [this message]
2026-07-10 16:48 ` Tejun Heo
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=20260710150233.7F4611F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=jpiecuch@google.com \
--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 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.