cgroup: update init_css() into init_and_link_css()
[deliverable/linux.git] / include / linux / cgroup.h
index c2515851c1aa2038c5298c8ab3288d469cd3bb5b..793f70a48820ccfd7468159d0762713015b375c3 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/percpu-refcount.h>
 #include <linux/seq_file.h>
 #include <linux/kernfs.h>
+#include <linux/wait.h>
 
 #ifdef CONFIG_CGROUPS
 
@@ -61,7 +62,7 @@ struct cgroup_subsys_state {
        /* the parent css */
        struct cgroup_subsys_state *parent;
 
-       unsigned long flags;
+       unsigned int flags;
 
        /* percpu_ref killing and RCU release */
        struct rcu_head rcu_head;
@@ -143,8 +144,8 @@ struct cgroup {
        /*
         * idr allocated in-hierarchy ID.
         *
-        * The ID of the root cgroup is always 0, and a new cgroup
-        * will be assigned with a smallest available ID.
+        * ID 0 is not used, the ID of the root cgroup is always 1, and a
+        * new cgroup will be assigned with a smallest available ID.
         *
         * Allocating/Removing ID must be protected by cgroup_mutex.
         */
@@ -153,6 +154,14 @@ struct cgroup {
        /* the number of attached css's */
        int nr_css;
 
+       /*
+        * If this cgroup contains any tasks, it contributes one to
+        * populated_cnt.  All children with non-zero popuplated_cnt of
+        * their own contribute one.  The count is zero iff there's no task
+        * in this cgroup or its subtree.
+        */
+       int populated_cnt;
+
        atomic_t refcnt;
 
        /*
@@ -164,6 +173,8 @@ struct cgroup {
 
        struct cgroup *parent;          /* my parent */
        struct kernfs_node *kn;         /* cgroup kernfs entry */
+       struct kernfs_node *control_kn; /* kn for "cgroup.subtree_control" */
+       struct kernfs_node *populated_kn; /* kn for "cgroup.subtree_populated" */
 
        /*
         * Monotonically increasing unique serial number which defines a
@@ -173,8 +184,8 @@ struct cgroup {
         */
        u64 serial_nr;
 
-       /* The bitmask of subsystems attached to this cgroup */
-       unsigned long subsys_mask;
+       /* the bitmask of subsystems enabled on the child cgroups */
+       unsigned int child_subsys_mask;
 
        /* Private pointers for each registered subsystem */
        struct cgroup_subsys_state __rcu *subsys[CGROUP_SUBSYS_COUNT];
@@ -187,6 +198,15 @@ struct cgroup {
         */
        struct list_head cset_links;
 
+       /*
+        * On the default hierarchy, a css_set for a cgroup with some
+        * susbsys disabled will point to css's which are associated with
+        * the closest ancestor which has the subsys enabled.  The
+        * following lists all css_sets which point to this cgroup's css
+        * for the given subsystem.
+        */
+       struct list_head e_csets[CGROUP_SUBSYS_COUNT];
+
        /*
         * Linked list running through all cgroups that can
         * potentially be reaped by the release agent. Protected by
@@ -207,6 +227,9 @@ struct cgroup {
        /* For css percpu_ref killing and RCU-protected deletion */
        struct rcu_head rcu_head;
        struct work_struct destroy_work;
+
+       /* used to wait for offlining of csses */
+       wait_queue_head_t offline_waitq;
 };
 
 #define MAX_CGROUP_ROOT_NAMELEN 64
@@ -250,6 +273,12 @@ enum {
         *
         * - "cgroup.clone_children" is removed.
         *
+        * - "cgroup.subtree_populated" is available.  Its value is 0 if
+        *   the cgroup and its descendants contain no task; otherwise, 1.
+        *   The file also generates kernfs notification which can be
+        *   monitored through poll and [di]notify when the value of the
+        *   file changes.
+        *
         * - If mount is requested with sane_behavior but without any
         *   subsystem, the default unified hierarchy is mounted.
         *
@@ -282,6 +311,9 @@ enum {
 struct cgroup_root {
        struct kernfs_root *kf_root;
 
+       /* The bitmask of subsystems attached to this hierarchy */
+       unsigned int subsys_mask;
+
        /* Unique id for this hierarchy. */
        int hierarchy_id;
 
@@ -295,7 +327,7 @@ struct cgroup_root {
        struct list_head root_list;
 
        /* Hierarchy-specific flags */
-       unsigned long flags;
+       unsigned int flags;
 
        /* IDs for cgroups in this hierarchy */
        struct idr cgroup_idr;
@@ -342,6 +374,9 @@ struct css_set {
         */
        struct list_head cgrp_links;
 
+       /* the default cgroup associated with this css_set */
+       struct cgroup *dfl_cgrp;
+
        /*
         * Set of subsystem states, one for each subsystem. This array is
         * immutable after creation apart from the init_css_set during
@@ -366,6 +401,15 @@ struct css_set {
        struct cgroup *mg_src_cgrp;
        struct css_set *mg_dst_cset;
 
+       /*
+        * On the default hierarhcy, ->subsys[ssid] may point to a css
+        * attached to an ancestor instead of the cgroup this css_set is
+        * associated with.  The following node is anchored at
+        * ->subsys[ssid]->cgroup->e_csets[ssid] and provides a way to
+        * iterate through all css's attached to a given cgroup.
+        */
+       struct list_head e_cset_node[CGROUP_SUBSYS_COUNT];
+
        /* For RCU-protected deletion */
        struct rcu_head rcu_head;
 };
@@ -821,9 +865,14 @@ css_next_descendant_post(struct cgroup_subsys_state *pos,
 
 /* A css_task_iter should be treated as an opaque object */
 struct css_task_iter {
-       struct cgroup_subsys_state      *origin_css;
-       struct list_head                *cset_link;
-       struct list_head                *task;
+       struct cgroup_subsys            *ss;
+
+       struct list_head                *cset_pos;
+       struct list_head                *cset_head;
+
+       struct list_head                *task_pos;
+       struct list_head                *tasks_head;
+       struct list_head                *mg_tasks_head;
 };
 
 void css_task_iter_start(struct cgroup_subsys_state *css,
This page took 0.047906 seconds and 5 git commands to generate.