Skip to contentSkip to conversation

cgroup: cleanup the format of /proc/cgroups

PATCH In review Feng Tang 2 participants 3 messages Aug 21, 2022 – Aug 22, 2022 2 messages not in the archive cgroup

lore
Share & tools
lore

Feng Tang

author
#0 lore raw

PATCH 1/1 cgroup: cleanup the format of /proc/cgroups

Currrent /proc/cgroup output is like:

#subsys_name hierarchy num_cgroups enabled
cpuset 6 1 1
cpu 4 7 1
cpuacct 4 7 1
blkio 8 7 1
memory 9 7 1
...

Add some indentation to make it more readable without any functional change:

  #subsys_name         hierarchy        num_cgroups      enabled
  cpuset               8                1                1
  cpu                  4                7                1
  cpuacct              4                7                1
  blkio                2                7                1
  memory               5                7                1

...

---
 kernel/cgroup/cgroup-v1.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
kernel/cgroup/cgroup-v1.c +8 -2
index 2ade21b54dc4..e370ce3afdad 100644
@@ -670,14 +670,20 @@ int proc_cgroupstats_show(struct seq_file *m, void *v)
 	struct cgroup_subsys *ss;
 	int i;
 
-	seq_puts(m, "#subsys_name\thierarchy\tnum_cgroups\tenabled\n");
+	seq_printf(m, "%-20s %-16s %-16s %-16s\n",
+			"#subsys_name",
+			"hierarchy",
+			"num_cgroups",
+			"enabled"
+			);
+
 	/*
 	 * Grab the subsystems state racily. No need to add avenue to
 	 * cgroup_mutex contention.
 	 */
 
 	for_each_subsys(ss, i)
-		seq_printf(m, "%s\t%d\t%d\t%d\n",
+		seq_printf(m, "%-20s %-16d %-16d %-16d\n",
 			   ss->legacy_name, ss->root->hierarchy_id,
 			   atomic_read(&ss->root->nr_cgrps),
 			   cgroup_ssid_enabled(i));
Signature · 1 line
2.27.0

A message that is not in the archive (sent off-list or not yet received): 20220821073446.92669-1-feng.tang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#2 lore raw

Hello,

Quoted 10 lines · Feng Tang

Currrent /proc/cgroup output is like:

#subsys_name hierarchy num_cgroups enabled
cpuset 6 1 1
cpu 4 7 1
cpuacct 4 7 1
blkio 8 7 1
memory 9 7 1
...

Quoted 2 lines

Add some indentation to make it more readable without any functional change:

So, this has been suggested a couple times before and I fully agree that the file is really ugly. In the past, we didn't pull the trigger on it for two reasons - 1. It is user-visible functional change in that it can break really dumb parsers 2. the file is only useful for cgroup1 which has been in mostly maintenance mode for many years now. I don't feel that strongly either way but still kinda lean towards just leaving it as-is.

Thanks.

Signature · 1 line
tejun

A message that is not in the archive (sent off-list or not yet received): YwMwlMv/tK3sRXbB-NiLfg/[email protected]

author
#4 lore raw
Quoted 16 lines · Tejun Heo

Hello,

Quoted 10 lines · Feng Tang

Currrent /proc/cgroup output is like:

#subsys_name hierarchy num_cgroups enabled
cpuset 6 1 1
cpu 4 7 1
cpuacct 4 7 1
blkio 8 7 1
memory 9 7 1
...

Quoted 2 lines

Add some indentation to make it more readable without any functional change:

Quoted 6 lines

So, this has been suggested a couple times before and I fully agree that the file is really ugly. In the past, we didn't pull the trigger on it for two reasons - 1. It is user-visible functional change in that it can break really dumb parsers 2. the file is only useful for cgroup1 which has been in mostly maintenance mode for many years now. I don't feel that strongly either way but still kinda lean towards just leaving it as-is.

Ok, makes sense to me. Thanks for the explaination!

Thanks,
Feng

Quoted 4 lines

Thanks.

Signature · 1 line
tejun