lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220630082539.83602-1-linf@wangsu.com>
Date:   Thu, 30 Jun 2022 16:25:39 +0800
From:   Lin Feng <linf@...gsu.com>
To:     tj@...nel.org, lizefan.x@...edance.com, hannes@...xchg.org
Cc:     cgroups@...r.kernel.org, linux-kernel@...r.kernel.org,
        linf@...gsu.com
Subject: [PATCH] cgroup-v1: use find granularity format identifiers to make /proc/cgroups show pretty

The listing subsys info is unaligned with the header columns and we can
make the output more intuitive to read by specifying "left alignment"
and "fixed length" format styles for seq_printf.

# cat /proc/cgroups

the output originally:

#subsys_name	hierarchy	num_cgroups	enabled
cpuset	11	19	1
cpu	5	122	1
cpuacct	5	122	1
blkio	4	122	1
memory	10	129	1
devices	6	122	1
freezer	9	19	1
net_cls	8	19	1
perf_event	3	19	1
net_prio	8	19	1
hugetlb	7	19	1
pids	12	122	1
rdma	2	1	1

output after this patch:

#subsys_name	hierarchy	num_cgroups	enabled
cpuset      	11        	19      	1
cpu         	5         	122     	1
cpuacct     	5         	122     	1
blkio       	4         	122     	1
memory      	10        	129     	1
devices     	6         	122     	1
freezer     	9         	19      	1
net_cls     	8         	19      	1
perf_event  	3         	19      	1
net_prio    	8         	19      	1
hugetlb     	7         	19      	1
pids        	12        	122     	1
rdma        	2         	1       	1

Signed-off-by: Lin Feng <linf@...gsu.com>
---
 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 afc6c0e9c966..1a74b0c504aa 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%-10d\t%-10d\t%-d\n",
 			   ss->legacy_name, ss->root->hierarchy_id,
 			   atomic_read(&ss->root->nr_cgrps),
 			   cgroup_ssid_enabled(i));
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