Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

cgroup: Print message when /proc/cgroups is read on v2-only system

As a followup to commits 6c2920926b10e ("cgroup: replace
unified-hierarchy.txt with a proper cgroup v2 documentation") and
ab03125268679 ("cgroup: Show # of subsystem CSSes in cgroup.stat"),
add a runtime message to users who read status of controllers in
/proc/cgroups on v2-only system. The detection is based on a)
no controllers are attached to v1, b) default hierarchy is mounted (the
latter is for setups that never mount v2 but read /proc/cgroups upon
boot when controllers default to v2, so that this code may be backported
to older kernels).

Signed-off-by: Michal Koutný <mkoutny@suse.com>
Acked-by: Waiman Long <longman@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Michal Koutný and committed by
Tejun Heo
a0ab1453 77bbb259

+9 -1
+1
kernel/cgroup/cgroup-internal.h
··· 168 168 169 169 extern struct cgroup_subsys *cgroup_subsys[]; 170 170 extern struct list_head cgroup_roots; 171 + extern bool cgrp_dfl_visible; 171 172 172 173 /* iterate across the hierarchies */ 173 174 #define for_each_root(root) \
+7
kernel/cgroup/cgroup-v1.c
··· 673 673 int proc_cgroupstats_show(struct seq_file *m, void *v) 674 674 { 675 675 struct cgroup_subsys *ss; 676 + bool cgrp_v1_visible = false; 676 677 int i; 677 678 678 679 seq_puts(m, "#subsys_name\thierarchy\tnum_cgroups\tenabled\n"); ··· 685 684 for_each_subsys(ss, i) { 686 685 if (cgroup1_subsys_absent(ss)) 687 686 continue; 687 + cgrp_v1_visible |= ss->root != &cgrp_dfl_root; 688 + 688 689 seq_printf(m, "%s\t%d\t%d\t%d\n", 689 690 ss->legacy_name, ss->root->hierarchy_id, 690 691 atomic_read(&ss->root->nr_cgrps), 691 692 cgroup_ssid_enabled(i)); 692 693 } 694 + 695 + if (cgrp_dfl_visible && !cgrp_v1_visible) 696 + pr_info_once("/proc/cgroups lists only v1 controllers, use cgroup.controllers of root cgroup for v2 info\n"); 697 + 693 698 694 699 return 0; 695 700 }
+1 -1
kernel/cgroup/cgroup.c
··· 171 171 * The default hierarchy always exists but is hidden until mounted for the 172 172 * first time. This is for backward compatibility. 173 173 */ 174 - static bool cgrp_dfl_visible; 174 + bool cgrp_dfl_visible; 175 175 176 176 /* some controllers are not supported in the default hierarchy */ 177 177 static u16 cgrp_dfl_inhibit_ss_mask;