From: Chen Wandun chenwandun@huawei.com
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4OF4N
------------------------------------------
Function setup_psi_v1 is called before cgroup_v1_psi_init. Cgroup psi will be enable for a short time between the two functions, when passing parameter psi_v1=0 in kernel boot cmdline, that'is not unexpected behavior.
So the setting of psi_v1_disabled should be run in advance.
Fixes: f9a7d23ac0a0 ("psi: introduce psi_v1 boot parameter") Reported-by: Yang Yingliang yangyingliang@huawei.com Signed-off-by: Chen Wandun chenwandun@huawei.com Reviewed-by: Kefeng Wang wangkefeng.wang@huawei.com Reviewed-by: Kefeng Wang wangkefeng.wang@huawei.com Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com --- kernel/sched/cpuacct.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c index 60a95eb67d9b..e51c1f524b8c 100644 --- a/kernel/sched/cpuacct.c +++ b/kernel/sched/cpuacct.c @@ -380,16 +380,20 @@ struct cgroup_subsys cpuacct_cgrp_subsys = { static bool psi_v1_enable; static int __init setup_psi_v1(char *str) { - return kstrtobool(str, &psi_v1_enable) == 0; + int ret; + + ret = kstrtobool(str, &psi_v1_enable); + if (!psi_v1_enable) + static_branch_enable(&psi_v1_disabled); + + return ret == 0; } __setup("psi_v1=", setup_psi_v1);
static int __init cgroup_v1_psi_init(void) { - if (!psi_v1_enable) { - static_branch_enable(&psi_v1_disabled); + if (!psi_v1_enable) return 0; - }
cgroup_add_legacy_cftypes(&cpuacct_cgrp_subsys, cgroup_v1_psi_files); return 0;