From: Andrea Righi <arighi@nvidia.com>
To: Zicheng Qu <quzicheng315@gmail.com>
Cc: tj@kernel.org, void@manifault.com, changwoo@igalia.com,
mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.co,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
vschneid@redhat.com, kprateek.nayak@amd.com, haoluo@google.com,
joshdon@google.com, brho@google.com, sched-ext@lists.linux.dev,
linux-kernel@vger.kernel.org, tanghui20@huawei.com,
zhangqiao22@huawei.com, quzicheng@huawei.com
Subject: Re: [PATCH] sched_ext: Rebuild fair weight when disabling BPF scheduler
Date: Tue, 26 May 2026 19:20:40 +0200 [thread overview]
Message-ID: <ahXWaL2BYLU6ukkO@gpd4> (raw)
In-Reply-To: <20260526135211.1892261-1-quzicheng315@gmail.com>
Hi Zicheng,
On Tue, May 26, 2026 at 09:52:11PM +0800, Zicheng Qu wrote:
> From: Zicheng Qu <quzicheng@huawei.com>
>
> When a BPF scheduler is disabled, scx_root_disable() switches tasks
> from ext_sched_class back to fair_sched_class directly. This does not
> go through __setscheduler_params(), so p->se.load is not rebuilt for
> tasks returning to fair.
>
> For example, after enabling a sched_ext BPF scheduler and creating
> CPU-bound tasks with different nice values, disabling the BPF scheduler
> can leave them running under fair with stale p->se.load. They may then
> split CPU time according to the stale weight instead of their current
> nice weights.
>
> Rebuild the fair load weight when scx_root_disable() switches a task
> from ext_sched_class to fair_sched_class. Use set_load_weight(p, false)
> so CFS gets a native load_weight derived from the task's current
> policy/static_prio before the task is enqueued on fair.
>
> Fixes: f0e1a0643a59 ("sched_ext: Implement BPF extensible scheduler class")
> Signed-off-by: Zicheng Qu <quzicheng@huawei.com>
> ---
> kernel/sched/ext.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index 65631e577ee9..e5b8509ce7ee 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -5967,6 +5967,10 @@ static void scx_root_disable(struct scx_sched *sch)
>
> scoped_guard (sched_change, p, queue_flags) {
> p->sched_class = new_class;
> +
> + if (old_class == &ext_sched_class &&
> + new_class == &fair_sched_class)
> + set_load_weight(p, false);
I'm wondering if we have a similar issue for tasks moving from SCHED_EXT to
SCHED_NORMAL when a scx scheduler is running in partial mode. Maybe we need to
intercept this special case in __sched_setscheduler()? (not necessarily for this
patch, it can be addressed later as a separate follow-up patch).
For now, this makes sense to me.
Reviewed-by: Andrea Righi <arighi@nvidia.com>
Thanks,
-Andrea
> }
>
> scx_disable_and_exit_task(scx_task_sched(p), p);
> --
> 2.43.0
>
next prev parent reply other threads:[~2026-05-26 17:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 13:52 [PATCH] sched_ext: Rebuild fair weight when disabling BPF scheduler Zicheng Qu
2026-05-26 15:18 ` sashiko-bot
2026-05-26 17:20 ` Andrea Righi [this message]
2026-05-27 9:40 ` [PATCH v2] sched_ext: Rebuild fair weight on ext to fair switches quzicheng315
2026-05-27 11:26 ` Peter Zijlstra
2026-05-28 2:53 ` Zicheng Qu
2026-05-28 9:25 ` Peter Zijlstra
2026-05-28 13:12 ` [PATCH v3] sched/fair: Rebuild load weight when switching to fair quzicheng315
2026-05-28 14:27 ` Tejun Heo
2026-05-30 5:06 ` sashiko-bot
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=ahXWaL2BYLU6ukkO@gpd4 \
--to=arighi@nvidia.com \
--cc=brho@google.com \
--cc=bsegall@google.com \
--cc=changwoo@igalia.com \
--cc=dietmar.eggemann@arm.com \
--cc=haoluo@google.com \
--cc=joshdon@google.com \
--cc=juri.lelli@redhat.co \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=quzicheng315@gmail.com \
--cc=quzicheng@huawei.com \
--cc=rostedt@goodmis.org \
--cc=sched-ext@lists.linux.dev \
--cc=tanghui20@huawei.com \
--cc=tj@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=void@manifault.com \
--cc=vschneid@redhat.com \
--cc=zhangqiao22@huawei.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.