cgroup: make cgroups info more readable
PATCH 1/1 cgroup: make cgroups info more readable
The current cgroups output format is based on tabs, which may cause misalignment of output information.
Using placeholder formatting can make the output information more readable.
--- kernel/cgroup/cgroup-v1.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/cgroup/cgroup-v1.c +4 -3
@@ -669,15 +669,16 @@ 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,"%16s %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" , - ss->legacy_name, ss->root->hierarchy_id, +seq_printf (m,"%16s %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.34.1
Hi,
I found a discussion about this change in the email thread bellow, and hope it helps you.
https://lore.kernel.org/all/YwMwlMv%[email protected]/#t
Quoted 35 lines · Huan Yang
The current cgroups output format is based on tabs, which may cause misalignment of output information.
Using placeholder formatting can make the output information more readable.
Signed-off-by Huan Yang <[email protected]>--- kernel/cgroup/cgroup-v1.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)kernel/cgroup/cgroup-v1.c +4
-3@@ -669,15 +669,16 @@ 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,"%16s %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" , - ss->legacy_name, ss->root->hierarchy_id, +seq_printf (m,"%16s %16d %16d %16d\n" , ss->legacy_name, + ss->root->hierarchy_id,atomic_read (&ss->root->nr_cgrps),cgroup_ssid_enabled (i));
HI jianfeng
Quoted 6 lines · xiujianfeng
[Some people who received this message don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
Hi,
I found a discussion about this change in the email thread bellow, and hope it helps you.
It's helpful to know why this patch not need, thank you.
Quoted 2 lines
I have a question, that, now that only for cgroup1, when I running qemu ubuntu, I got this:
Quoted 2 lines
mount | grep cgroup
cgroup2 on/sys/fs/cgrouptype cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot)
Only cgroup2 mount in my system, but /proc/cgroup also worked, maybe better to disable this when only cgroup2 mounted?
Quoted 36 lines · Huan Yang
Quoted 35 lines
The current cgroups output format is based on tabs, which may cause misalignment of output information.
Using placeholder formatting can make the output information more readable.
Signed-off-by Huan Yang <[email protected]>--- kernel/cgroup/cgroup-v1.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)kernel/cgroup/cgroup-v1.c +4
-3@@ -669,15 +669,16 @@ 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,"%16s %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" , - ss->legacy_name, ss->root->hierarchy_id, +seq_printf (m,"%16s %16d %16d %16d\n" , ss->legacy_name, + ss->root->hierarchy_id,atomic_read (&ss->root->nr_cgrps),cgroup_ssid_enabled (i));
Hi,
Quoted 18 lines · Huan Yang
HI jianfeng
Quoted 8 lines · xiujianfeng
[Some people who received this message don't often get email from [email protected]. Learn why this is important at
https://aka.ms/LearnAboutSenderIdentification ]Hi,
I found a discussion about this change in the email thread bellow, and hope it helps you.
It's helpful to know why this patch not need, thank you.
Quoted 2 lines
I have a question, that, now that only for cgroup1, when I running qemu ubuntu, I got this:
Quoted 6 lines
Quoted 2 lines
mount | grep cgroup
cgroup2 on/sys/fs/cgrouptype cgroup2(rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot)
Only cgroup2 mount in my system, but
/proc/cgroupalso worked, maybe better to disable this when only cgroup2 mounted?
I’m not the maintainer, so the official answer to this question should be left to them:).
However, I don’t think this is the right way. Even though the information shown by /proc/cgroups doesn’t seem as useful for cgroup2 as for cgroup1 due to cgroup2 has only single hierarchy, it’s not entirely useless, IMHO.
Quoted 39 lines
Quoted 39 lines · Huan Yang
Quoted 37 lines
The current cgroups output format is based on tabs, which may cause misalignment of output information.
Using placeholder formatting can make the output information more readable.
Signed-off-by Huan Yang <[email protected]>---
kernel/cgroup/cgroup-v1.c| 7 ++++---1 file changed, 4 insertions(+), 3 deletions(-)kernel/cgroup/cgroup-v1.c +4
-3@@ -669,15 +669,16 @@ 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, "%16s %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", - ss->legacy_name, ss->root->hierarchy_id, + seq_printf(m, "%16s %16d %16d %16d\n", ss->legacy_name, + ss->root->hierarchy_id, atomic_read(&ss->root->nr_cgrps),
cgroup_ssid_enabled(i));
Quoted 3 lines · xiujianfeng
However, I don’t think this is the right way. Even though the information shown by
/proc/cgroupsdoesn’t seem as useful for cgroup2 as for cgroup1 due to cgroup2 has only single hierarchy, it’s not entirely
OK, thanks for your reply
Quoted 1 line
useless, IMHO.