]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
sched_ext: Make scx_group_set_weight() always update tg->scx.weight
authorSasha Levin <sashal@kernel.org>
Wed, 2 Jul 2025 01:58:33 +0000 (21:58 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 6 Jul 2025 09:04:24 +0000 (11:04 +0200)
[ Upstream commit c50784e99f0e7199cdb12dbddf02229b102744ef ]

Otherwise, tg->scx.weight can go out of sync while scx_cgroup is not enabled
and ops.cgroup_init() may be called with a stale weight value.

Signed-off-by: Tejun Heo <tj@kernel.org>
Fixes: 819513666966 ("sched_ext: Add cgroup support")
Cc: stable@vger.kernel.org # v6.12+
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/sched/ext.c

index afaf49e5ecb976d827cc56cba2cbed25639d93af..86ce43fa36693163eed26d4927ce6d908cb8bcbe 100644 (file)
@@ -4074,12 +4074,12 @@ void scx_group_set_weight(struct task_group *tg, unsigned long weight)
 {
        percpu_down_read(&scx_cgroup_rwsem);
 
-       if (scx_cgroup_enabled && tg->scx_weight != weight) {
-               if (SCX_HAS_OP(cgroup_set_weight))
-                       SCX_CALL_OP(SCX_KF_UNLOCKED, cgroup_set_weight, NULL,
-                                   tg_cgrp(tg), weight);
-               tg->scx_weight = weight;
-       }
+       if (scx_cgroup_enabled && SCX_HAS_OP(cgroup_set_weight) &&
+           tg->scx_weight != weight)
+               SCX_CALL_OP(SCX_KF_UNLOCKED, cgroup_set_weight, NULL,
+                           tg_cgrp(tg), weight);
+
+       tg->scx_weight = weight;
 
        percpu_up_read(&scx_cgroup_rwsem);
 }