diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-09-27 19:43:11 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-09-27 19:43:11 -0400 |
commit | 8ab293e3a1376574e11f9059c09cc0db212546cb (patch) | |
tree | ab3868ca55ae136df4deb8d70f78faf14b961f90 | |
parent | 08895a8b6b06ed2323cd97a36ee40a116b3db8ed (diff) | |
parent | 9157056da8f8c4a6305f15619e269f164b63a6de (diff) |
Merge branch 'for-4.8-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
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
-rw-r--r-- | kernel/cgroup.c | 29 | ||||
-rw-r--r-- | kernel/cpuset.c | 19 |
2 files changed, 40 insertions, 8 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 5e8dab5bf9ad..d6b729beba49 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -3446,9 +3446,28 @@ static ssize_t cgroup_subtree_control_write(struct kernfs_open_file *of, | |||
3446 | * Except for the root, subtree_control must be zero for a cgroup | 3446 | * Except for the root, subtree_control must be zero for a cgroup |
3447 | * with tasks so that child cgroups don't compete against tasks. | 3447 | * with tasks so that child cgroups don't compete against tasks. |
3448 | */ | 3448 | */ |
3449 | if (enable && cgroup_parent(cgrp) && !list_empty(&cgrp->cset_links)) { | 3449 | if (enable && cgroup_parent(cgrp)) { |
3450 | ret = -EBUSY; | 3450 | struct cgrp_cset_link *link; |
3451 | goto out_unlock; | 3451 | |
3452 | /* | ||
3453 | * Because namespaces pin csets too, @cgrp->cset_links | ||
3454 | * might not be empty even when @cgrp is empty. Walk and | ||
3455 | * verify each cset. | ||
3456 | */ | ||
3457 | spin_lock_irq(&css_set_lock); | ||
3458 | |||
3459 | ret = 0; | ||
3460 | list_for_each_entry(link, &cgrp->cset_links, cset_link) { | ||
3461 | if (css_set_populated(link->cset)) { | ||
3462 | ret = -EBUSY; | ||
3463 | break; | ||
3464 | } | ||
3465 | } | ||
3466 | |||
3467 | spin_unlock_irq(&css_set_lock); | ||
3468 | |||
3469 | if (ret) | ||
3470 | goto out_unlock; | ||
3452 | } | 3471 | } |
3453 | 3472 | ||
3454 | /* save and update control masks and prepare csses */ | 3473 | /* save and update control masks and prepare csses */ |
@@ -3899,7 +3918,9 @@ void cgroup_file_notify(struct cgroup_file *cfile) | |||
3899 | * cgroup_task_count - count the number of tasks in a cgroup. | 3918 | * cgroup_task_count - count the number of tasks in a cgroup. |
3900 | * @cgrp: the cgroup in question | 3919 | * @cgrp: the cgroup in question |
3901 | * | 3920 | * |
3902 | * Return the number of tasks in the cgroup. | 3921 | * Return the number of tasks in the cgroup. The returned number can be |
3922 | * higher than the actual number of tasks due to css_set references from | ||
3923 | * namespace roots and temporary usages. | ||
3903 | */ | 3924 | */ |
3904 | static int cgroup_task_count(const struct cgroup *cgrp) | 3925 | static int cgroup_task_count(const struct cgroup *cgrp) |
3905 | { | 3926 | { |
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index c27e53326bef..2b4c20ab5bbe 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
@@ -325,8 +325,7 @@ static struct file_system_type cpuset_fs_type = { | |||
325 | /* | 325 | /* |
326 | * Return in pmask the portion of a cpusets's cpus_allowed that | 326 | * Return in pmask the portion of a cpusets's cpus_allowed that |
327 | * are online. If none are online, walk up the cpuset hierarchy | 327 | * are online. If none are online, walk up the cpuset hierarchy |
328 | * until we find one that does have some online cpus. The top | 328 | * until we find one that does have some online cpus. |
329 | * cpuset always has some cpus online. | ||
330 | * | 329 | * |
331 | * One way or another, we guarantee to return some non-empty subset | 330 | * One way or another, we guarantee to return some non-empty subset |
332 | * of cpu_online_mask. | 331 | * of cpu_online_mask. |
@@ -335,8 +334,20 @@ static struct file_system_type cpuset_fs_type = { | |||
335 | */ | 334 | */ |
336 | static void guarantee_online_cpus(struct cpuset *cs, struct cpumask *pmask) | 335 | static void guarantee_online_cpus(struct cpuset *cs, struct cpumask *pmask) |
337 | { | 336 | { |
338 | while (!cpumask_intersects(cs->effective_cpus, cpu_online_mask)) | 337 | while (!cpumask_intersects(cs->effective_cpus, cpu_online_mask)) { |
339 | cs = parent_cs(cs); | 338 | cs = parent_cs(cs); |
339 | if (unlikely(!cs)) { | ||
340 | /* | ||
341 | * The top cpuset doesn't have any online cpu as a | ||
342 | * consequence of a race between cpuset_hotplug_work | ||
343 | * and cpu hotplug notifier. But we know the top | ||
344 | * cpuset's effective_cpus is on its way to to be | ||
345 | * identical to cpu_online_mask. | ||
346 | */ | ||
347 | cpumask_copy(pmask, cpu_online_mask); | ||
348 | return; | ||
349 | } | ||
350 | } | ||
340 | cpumask_and(pmask, cs->effective_cpus, cpu_online_mask); | 351 | cpumask_and(pmask, cs->effective_cpus, cpu_online_mask); |
341 | } | 352 | } |
342 | 353 | ||
@@ -2074,7 +2085,7 @@ static void cpuset_bind(struct cgroup_subsys_state *root_css) | |||
2074 | * which could have been changed by cpuset just after it inherits the | 2085 | * which could have been changed by cpuset just after it inherits the |
2075 | * state from the parent and before it sits on the cgroup's task list. | 2086 | * state from the parent and before it sits on the cgroup's task list. |
2076 | */ | 2087 | */ |
2077 | void cpuset_fork(struct task_struct *task) | 2088 | static void cpuset_fork(struct task_struct *task) |
2078 | { | 2089 | { |
2079 | if (task_css_is_root(task, cpuset_cgrp_id)) | 2090 | if (task_css_is_root(task, cpuset_cgrp_id)) |
2080 | return; | 2091 | return; |