Merge branch 'for-4.8-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 27 Sep 2016 23:43:11 +0000 (16:43 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 27 Sep 2016 23:43:11 +0000 (16:43 -0700)
Pull cgroup fixes from Tejun Heo:
 "Three late fixes for cgroup: Two cpuset ones, one trivial and the
  other pretty obscure, and a cgroup core fix for a bug which impacts
  cgroup v2 namespace users"

* 'for-4.8-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup:
  cgroup: fix invalid controller enable rejections with cgroup namespace
  cpuset: fix non static symbol warning
  cpuset: handle race between CPU hotplug and cpuset_hotplug_work

1  2 
kernel/cgroup.c

diff --combined kernel/cgroup.c
@@@ -3446,9 -3446,28 +3446,28 @@@ static ssize_t cgroup_subtree_control_w
         * Except for the root, subtree_control must be zero for a cgroup
         * with tasks so that child cgroups don't compete against tasks.
         */
-       if (enable && cgroup_parent(cgrp) && !list_empty(&cgrp->cset_links)) {
-               ret = -EBUSY;
-               goto out_unlock;
+       if (enable && cgroup_parent(cgrp)) {
+               struct cgrp_cset_link *link;
+               /*
+                * Because namespaces pin csets too, @cgrp->cset_links
+                * might not be empty even when @cgrp is empty.  Walk and
+                * verify each cset.
+                */
+               spin_lock_irq(&css_set_lock);
+               ret = 0;
+               list_for_each_entry(link, &cgrp->cset_links, cset_link) {
+                       if (css_set_populated(link->cset)) {
+                               ret = -EBUSY;
+                               break;
+                       }
+               }
+               spin_unlock_irq(&css_set_lock);
+               if (ret)
+                       goto out_unlock;
        }
  
        /* save and update control masks and prepare csses */
@@@ -3899,7 -3918,9 +3918,9 @@@ void cgroup_file_notify(struct cgroup_f
   * cgroup_task_count - count the number of tasks in a cgroup.
   * @cgrp: the cgroup in question
   *
-  * Return the number of tasks in the cgroup.
+  * Return the number of tasks in the cgroup.  The returned number can be
+  * higher than the actual number of tasks due to css_set references from
+  * namespace roots and temporary usages.
   */
  static int cgroup_task_count(const struct cgroup *cgrp)
  {
@@@ -6270,12 -6291,6 +6291,12 @@@ void cgroup_sk_alloc(struct sock_cgroup
        if (cgroup_sk_alloc_disabled)
                return;
  
 +      /* Socket clone path */
 +      if (skcd->val) {
 +              cgroup_get(sock_cgroup_ptr(skcd));
 +              return;
 +      }
 +
        rcu_read_lock();
  
        while (true) {