mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
cgroup: Print message when /proc/cgroups is read on v2-only system
As a followup to commits6c2920926b
("cgroup: replace unified-hierarchy.txt with a proper cgroup v2 documentation") andab03125268
("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>
This commit is contained in:
parent
77bbb259db
commit
a0ab145322
3 changed files with 9 additions and 1 deletions
|
@ -168,6 +168,7 @@ struct cgroup_mgctx {
|
||||||
|
|
||||||
extern struct cgroup_subsys *cgroup_subsys[];
|
extern struct cgroup_subsys *cgroup_subsys[];
|
||||||
extern struct list_head cgroup_roots;
|
extern struct list_head cgroup_roots;
|
||||||
|
extern bool cgrp_dfl_visible;
|
||||||
|
|
||||||
/* iterate across the hierarchies */
|
/* iterate across the hierarchies */
|
||||||
#define for_each_root(root) \
|
#define for_each_root(root) \
|
||||||
|
|
|
@ -673,6 +673,7 @@ struct cftype cgroup1_base_files[] = {
|
||||||
int proc_cgroupstats_show(struct seq_file *m, void *v)
|
int proc_cgroupstats_show(struct seq_file *m, void *v)
|
||||||
{
|
{
|
||||||
struct cgroup_subsys *ss;
|
struct cgroup_subsys *ss;
|
||||||
|
bool cgrp_v1_visible = false;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
seq_puts(m, "#subsys_name\thierarchy\tnum_cgroups\tenabled\n");
|
seq_puts(m, "#subsys_name\thierarchy\tnum_cgroups\tenabled\n");
|
||||||
|
@ -684,12 +685,18 @@ int proc_cgroupstats_show(struct seq_file *m, void *v)
|
||||||
for_each_subsys(ss, i) {
|
for_each_subsys(ss, i) {
|
||||||
if (cgroup1_subsys_absent(ss))
|
if (cgroup1_subsys_absent(ss))
|
||||||
continue;
|
continue;
|
||||||
|
cgrp_v1_visible |= ss->root != &cgrp_dfl_root;
|
||||||
|
|
||||||
seq_printf(m, "%s\t%d\t%d\t%d\n",
|
seq_printf(m, "%s\t%d\t%d\t%d\n",
|
||||||
ss->legacy_name, ss->root->hierarchy_id,
|
ss->legacy_name, ss->root->hierarchy_id,
|
||||||
atomic_read(&ss->root->nr_cgrps),
|
atomic_read(&ss->root->nr_cgrps),
|
||||||
cgroup_ssid_enabled(i));
|
cgroup_ssid_enabled(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cgrp_dfl_visible && !cgrp_v1_visible)
|
||||||
|
pr_info_once("/proc/cgroups lists only v1 controllers, use cgroup.controllers of root cgroup for v2 info\n");
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -171,7 +171,7 @@ EXPORT_SYMBOL_GPL(cgrp_dfl_root);
|
||||||
* The default hierarchy always exists but is hidden until mounted for the
|
* The default hierarchy always exists but is hidden until mounted for the
|
||||||
* first time. This is for backward compatibility.
|
* first time. This is for backward compatibility.
|
||||||
*/
|
*/
|
||||||
static bool cgrp_dfl_visible;
|
bool cgrp_dfl_visible;
|
||||||
|
|
||||||
/* some controllers are not supported in the default hierarchy */
|
/* some controllers are not supported in the default hierarchy */
|
||||||
static u16 cgrp_dfl_inhibit_ss_mask;
|
static u16 cgrp_dfl_inhibit_ss_mask;
|
||||||
|
|
Loading…
Add table
Reference in a new issue