Commit d767c633 authored by Chen Wandun's avatar Chen Wandun Committed by Zheng Zengkai
Browse files

psi: fix unexpected behavior of psi in cgroup v1 during init

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: f9a7d23a ("psi: introduce psi_v1 boot parameter")
Reported-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: default avatarChen Wandun <chenwandun@huawei.com>
Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 8de3a77b
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -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;