cgroup: implement CFTYPE_ONLY_ON_DFL
[firefly-linux-kernel-4.4.55.git] / include / linux / cgroup.h
index 3752a0182c94871ef92574578a026157fd8f4769..43d1ed30bae3a76ce83b1007886d813c561419b1 100644 (file)
@@ -24,7 +24,7 @@
 
 #ifdef CONFIG_CGROUPS
 
-struct cgroupfs_root;
+struct cgroup_root;
 struct cgroup_subsys;
 struct inode;
 struct cgroup;
@@ -179,7 +179,7 @@ struct cgroup {
        /* Private pointers for each registered subsystem */
        struct cgroup_subsys_state __rcu *subsys[CGROUP_SUBSYS_COUNT];
 
-       struct cgroupfs_root *root;
+       struct cgroup_root *root;
 
        /*
         * List of cgrp_cset_links pointing at css_sets with tasks in this
@@ -211,7 +211,7 @@ struct cgroup {
 
 #define MAX_CGROUP_ROOT_NAMELEN 64
 
-/* cgroupfs_root->flags */
+/* cgroup_root->flags */
 enum {
        /*
         * Unfortunately, cgroup core and various controllers are riddled
@@ -250,6 +250,9 @@ enum {
         *
         * - "cgroup.clone_children" is removed.
         *
+        * - If mount is requested with sane_behavior but without any
+        *   subsystem, the default unified hierarchy is mounted.
+        *
         * - cpuset: tasks will be kept in empty cpusets when hotplug happens
         *   and take masks of ancestors with non-empty cpus/mems, instead of
         *   being moved to an ancestor.
@@ -272,18 +275,18 @@ enum {
 };
 
 /*
- * A cgroupfs_root represents the root of a cgroup hierarchy, and may be
+ * A cgroup_root represents the root of a cgroup hierarchy, and may be
  * associated with a kernfs_root to form an active hierarchy.  This is
  * internal to cgroup core.  Don't access directly from controllers.
  */
-struct cgroupfs_root {
+struct cgroup_root {
        struct kernfs_root *kf_root;
 
        /* Unique id for this hierarchy. */
        int hierarchy_id;
 
        /* The root cgroup.  Root is destroyed on its release. */
-       struct cgroup top_cgroup;
+       struct cgroup cgrp;
 
        /* Number of cgroups in the hierarchy, used only for /proc/cgroups */
        atomic_t nr_cgrps;
@@ -381,6 +384,7 @@ enum {
        CFTYPE_NOT_ON_ROOT      = (1 << 1),     /* don't create on root cgrp */
        CFTYPE_INSANE           = (1 << 2),     /* don't create if sane_behavior */
        CFTYPE_NO_PREFIX        = (1 << 3),     /* (DON'T USE FOR NEW FILES) no subsys prefix */
+       CFTYPE_ONLY_ON_DFL      = (1 << 4),     /* only on default hierarchy */
 };
 
 #define MAX_CFTYPE_NAME                64
@@ -454,7 +458,7 @@ struct cftype {
         * Returns 0 or -ve error code.
         */
        int (*write_string)(struct cgroup_subsys_state *css, struct cftype *cft,
-                           const char *buffer);
+                           char *buffer);
        /*
         * trigger() callback can be used to get some kick from the
         * userspace, when the actual string written is not important
@@ -468,6 +472,13 @@ struct cftype {
 #endif
 };
 
+extern struct cgroup_root cgrp_dfl_root;
+
+static inline bool cgroup_on_dfl(const struct cgroup *cgrp)
+{
+       return cgrp->root == &cgrp_dfl_root;
+}
+
 /*
  * See the comment above CGRP_ROOT_SANE_BEHAVIOR for details.  This
  * function can be called as long as @cgrp is accessible.
@@ -598,7 +609,7 @@ struct cgroup_subsys {
        const char *name;
 
        /* link to parent, protected by cgroup_lock() */
-       struct cgroupfs_root *root;
+       struct cgroup_root *root;
 
        /*
         * List of cftypes.  Each entry is the first entry of an array