From: Zefan Li lizefan@huawei.com
euler inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8QLND CVE: N/A
-------------------------------------------------
If a cgroup root is dying, show its hierarchy_id and num_cgroups as 0.
Signed-off-by: Zefan Li lizefan@huawei.com Signed-off-by: chenridong chenridong@huawei.com --- kernel/cgroup/cgroup-v1.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c index 134a15e1d83a..f4d9745a48d9 100644 --- a/kernel/cgroup/cgroup-v1.c +++ b/kernel/cgroup/cgroup-v1.c @@ -675,6 +675,7 @@ int proc_cgroupstats_show(struct seq_file *m, void *v) { struct cgroup_subsys *ss; int i; + bool dead;
seq_puts(m, "#subsys_name\thierarchy\tnum_cgroups\tenabled\n"); /* @@ -682,11 +683,13 @@ int proc_cgroupstats_show(struct seq_file *m, void *v) * cgroup_mutex contention. */
- for_each_subsys(ss, i) + for_each_subsys(ss, i) { + dead = percpu_ref_is_dying(&ss->root->cgrp.self.refcnt); seq_printf(m, "%s\t%d\t%d\t%d\n", - ss->legacy_name, ss->root->hierarchy_id, - atomic_read(&ss->root->nr_cgrps), - cgroup_ssid_enabled(i)); + ss->legacy_name, dead ? 0 : ss->root->hierarchy_id, + dead ? 0 : atomic_read(&ss->root->nr_cgrps), + cgroup_ssid_enabled(i)); + }
return 0; }