From: Zefan Li
ohos inclusion
category: bugfix
issue: #I3ZXZF
CVE: NA
-------------------------------------------------
If a cgroup root is dying, show its hierarchy_id and num_cgroups
as 0.
Signed-off-by: Zefan Li
Tested-by: Kefeng Wang
Signed-off-by: Hanjun Guo
Signed-off-by: Changchun Yu
Reviewed-by: Zefan Li
Signed-off-by: zhangyi (F)
Signed-off-by: Lu Jialin
Reviewed-by: xiu jianfeng
Signed-off-by: Chen Jun
Signed-off-by: Yu Changchun
---
kernel/cgroup/cgroup-v1.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c
index f6dddb3a8f4a..c7bd9d634e8e 100644
--- a/kernel/cgroup/cgroup-v1.c
+++ b/kernel/cgroup/cgroup-v1.c
@@ -655,6 +655,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");
/*
@@ -665,10 +666,13 @@ int proc_cgroupstats_show(struct seq_file *m, void *v)
mutex_lock(&cgroup_mutex);
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),
+ ss->legacy_name, dead ? 0 : ss->root->hierarchy_id,
+ dead ? 0 : atomic_read(&ss->root->nr_cgrps),
cgroup_ssid_enabled(i));
+ }
mutex_unlock(&cgroup_mutex);
return 0;
--
2.22.0