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

psi: fix wrong iteration in iterate_groups

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I562O9


CVE: NA
backport: openEuler-22.03-LTS

--------------------------------

It is different to get the cgroup that is used to update psi info in
cgroup v1 and cgroup v2.

task_cgroup can only used in cgroup v1, so add branch to achieve this.

Signed-off-by: default avatarChen Wandun <chenwandun@huawei.com>
Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent ea9d73cf
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -757,9 +757,13 @@ static struct psi_group *iterate_groups(struct task_struct *task, void **iter)
			cgroup = task->cgroups->dfl_cgrp;
		else {
#ifdef CONFIG_CGROUP_CPUACCT
			if (!cgroup_subsys_on_dfl(cpuacct_cgrp_subsys)) {
				rcu_read_lock();
				cgroup = task_cgroup(task, cpuacct_cgrp_id);
				rcu_read_unlock();
			} else {
				cgroup = task->cgroups->dfl_cgrp;
			}
#else
			cgroup = NULL;
#endif