The function cgroupstats_build extracts cgroup from the kernfs_node's
priv pointer which is a RCU pointer. So, there is no need to grab
cgroup_mutex. Just get the reference on the cgroup before using and
remove the cgroup_mutex altogether.
Signed-off-by: Shakeel Butt <shakeelb@google.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
            kernfs_type(kn) != KERNFS_DIR)
                return -EINVAL;
 
-       mutex_lock(&cgroup_mutex);
-
        /*
         * We aren't being called from kernfs and there's no guarantee on
         * @kn->priv's validity.  For this and css_tryget_online_from_dir(),
         */
        rcu_read_lock();
        cgrp = rcu_dereference(*(void __rcu __force **)&kn->priv);
-       if (!cgrp || cgroup_is_dead(cgrp)) {
+       if (!cgrp || !cgroup_tryget(cgrp)) {
                rcu_read_unlock();
-               mutex_unlock(&cgroup_mutex);
                return -ENOENT;
        }
        rcu_read_unlock();
        }
        css_task_iter_end(&it);
 
-       mutex_unlock(&cgroup_mutex);
+       cgroup_put(cgrp);
        return 0;
 }