* FAILED: patch "[PATCH] sched_ext: Skip ops.set_weight() for disabled tasks" failed to apply to 7.1-stable tree
@ 2026-07-21 9:17 gregkh
2026-07-21 13:47 ` Kuba Piecuch
0 siblings, 1 reply; 6+ messages in thread
From: gregkh @ 2026-07-21 9:17 UTC (permalink / raw)
To: jpiecuch, tj; +Cc: stable
The patch below does not apply to the 7.1-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-7.1.y
git checkout FETCH_HEAD
git cherry-pick -x 0e2f4ab68a89fad42e0f5a9ff4b740738e7aa1d6
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026072131-citation-reshape-587c@gregkh' --subject-prefix 'PATCH 7.1.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 0e2f4ab68a89fad42e0f5a9ff4b740738e7aa1d6 Mon Sep 17 00:00:00 2001
From: Kuba Piecuch <jpiecuch@google.com>
Date: Fri, 10 Jul 2026 14:43:41 +0000
Subject: [PATCH] sched_ext: Skip ops.set_weight() for disabled tasks
When switching a task's sched_class away from sched_ext, we get the
following sequence of events in __sched_setscheduler():
sched_change_begin()
switched_from_scx()
scx_disable_task(p)
ops.disable(p)
__setscheduler_params()
set_load_weight()
reweight_task_scx(p)
ops.set_weight(p)
p->sched_class = next_class;
sched_change_end()
...
Notably, ops.set_weight() is called _after_ ops.disable().
This violates the expected semantics of the callbacks, the expectation
being that ops.disable() can only be followed by ops.exit_task() or
ops.enable().
Skipping the weight adjustment for disabled tasks should be harmless
since the weight will be recalculated in scx_enable_task() if the task
ever rejoins SCX.
Fixes: 637b0682821b ("sched: Fold sched_class::switch{ing,ed}_{to,from}() into the change pattern")
Cc: stable@vger.kernel.org # v6.19+
Signed-off-by: Kuba Piecuch <jpiecuch@google.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
index aeee44e016ab..e3fa7b2fac9d 100644
--- a/kernel/sched/ext/ext.c
+++ b/kernel/sched/ext/ext.c
@@ -3967,6 +3967,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);
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: FAILED: patch "[PATCH] sched_ext: Skip ops.set_weight() for disabled tasks" failed to apply to 7.1-stable tree
2026-07-21 9:17 FAILED: patch "[PATCH] sched_ext: Skip ops.set_weight() for disabled tasks" failed to apply to 7.1-stable tree gregkh
@ 2026-07-21 13:47 ` Kuba Piecuch
2026-07-21 14:19 ` Greg KH
0 siblings, 1 reply; 6+ messages in thread
From: Kuba Piecuch @ 2026-07-21 13:47 UTC (permalink / raw)
To: gregkh, jpiecuch, tj; +Cc: stable
Hi Greg,
I'm unable to reproduce the failure using the steps provided.
The patch applies cleanly. The code compiles and tests are passing.
FWIW, below is the patch after cherry-picking the commit:
Thanks,
Kuba
------------------------ 8< ----------------------------
From adc748e669cc1564255430299abf086b9ecd9b45 Mon Sep 17 00:00:00 2001
From: Kuba Piecuch <jpiecuch@google.com>
Date: Fri, 10 Jul 2026 14:43:41 +0000
Subject: [PATCH] sched_ext: Skip ops.set_weight() for disabled tasks
When switching a task's sched_class away from sched_ext, we get the
following sequence of events in __sched_setscheduler():
sched_change_begin()
switched_from_scx()
scx_disable_task(p)
ops.disable(p)
__setscheduler_params()
set_load_weight()
reweight_task_scx(p)
ops.set_weight(p)
p->sched_class = next_class;
sched_change_end()
...
Notably, ops.set_weight() is called _after_ ops.disable().
This violates the expected semantics of the callbacks, the expectation
being that ops.disable() can only be followed by ops.exit_task() or
ops.enable().
Skipping the weight adjustment for disabled tasks should be harmless
since the weight will be recalculated in scx_enable_task() if the task
ever rejoins SCX.
Fixes: 637b0682821b ("sched: Fold sched_class::switch{ing,ed}_{to,from}() into the change pattern")
Cc: stable@vger.kernel.org # v6.19+
Signed-off-by: Kuba Piecuch <jpiecuch@google.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
(cherry picked from commit 0e2f4ab68a89fad42e0f5a9ff4b740738e7aa1d6)
---
kernel/sched/ext.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 5d2d19473a82..8429bebc21a1 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -3904,6 +3904,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);
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: FAILED: patch "[PATCH] sched_ext: Skip ops.set_weight() for disabled tasks" failed to apply to 7.1-stable tree
2026-07-21 13:47 ` Kuba Piecuch
@ 2026-07-21 14:19 ` Greg KH
2026-07-21 14:19 ` Greg KH
0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2026-07-21 14:19 UTC (permalink / raw)
To: Kuba Piecuch; +Cc: tj, stable
On Tue, Jul 21, 2026 at 01:47:04PM +0000, Kuba Piecuch wrote:
> Hi Greg,
>
> I'm unable to reproduce the failure using the steps provided.
> The patch applies cleanly. The code compiles and tests are passing.
>
> FWIW, below is the patch after cherry-picking the commit:
>
> Thanks,
> Kuba
>
> ------------------------ 8< ----------------------------
>
> >From adc748e669cc1564255430299abf086b9ecd9b45 Mon Sep 17 00:00:00 2001
> From: Kuba Piecuch <jpiecuch@google.com>
> Date: Fri, 10 Jul 2026 14:43:41 +0000
> Subject: [PATCH] sched_ext: Skip ops.set_weight() for disabled tasks
>
> When switching a task's sched_class away from sched_ext, we get the
> following sequence of events in __sched_setscheduler():
>
> sched_change_begin()
> switched_from_scx()
> scx_disable_task(p)
> ops.disable(p)
> __setscheduler_params()
> set_load_weight()
> reweight_task_scx(p)
> ops.set_weight(p)
> p->sched_class = next_class;
> sched_change_end()
> ...
>
> Notably, ops.set_weight() is called _after_ ops.disable().
> This violates the expected semantics of the callbacks, the expectation
> being that ops.disable() can only be followed by ops.exit_task() or
> ops.enable().
>
> Skipping the weight adjustment for disabled tasks should be harmless
> since the weight will be recalculated in scx_enable_task() if the task
> ever rejoins SCX.
>
> Fixes: 637b0682821b ("sched: Fold sched_class::switch{ing,ed}_{to,from}() into the change pattern")
> Cc: stable@vger.kernel.org # v6.19+
> Signed-off-by: Kuba Piecuch <jpiecuch@google.com>
> Signed-off-by: Tejun Heo <tj@kernel.org>
> (cherry picked from commit 0e2f4ab68a89fad42e0f5a9ff4b740738e7aa1d6)
> ---
> kernel/sched/ext.c | 11 +++++++++++
If you look, the original file was:
kernel/sched/ext/ext.c
your cherry-pick fixed that.
I'll take this, thanks.
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: FAILED: patch "[PATCH] sched_ext: Skip ops.set_weight() for disabled tasks" failed to apply to 7.1-stable tree
2026-07-21 14:19 ` Greg KH
@ 2026-07-21 14:19 ` Greg KH
2026-07-21 15:04 ` [PATCH 7.1.y] sched_ext: Skip ops.set_weight() for disabled tasks Kuba Piecuch
0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2026-07-21 14:19 UTC (permalink / raw)
To: Kuba Piecuch; +Cc: tj, stable
On Tue, Jul 21, 2026 at 04:19:02PM +0200, Greg KH wrote:
> On Tue, Jul 21, 2026 at 01:47:04PM +0000, Kuba Piecuch wrote:
> > Hi Greg,
> >
> > I'm unable to reproduce the failure using the steps provided.
> > The patch applies cleanly. The code compiles and tests are passing.
> >
> > FWIW, below is the patch after cherry-picking the commit:
> >
> > Thanks,
> > Kuba
> >
> > ------------------------ 8< ----------------------------
> >
> > >From adc748e669cc1564255430299abf086b9ecd9b45 Mon Sep 17 00:00:00 2001
> > From: Kuba Piecuch <jpiecuch@google.com>
> > Date: Fri, 10 Jul 2026 14:43:41 +0000
> > Subject: [PATCH] sched_ext: Skip ops.set_weight() for disabled tasks
> >
> > When switching a task's sched_class away from sched_ext, we get the
> > following sequence of events in __sched_setscheduler():
> >
> > sched_change_begin()
> > switched_from_scx()
> > scx_disable_task(p)
> > ops.disable(p)
> > __setscheduler_params()
> > set_load_weight()
> > reweight_task_scx(p)
> > ops.set_weight(p)
> > p->sched_class = next_class;
> > sched_change_end()
> > ...
> >
> > Notably, ops.set_weight() is called _after_ ops.disable().
> > This violates the expected semantics of the callbacks, the expectation
> > being that ops.disable() can only be followed by ops.exit_task() or
> > ops.enable().
> >
> > Skipping the weight adjustment for disabled tasks should be harmless
> > since the weight will be recalculated in scx_enable_task() if the task
> > ever rejoins SCX.
> >
> > Fixes: 637b0682821b ("sched: Fold sched_class::switch{ing,ed}_{to,from}() into the change pattern")
> > Cc: stable@vger.kernel.org # v6.19+
> > Signed-off-by: Kuba Piecuch <jpiecuch@google.com>
> > Signed-off-by: Tejun Heo <tj@kernel.org>
> > (cherry picked from commit 0e2f4ab68a89fad42e0f5a9ff4b740738e7aa1d6)
> > ---
> > kernel/sched/ext.c | 11 +++++++++++
>
> If you look, the original file was:
> kernel/sched/ext/ext.c
> your cherry-pick fixed that.
>
> I'll take this, thanks.
Nope, the whitespace is corrupted, please send a good copy.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 7.1.y] sched_ext: Skip ops.set_weight() for disabled tasks
2026-07-21 14:19 ` Greg KH
@ 2026-07-21 15:04 ` Kuba Piecuch
2026-07-22 0:53 ` Sasha Levin
0 siblings, 1 reply; 6+ messages in thread
From: Kuba Piecuch @ 2026-07-21 15:04 UTC (permalink / raw)
To: Greg KH, stable; +Cc: Kuba Piecuch, Tejun Heo
When switching a task's sched_class away from sched_ext, we get the
following sequence of events in __sched_setscheduler():
sched_change_begin()
switched_from_scx()
scx_disable_task(p)
ops.disable(p)
__setscheduler_params()
set_load_weight()
reweight_task_scx(p)
ops.set_weight(p)
p->sched_class = next_class;
sched_change_end()
...
Notably, ops.set_weight() is called _after_ ops.disable().
This violates the expected semantics of the callbacks, the expectation
being that ops.disable() can only be followed by ops.exit_task() or
ops.enable().
Skipping the weight adjustment for disabled tasks should be harmless
since the weight will be recalculated in scx_enable_task() if the task
ever rejoins SCX.
Fixes: 637b0682821b ("sched: Fold sched_class::switch{ing,ed}_{to,from}() into the change pattern")
Cc: stable@vger.kernel.org # v6.19+
Signed-off-by: Kuba Piecuch <jpiecuch@google.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
(cherry picked from commit 0e2f4ab68a89fad42e0f5a9ff4b740738e7aa1d6)
---
kernel/sched/ext.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 5d2d19473a82..8429bebc21a1 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -3904,6 +3904,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);
--
2.55.0.229.g6434b31f56-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-07-22 0:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-21 9:17 FAILED: patch "[PATCH] sched_ext: Skip ops.set_weight() for disabled tasks" failed to apply to 7.1-stable tree gregkh
2026-07-21 13:47 ` Kuba Piecuch
2026-07-21 14:19 ` Greg KH
2026-07-21 14:19 ` Greg KH
2026-07-21 15:04 ` [PATCH 7.1.y] sched_ext: Skip ops.set_weight() for disabled tasks Kuba Piecuch
2026-07-22 0:53 ` Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox