Merge tag 'fixes-nc-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm...
[firefly-linux-kernel-4.4.55.git] / kernel / cgroup.c
index c16719e056aba60b2a915b7ce6072fa733cf39b5..2a9926275f806f41e7c15b6eed584acaf8796bc0 100644 (file)
@@ -117,6 +117,9 @@ struct cfent {
        struct list_head                node;
        struct dentry                   *dentry;
        struct cftype                   *type;
+
+       /* file xattrs */
+       struct simple_xattrs            xattrs;
 };
 
 /*
@@ -845,9 +848,12 @@ static void cgroup_free_fn(struct work_struct *work)
         */
        dput(cgrp->parent->dentry);
 
+       ida_simple_remove(&cgrp->root->cgroup_ida, cgrp->id);
+
        /*
         * Drop the active superblock reference that we took when we
-        * created the cgroup
+        * created the cgroup. This will free cgrp->root, if we are
+        * holding the last reference to @sb.
         */
        deactivate_super(cgrp->root->sb);
 
@@ -859,7 +865,6 @@ static void cgroup_free_fn(struct work_struct *work)
 
        simple_xattrs_free(&cgrp->xattrs);
 
-       ida_simple_remove(&cgrp->root->cgroup_ida, cgrp->id);
        kfree(rcu_dereference_raw(cgrp->name));
        kfree(cgrp);
 }
@@ -882,13 +887,12 @@ static void cgroup_diput(struct dentry *dentry, struct inode *inode)
        } else {
                struct cfent *cfe = __d_cfe(dentry);
                struct cgroup *cgrp = dentry->d_parent->d_fsdata;
-               struct cftype *cft = cfe->type;
 
                WARN_ONCE(!list_empty(&cfe->node) &&
                          cgrp != &cgrp->root->top_cgroup,
                          "cfe still linked for %s\n", cfe->type->name);
+               simple_xattrs_free(&cfe->xattrs);
                kfree(cfe);
-               simple_xattrs_free(&cft->xattrs);
        }
        iput(inode);
 }
@@ -2133,11 +2137,11 @@ retry_find_task:
                tsk = tsk->group_leader;
 
        /*
-        * Workqueue threads may acquire PF_THREAD_BOUND and become
+        * Workqueue threads may acquire PF_NO_SETAFFINITY and become
         * trapped in a cpuset, or RT worker may be born in a cgroup
         * with no rt_runtime allocated.  Just say no.
         */
