From: Tejun Heo <tj@kernel.org> mainline inclusion from mainline-v6.16-rc3 commit c50784e99f0e7199cdb12dbddf02229b102744ef category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IDC9YK Reference: https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commi... -------------------------------- 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+ Conflicts: kernel/sched/ext.c [Only pick the code modified by this mainline patch.] Signed-off-by: Zicheng Qu <quzicheng@huawei.com> --- kernel/sched/ext.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c index edc29ac492c1..82f356dd47ad 100644 --- a/kernel/sched/ext.c +++ b/kernel/sched/ext.c @@ -3950,12 +3950,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, + 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; - } + + tg->scx_weight = weight; percpu_up_read(&scx_cgroup_rwsem); } -- 2.34.1