|
@@ -149,6 +149,12 @@ struct cgroup_root cgrp_dfl_root;
|
|
|
*/
|
|
|
static bool cgrp_dfl_root_visible;
|
|
|
|
|
|
+/*
|
|
|
+ * Set by the boot param of the same name and makes subsystems with NULL
|
|
|
+ * ->dfl_files to use ->legacy_files on the default hierarchy.
|
|
|
+ */
|
|
|
+static bool cgroup_legacy_files_on_dfl;
|
|
|
+
|
|
|
/* some controllers are not supported in the default hierarchy */
|
|
|
static const unsigned int cgrp_dfl_root_inhibit_ss_mask = 0
|
|
|
#ifdef CONFIG_CGROUP_DEBUG
|
|
@@ -3085,6 +3091,9 @@ static void cgroup_exit_cftypes(struct cftype *cfts)
|
|
|
kfree(cft->kf_ops);
|
|
|
cft->kf_ops = NULL;
|
|
|
cft->ss = NULL;
|
|
|
+
|
|
|
+ /* revert flags set by cgroup core while adding @cfts */
|
|
|
+ cft->flags &= ~(CFTYPE_ONLY_ON_DFL | CFTYPE_INSANE);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -3195,8 +3204,37 @@ static int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts)
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * cgroup_add_dfl_cftypes - add an array of cftypes for default hierarchy
|
|
|
+ * @ss: target cgroup subsystem
|
|
|
+ * @cfts: zero-length name terminated array of cftypes
|
|
|
+ *
|
|
|
+ * Similar to cgroup_add_cftypes() but the added files are only used for
|
|
|
+ * the default hierarchy.
|
|
|
+ */
|
|
|
+int cgroup_add_dfl_cftypes(struct cgroup_subsys *ss, struct cftype *cfts)
|
|
|
+{
|
|
|
+ struct cftype *cft;
|
|
|
+
|
|
|
+ for (cft = cfts; cft && cft->name[0] != '\0'; cft++)
|
|
|
+ cft->flags |= CFTYPE_ONLY_ON_DFL;
|
|
|
+ return cgroup_add_cftypes(ss, cfts);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * cgroup_add_legacy_cftypes - add an array of cftypes for legacy hierarchies
|
|
|
+ * @ss: target cgroup subsystem
|
|
|
+ * @cfts: zero-length name terminated array of cftypes
|
|
|
+ *
|
|
|
+ * Similar to cgroup_add_cftypes() but the added files are only used for
|
|
|
+ * the legacy hierarchies.
|
|
|
+ */
|
|
|
int cgroup_add_legacy_cftypes(struct cgroup_subsys *ss, struct cftype *cfts)
|
|
|
{
|
|
|
+ struct cftype *cft;
|
|
|
+
|
|
|
+ for (cft = cfts; cft && cft->name[0] != '\0'; cft++)
|
|
|
+ cft->flags |= CFTYPE_INSANE;
|
|
|
return cgroup_add_cftypes(ss, cfts);
|
|
|
}
|
|
|
|
|
@@ -4893,9 +4931,19 @@ int __init cgroup_init(void)
|
|
|
* disabled flag and cftype registration needs kmalloc,
|
|
|
* both of which aren't available during early_init.
|
|
|
*/
|
|
|
- if (!ss->disabled) {
|
|
|
- cgrp_dfl_root.subsys_mask |= 1 << ss->id;
|
|
|
- WARN_ON(cgroup_add_cftypes(ss, ss->legacy_cftypes));
|
|
|
+ if (ss->disabled)
|
|
|
+ continue;
|
|
|
+
|
|
|
+ cgrp_dfl_root.subsys_mask |= 1 << ss->id;
|
|
|
+
|
|
|
+ if (cgroup_legacy_files_on_dfl && !ss->dfl_cftypes)
|
|
|
+ ss->dfl_cftypes = ss->legacy_cftypes;
|
|
|
+
|
|
|
+ if (ss->dfl_cftypes == ss->legacy_cftypes) {
|
|
|
+ WARN_ON(cgroup_add_cftypes(ss, ss->dfl_cftypes));
|
|
|
+ } else {
|
|
|
+ WARN_ON(cgroup_add_dfl_cftypes(ss, ss->dfl_cftypes));
|
|
|
+ WARN_ON(cgroup_add_legacy_cftypes(ss, ss->legacy_cftypes));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -5291,6 +5339,14 @@ static int __init cgroup_disable(char *str)
|
|
|
}
|
|
|
__setup("cgroup_disable=", cgroup_disable);
|
|
|
|
|
|
+static int __init cgroup_set_legacy_files_on_dfl(char *str)
|
|
|
+{
|
|
|
+ printk("cgroup: using legacy files on the default hierarchy\n");
|
|
|
+ cgroup_legacy_files_on_dfl = true;
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+__setup("cgroup__DEVEL__legacy_files_on_dfl", cgroup_set_legacy_files_on_dfl);
|
|
|
+
|
|
|
/**
|
|
|
* css_tryget_online_from_dir - get corresponding css from a cgroup dentry
|
|
|
* @dentry: directory dentry of interest
|