Merge tag 'please-pull-naveen' of git://git.kernel.org/pub/scm/linux/kernel/git/ras...
[linux-3.10.git] / kernel / cgroup_freezer.c
index 0e74805..3649fc6 100644 (file)
@@ -128,8 +128,7 @@ struct cgroup_subsys freezer_subsys;
  *    task->alloc_lock (inside __thaw_task(), prevents race with refrigerator())
  *     sighand->siglock
  */
-static struct cgroup_subsys_state *freezer_create(struct cgroup_subsys *ss,
-                                                 struct cgroup *cgroup)
+static struct cgroup_subsys_state *freezer_create(struct cgroup *cgroup)
 {
        struct freezer *freezer;
 
@@ -142,8 +141,7 @@ static struct cgroup_subsys_state *freezer_create(struct cgroup_subsys *ss,
        return &freezer->css;
 }
 
-static void freezer_destroy(struct cgroup_subsys *ss,
-                           struct cgroup *cgroup)
+static void freezer_destroy(struct cgroup *cgroup)
 {
        struct freezer *freezer = cgroup_freezer(cgroup);
 
@@ -152,13 +150,19 @@ static void freezer_destroy(struct cgroup_subsys *ss,
        kfree(freezer);
 }
 
+/* task is frozen or will freeze immediately when next it gets woken */
+static bool is_task_frozen_enough(struct task_struct *task)
+{
+       return frozen(task) ||
+               (task_is_stopped_or_traced(task) && freezing(task));
+}
+
 /*
  * The call to cgroup_lock() in the freezer.state write method prevents
  * a write to that file racing against an attach, and hence the
  * can_attach() result will remain valid until the attach completes.
  */
-static int freezer_can_attach(struct cgroup_subsys *ss,
-                             struct cgroup *new_cgroup,
+static int freezer_can_attach(struct cgroup *new_cgroup,
                              struct cgroup_taskset *tset)
 {
        struct freezer *freezer;
@@ -178,7 +182,7 @@ static int freezer_can_attach(struct cgroup_subsys *ss,
        return 0;
 }
 
-static void freezer_fork(struct cgroup_subsys *ss, struct task_struct *task)
+static void freezer_fork(struct task_struct *task)
 {
        struct freezer *freezer;
 
@@ -223,7 +227,7 @@ static void update_if_frozen(struct cgroup *cgroup,
        cgroup_iter_start(cgroup, &it);
        while ((task = cgroup_iter_next(cgroup, &it))) {
                ntotal++;
-               if (freezing(task) && frozen(task))
+               if (freezing(task) && is_task_frozen_enough(task))
                        nfrozen++;
        }
 
@@ -275,7 +279,7 @@ static int try_to_freeze_cgroup(struct cgroup *cgroup, struct freezer *freezer)
        while ((task = cgroup_iter_next(cgroup, &it))) {
                if (!freeze_task(task))
                        continue;
-               if (frozen(task))
+               if (is_task_frozen_enough(task))
                        continue;
                if (!freezing(task) && !freezer_should_skip(task))
                        num_cant_freeze_now++;
@@ -354,24 +358,19 @@ static int freezer_write(struct cgroup *cgroup,
 static struct cftype files[] = {
        {
                .name = "state",
+               .flags = CFTYPE_NOT_ON_ROOT,
                .read_seq_string = freezer_read,
                .write_string = freezer_write,
        },
+       { }     /* terminate */
 };
 
-static int freezer_populate(struct cgroup_subsys *ss, struct cgroup *cgroup)
-{
-       if (!cgroup->parent)
-               return 0;
-       return cgroup_add_files(cgroup, ss, files, ARRAY_SIZE(files));
-}
-
 struct cgroup_subsys freezer_subsys = {
        .name           = "freezer",
        .create         = freezer_create,
        .destroy        = freezer_destroy,
-       .populate       = freezer_populate,
        .subsys_id      = freezer_subsys_id,
        .can_attach     = freezer_can_attach,
        .fork           = freezer_fork,
+       .base_cftypes   = files,
 };