cgroup: remove cgrp->top_cgroup
[deliverable/linux.git] / include / linux / cgroup.h
index 45aee0fc6b98af8665a1a24c4b87337965ef4226..64047ae7fde1dcac6b053b7ff974faffdf0f4303 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/idr.h>
 #include <linux/workqueue.h>
 #include <linux/xattr.h>
+#include <linux/fs.h>
 
 #ifdef CONFIG_CGROUPS
 
@@ -155,6 +156,8 @@ enum {
         * specified at mount time and thus is implemented here.
         */
        CGRP_CPUSET_CLONE_CHILDREN,
+       /* see the comment above CGRP_ROOT_SANE_BEHAVIOR for details */
+       CGRP_SANE_BEHAVIOR,
 };
 
 struct cgroup_name {
@@ -201,7 +204,6 @@ struct cgroup {
        struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT];
 
        struct cgroupfs_root *root;
-       struct cgroup *top_cgroup;
 
        /*
         * List of cg_cgroup_links pointing at css_sets with
@@ -238,6 +240,93 @@ struct cgroup {
        struct simple_xattrs xattrs;
 };
 
+#define MAX_CGROUP_ROOT_NAMELEN 64
+
+/* cgroupfs_root->flags */
+enum {
+       /*
+        * Unfortunately, cgroup core and various controllers are riddled
+        * with idiosyncrasies and pointless options.  The following flag,
+        * when set, will force sane behavior - some options are forced on,
+        * others are disallowed, and some controllers will change their
+        * hierarchical or other behaviors.
+        *
+        * The set of behaviors affected by this flag are still being
+        * determined and developed and the mount option for this flag is
+        * prefixed with __DEVEL__.  The prefix will be dropped once we
+        * reach the point where all behaviors are compatible with the
+        * planned unified hierarchy, which will automatically turn on this
+        * flag.
+        *
+        * The followings are the behaviors currently affected this flag.
+        *
+        * - Mount options "noprefix" and "clone_children" are disallowed.
+        *   Also, cgroupfs file cgroup.clone_children is not created.
+        *
+        * - When mounting an existing superblock, mount options should
+        *   match.
+        *
+        * - Remount is disallowed.
+        *
+        * The followings are planned changes.
+        *
+        * - release_agent will be disallowed once replacement notification
+        *   mechanism is implemented.
+        */
+       CGRP_ROOT_SANE_BEHAVIOR = (1 << 0),
+
+       CGRP_ROOT_NOPREFIX      = (1 << 1), /* mounted subsystems have no named prefix */
+       CGRP_ROOT_XATTR         = (1 << 2), /* supports extended attributes */
+};
+
+/*
+ * A cgroupfs_root represents the root of a cgroup hierarchy, and may be
+ * associated with a superblock to form an active hierarchy.  This is
+ * internal to cgroup core.  Don't access directly from controllers.
+ */
+struct cgroupfs_root {
+       struct super_block *sb;
+
+       /*
+        * The bitmask of subsystems intended to be attached to this
+        * hierarchy
+        */
+       unsigned long subsys_mask;
+
+       /* Unique id for this hierarchy. */
+       int hierarchy_id;
+
+       /* The bitmask of subsystems currently attached to this hierarchy */
+       unsigned long actual_subsys_mask;
+
+       /* A list running through the attached subsystems */
+       struct list_head subsys_list;
+
+       /* The root cgroup for this hierarchy */
+       struct cgroup top_cgroup;
+
+       /* Tracks how many cgroups are currently defined in hierarchy.*/
+       int number_of_cgroups;
+
+       /* A list running through the active hierarchies */
+       struct list_head root_list;
+
+       /* All cgroups on this root, cgroup_mutex protected */
+       struct list_head allcg_list;
+
+       /* Hierarchy-specific flags */
+       unsigned long flags;
+
+       /* IDs for cgroups in this hierarchy */
+       struct ida cgroup_ida;
+
+       /* The path to use for release notifications. */
+       char release_agent_path[PATH_MAX];
+
+       /* The name for this hierarchy - may be empty */
+       char name[MAX_CGROUP_ROOT_NAMELEN];
+};
+
 /*
  * A css_set is a structure holding pointers to a set of
  * cgroup_subsys_state objects. This saves space in the task struct
@@ -303,6 +392,7 @@ struct cgroup_map_cb {
 /* cftype->flags */
 #define CFTYPE_ONLY_ON_ROOT    (1U << 0)       /* only create on root cg */
 #define CFTYPE_NOT_ON_ROOT     (1U << 1)       /* don't create on root cg */
+#define CFTYPE_INSANE          (1U << 2)       /* don't create if sane_behavior */
 
 #define MAX_CFTYPE_NAME                64
 
@@ -429,6 +519,15 @@ struct cgroup_scanner {
        void *data;
 };
 
+/*
+ * See the comment above CGRP_ROOT_SANE_BEHAVIOR for details.  This
+ * function can be called as long as @cgrp is accessible.
+ */
+static inline bool cgroup_sane_behavior(const struct cgroup *cgrp)
+{
+       return cgrp->root->flags & CGRP_ROOT_SANE_BEHAVIOR;
+}
+
 /* Caller should hold rcu_read_lock() */
 static inline const char *cgroup_name(const struct cgroup *cgrp)
 {
This page took 0.029166 seconds and 5 git commands to generate.