[PATCH] cgroup-v1: tweak the output format of cgroupstats

From: Miaohe Lin
Date: Tue Jun 06 2023 - 09:08:06 EST


The output of /proc/cgroups is somewhat awful now. For example, it may
look like below:

subsys_name hierarchy num_cgroups enabled
cpuset 7 95 1
...
perf_event 6 1 1
...
files 10 1 1

Tweak the output format of cgroup stats to make it look better. After
patch applied, it will look like below:

subsys_name hierarchy num_cgroups enabled
cpuset 11 73 1
...
perf_event 10 1 1
...
files 7 1 1

Signed-off-by: Miaohe Lin <linmiaohe@xxxxxxxxxx>
---
kernel/cgroup/cgroup-v1.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c
index aeef06c465ef..916871babeea 100644
--- a/kernel/cgroup/cgroup-v1.c
+++ b/kernel/cgroup/cgroup-v1.c
@@ -677,7 +677,7 @@ int proc_cgroupstats_show(struct seq_file *m, void *v)
*/

for_each_subsys(ss, i)
- seq_printf(m, "%s\t%d\t%d\t%d\n",
+ seq_printf(m, "%-12s\t%-9d\t%-11d\t%-7d\n",
ss->legacy_name, ss->root->hierarchy_id,
atomic_read(&ss->root->nr_cgrps),
cgroup_ssid_enabled(i));
--
2.27.0