-       if (tsk == kthreadd_task || (tsk->flags & PF_THREAD_BOUND)) {
+       if (tsk == kthreadd_task || (tsk->flags & PF_NO_SETAFFINITY)) {
                ret = -EINVAL;
                rcu_read_unlock();
                goto out_unlock_cgroup;
@@ -2501,7 +2505,7 @@ static struct simple_xattrs *__d_xattrs(struct dentry *dentry)
        if (S_ISDIR(dentry->d_inode->i_mode))
                return &__d_cgrp(dentry)->xattrs;
        else
-               return &__d_cft(dentry)->xattrs;
+               return &__d_cfe(dentry)->xattrs;
 }
 
 static inline int xattr_enabled(struct dentry *dentry)
@@ -2677,8 +2681,6 @@ static int cgroup_add_file(struct cgroup *cgrp, struct cgroup_subsys *subsys,
        umode_t mode;
        char name[MAX_CGROUP_TYPE_NAMELEN + MAX_CFTYPE_NAME + 2] = { 0 };
 
-       simple_xattrs_init(&cft->xattrs);
-
        if (subsys && !(cgrp->root->flags & CGRP_ROOT_NOPREFIX)) {
                strcpy(name, subsys->name);
                strcat(name, ".");
@@ -2703,6 +2705,7 @@ static int cgroup_add_file(struct cgroup *cgrp, struct cgroup_subsys *subsys,
                cfe->type = (void *)cft;
                cfe->dentry = dentry;
                dentry->d_fsdata = cfe;
+               simple_xattrs_init(&cfe->xattrs);
                list_add_tail(&cfe->node, &parent->files);
                cfe = NULL;
        }
@@ -3879,6 +3882,8 @@ static int cgroup_write_event_control(struct cgroup *cgrp, struct cftype *cft,
        if (ret)
                goto fail;
 
+       efile->f_op->poll(efile, &event->pt);
+
        /*
         * Events should be removed after rmdir of cgroup directory, but before
         * destroying subsystem state objects. Let's take reference to cgroup
@@ -4375,7 +4380,6 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss)
         * need to invoke fork callbacks here. */
        BUG_ON(!list_empty(&init_task.tasks));
 
-       ss->active = 1;
        BUG_ON(online_css(ss, dummytop));
 
        mutex_unlock(&cgroup_mutex);
@@ -4480,7 +4484,6 @@ int __init_or_module cgroup_load_subsys(struct cgroup_subsys *ss)
        }
        write_unlock(&css_set_lock);
 
-       ss->active = 1;
        ret = online_css(ss, dummytop);
        if (ret)
                goto err_unload;
@@ -4521,7 +4524,6 @@ void cgroup_unload_subsys(struct cgroup_subsys *ss)
        mutex_lock(&cgroup_mutex);
 
        offline_css(ss, dummytop);
-       ss->active = 0;
 
        if (ss->use_id)
                idr_destroy(&ss->idr);
@@ -4676,7 +4678,7 @@ out:
  */
 
 /* TODO: Use a proper seq_file iterator */
-static int proc_cgroup_show(struct seq_file *m, void *v)
+int proc_cgroup_show(struct seq_file *m, void *v)
 {
        struct pid *pid;
        struct task_struct *tsk;
@@ -4728,19 +4730,6 @@ out:
        return retval;
 }
 
-static int cgroup_open(struct inode *inode, struct file *file)
-{
-       struct pid *pid = PROC_I(inode)->pid;
-       return single_open(file, proc_cgroup_show, pid);
-}
-
-const struct file_operations proc_cgroup_operations = {
-       .open           = cgroup_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
-
 /* Display information about each subsystem and each hierarchy */
 static int proc_cgroupstats_show(struct seq_file *m, void *v)
 {
@@ -5285,55 +5274,6 @@ struct cgroup_subsys_state *css_lookup(struct cgroup_subsys *ss, int id)
 }
 EXPORT_SYMBOL_GPL(css_lookup);
 
-/**
- * css_get_next - lookup next cgroup under specified hierarchy.
- * @ss: pointer to subsystem
- * @id: current position of iteration.
- * @root: pointer to css. search tree under this.
- * @foundid: position of found object.
- *
- * Search next css under the specified hierarchy of rootid. Calling under
- * rcu_read_lock() is necessary. Returns NULL if it reaches the end.
- */
-struct cgroup_subsys_state *
-css_get_next(struct cgroup_subsys *ss, int id,
-            struct cgroup_subsys_state *root, int *foundid)
-{
-       struct cgroup_subsys_state *ret = NULL;
-       struct css_id *tmp;
-       int tmpid;
-       int rootid = css_id(root);
-       int depth = css_depth(root);
-
-       if (!rootid)
-               return NULL;
-
-       BUG_ON(!ss->use_id);
-       WARN_ON_ONCE(!rcu_read_lock_held());
-
-       /* fill start point for scan */
-       tmpid = id;
-       while (1) {
-               /*
-                * scan next entry from bitmap(tree), tmpid is updated after
-                * idr_get_next().
-                */
-               tmp = idr_get_next(&ss->idr, &tmpid);
-               if (!tmp)
-                       break;
-               if (tmp->depth >= depth && tmp->stack[depth] == rootid) {
-                       ret = rcu_dereference(tmp->css);
-                       if (ret) {
-                               *foundid = tmpid;
-                               break;
-                       }
-               }
-               /* continue to scan from next id */
-               tmpid = tmpid + 1;
-       }
-       return ret;
-}
-
 /*
  * get corresponding css from file open on cgroupfs directory
  */