Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1662962 > unrolled thread
| Started by | Tejun Heo <tj@kernel.org> |
|---|---|
| First post | 2017-06-10 16:10 +0200 |
| Last post | 2017-06-10 16:10 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 01/10] cgroup: separate out cgroup_has_tasks() Tejun Heo <tj@kernel.org> - 2017-06-10 16:10 +0200
| From | Tejun Heo <tj@kernel.org> |
|---|---|
| Date | 2017-06-10 16:10 +0200 |
| Subject | [PATCH 01/10] cgroup: separate out cgroup_has_tasks() |
| Message-ID | <tQPfs-84G-15@gated-at.bofh.it> |
Separate out cgroup_has_tasks() test from
cgroup_subtree_control_write(). This will be used by the following
changes.
This patch doesn't cause any behavior changes.
Signed-off-by: Tejun Heo <tj@kernel.org>
---
kernel/cgroup/cgroup.c | 49 +++++++++++++++++++++++++++----------------------
1 file changed, 27 insertions(+), 22 deletions(-)
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 8d4e85eae42c..dcd120af4084 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -581,6 +581,30 @@ static bool css_set_populated(struct css_set *cset)
return !list_empty(&cset->tasks) || !list_empty(&cset->mg_tasks);
}
+static bool cgroup_has_tasks(struct cgroup *cgrp)
+{
+ struct cgrp_cset_link *link;
+ bool has_tasks = false;
+
+ /*
+ * 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);
+
+ list_for_each_entry(link, &cgrp->cset_links, cset_link) {
+ if (css_set_populated(link->cset)) {
+ has_tasks = true;
+ break;
+ }
+ }
+
+ spin_unlock_irq(&css_set_lock);
+
+ return has_tasks;
+}
+
/**
* cgroup_update_populated - updated populated count of a cgroup
* @cgrp: the target cgroup
@@ -2886,28 +2910,9 @@ static ssize_t cgroup_subtree_control_write(struct kernfs_open_file *of,
* 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)) {
- 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;
+ if (enable && cgroup_parent(cgrp) && cgroup_has_tasks(cgrp)) {
+ ret = -EBUSY;
+ goto out_unlock;
}
/* save and update control masks and prepare csses */
--
2.13.0
Back to top | Article view | linux.kernel
csiph-web