diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-10 07:24:40 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-10 07:24:40 -0400 |
commit | b211e9d7c861bdb37b86d6384da9edfb80949ceb (patch) | |
tree | dfb209ffce92a2b203a9fd2ddbc23eed5daddacf /kernel/cgroup.c | |
parent | d9428f09763d307a6d2220c4bbb01d8fc5c55b52 (diff) | |
parent | e756c7b698604f11a979f2781d06eb7b80aba363 (diff) |
Merge branch 'for-3.18' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
Pull cgroup updates from Tejun Heo:
"Nothing too interesting. Just a handful of cleanup patches"
* 'for-3.18' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup:
Revert "cgroup: remove redundant variable in cgroup_mount()"
cgroup: remove redundant variable in cgroup_mount()
cgroup: fix missing unlock in cgroup_release_agent()
cgroup: remove CGRP_RELEASABLE flag
perf/cgroup: Remove perf_put_cgroup()
cgroup: remove redundant check in cgroup_ino()
cpuset: simplify proc_cpuset_show()
cgroup: simplify proc_cgroup_show()
cgroup: use a per-cgroup work for release agent
cgroup: remove bogus comments
cgroup: remove redundant code in cgroup_rmdir()
cgroup: remove some useless forward declarations
cgroup: fix a typo in comment.
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r-- | kernel/cgroup.c | 184 |
1 files changed, 53 insertions, 131 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 3a73f995a81e..cab7dc4284dc 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -185,7 +185,6 @@ static int need_forkexit_callback __read_mostly; | |||
185 | static struct cftype cgroup_dfl_base_files[]; | 185 | static struct cftype cgroup_dfl_base_files[]; |
186 | static struct cftype cgroup_legacy_base_files[]; | 186 | static struct cftype cgroup_legacy_base_files[]; |
187 | 187 | ||
188 | static void cgroup_put(struct cgroup *cgrp); | ||
189 | static int rebind_subsystems(struct cgroup_root *dst_root, | 188 | static int rebind_subsystems(struct cgroup_root *dst_root, |
190 | unsigned int ss_mask); | 189 | unsigned int ss_mask); |
191 | static int cgroup_destroy_locked(struct cgroup *cgrp); | 190 | static int cgroup_destroy_locked(struct cgroup *cgrp); |
@@ -195,7 +194,6 @@ static void css_release(struct percpu_ref *ref); | |||
195 | static void kill_css(struct cgroup_subsys_state *css); | 194 | static void kill_css(struct cgroup_subsys_state *css); |
196 | static int cgroup_addrm_files(struct cgroup *cgrp, struct cftype cfts[], | 195 | static int cgroup_addrm_files(struct cgroup *cgrp, struct cftype cfts[], |
197 | bool is_add); | 196 | bool is_add); |
198 | static void cgroup_pidlist_destroy_all(struct cgroup *cgrp); | ||
199 | 197 | ||
200 | /* IDR wrappers which synchronize using cgroup_idr_lock */ | 198 | /* IDR wrappers which synchronize using cgroup_idr_lock */ |
201 | static int cgroup_idr_alloc(struct idr *idr, void *ptr, int start, int end, | 199 | static int cgroup_idr_alloc(struct idr *idr, void *ptr, int start, int end, |
@@ -331,14 +329,6 @@ bool cgroup_is_descendant(struct cgroup *cgrp, struct cgroup *ancestor) | |||
331 | return false; | 329 | return false; |
332 | } | 330 | } |
333 | 331 | ||
334 | static int cgroup_is_releasable(const struct cgroup *cgrp) | ||
335 | { | ||
336 | const int bits = | ||
337 | (1 << CGRP_RELEASABLE) | | ||
338 | (1 << CGRP_NOTIFY_ON_RELEASE); | ||
339 | return (cgrp->flags & bits) == bits; | ||
340 | } | ||
341 | |||
342 | static int notify_on_release(const struct cgroup *cgrp) | 332 | static int notify_on_release(const struct cgroup *cgrp) |
343 | { | 333 | { |
344 | return test_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags); | 334 | return test_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags); |
@@ -394,12 +384,7 @@ static int notify_on_release(const struct cgroup *cgrp) | |||
394 | ; \ | 384 | ; \ |
395 | else | 385 | else |
396 | 386 | ||
397 | /* the list of cgroups eligible for automatic release. Protected by | ||
398 | * release_list_lock */ | ||
399 | static LIST_HEAD(release_list); | ||
400 | static DEFINE_RAW_SPINLOCK(release_list_lock); | ||
401 | static void cgroup_release_agent(struct work_struct *work); | 387 | static void cgroup_release_agent(struct work_struct *work); |
402 | static DECLARE_WORK(release_agent_work, cgroup_release_agent); | ||
403 | static void check_for_release(struct cgroup *cgrp); | 388 | static void check_for_release(struct cgroup *cgrp); |
404 | 389 | ||
405 | /* | 390 | /* |
@@ -498,7 +483,7 @@ static unsigned long css_set_hash(struct cgroup_subsys_state *css[]) | |||
498 | return key; | 483 | return key; |
499 | } | 484 | } |
500 | 485 | ||
501 | static void put_css_set_locked(struct css_set *cset, bool taskexit) | 486 | static void put_css_set_locked(struct css_set *cset) |
502 | { | 487 | { |
503 | struct cgrp_cset_link *link, *tmp_link; | 488 | struct cgrp_cset_link *link, *tmp_link; |
504 | struct cgroup_subsys *ss; | 489 | struct cgroup_subsys *ss; |
@@ -524,11 +509,7 @@ static void put_css_set_locked(struct css_set *cset, bool taskexit) | |||
524 | /* @cgrp can't go away while we're holding css_set_rwsem */ | 509 | /* @cgrp can't go away while we're holding css_set_rwsem */ |
525 | if (list_empty(&cgrp->cset_links)) { | 510 | if (list_empty(&cgrp->cset_links)) { |
526 | cgroup_update_populated(cgrp, false); | 511 | cgroup_update_populated(cgrp, false); |
527 | if (notify_on_release(cgrp)) { | 512 | check_for_release(cgrp); |
528 | if (taskexit) | ||
529 | set_bit(CGRP_RELEASABLE, &cgrp->flags); | ||
530 | check_for_release(cgrp); | ||
531 | } | ||
532 | } | 513 | } |
533 | 514 | ||
534 | kfree(link); | 515 | kfree(link); |
@@ -537,7 +518,7 @@ static void put_css_set_locked(struct css_set *cset, bool taskexit) | |||
537 | kfree_rcu(cset, rcu_head); | 518 | kfree_rcu(cset, rcu_head); |
538 | } | 519 | } |
539 | 520 | ||
540 | static void put_css_set(struct css_set *cset, bool taskexit) | 521 | static void put_css_set(struct css_set *cset) |
541 | { | 522 | { |
542 | /* | 523 | /* |
543 | * Ensure that the refcount doesn't hit zero while any readers | 524 | * Ensure that the refcount doesn't hit zero while any readers |
@@ -548,7 +529,7 @@ static void put_css_set(struct css_set *cset, bool taskexit) | |||
548 | return; | 529 | return; |
549 | 530 | ||
550 | down_write(&css_set_rwsem); | 531 | down_write(&css_set_rwsem); |
551 | put_css_set_locked(cset, taskexit); | 532 | put_css_set_locked(cset); |
552 | up_write(&css_set_rwsem); | 533 | up_write(&css_set_rwsem); |
553 | } | 534 | } |
554 | 535 | ||
@@ -969,14 +950,6 @@ static struct cgroup *task_cgroup_from_root(struct task_struct *task, | |||
969 | * knows that the cgroup won't be removed, as cgroup_rmdir() | 950 | * knows that the cgroup won't be removed, as cgroup_rmdir() |
970 | * needs that mutex. | 951 | * needs that mutex. |
971 | * | 952 | * |
972 | * The fork and exit callbacks cgroup_fork() and cgroup_exit(), don't | ||
973 | * (usually) take cgroup_mutex. These are the two most performance | ||
974 | * critical pieces of code here. The exception occurs on cgroup_exit(), | ||
975 | * when a task in a notify_on_release cgroup exits. Then cgroup_mutex | ||
976 | * is taken, and if the cgroup count is zero, a usermode call made | ||
977 | * to the release agent with the name of the cgroup (path relative to | ||
978 | * the root of cgroup file system) as the argument. | ||
979 | * | ||
980 | * A cgroup can only be deleted if both its 'count' of using tasks | 953 | * A cgroup can only be deleted if both its 'count' of using tasks |
981 | * is zero, and its list of 'children' cgroups is empty. Since all | 954 | * is zero, and its list of 'children' cgroups is empty. Since all |
982 | * tasks in the system use _some_ cgroup, and since there is always at | 955 | * tasks in the system use _some_ cgroup, and since there is always at |
@@ -1587,7 +1560,6 @@ static void init_cgroup_housekeeping(struct cgroup *cgrp) | |||
1587 | INIT_LIST_HEAD(&cgrp->self.sibling); | 1560 | INIT_LIST_HEAD(&cgrp->self.sibling); |
1588 | INIT_LIST_HEAD(&cgrp->self.children); | 1561 | INIT_LIST_HEAD(&cgrp->self.children); |
1589 | INIT_LIST_HEAD(&cgrp->cset_links); | 1562 | INIT_LIST_HEAD(&cgrp->cset_links); |
1590 | INIT_LIST_HEAD(&cgrp->release_list); | ||
1591 | INIT_LIST_HEAD(&cgrp->pidlists); | 1563 | INIT_LIST_HEAD(&cgrp->pidlists); |
1592 | mutex_init(&cgrp->pidlist_mutex); | 1564 | mutex_init(&cgrp->pidlist_mutex); |
1593 | cgrp->self.cgroup = cgrp; | 1565 | cgrp->self.cgroup = cgrp; |
@@ -1597,6 +1569,7 @@ static void init_cgroup_housekeeping(struct cgroup *cgrp) | |||
1597 | INIT_LIST_HEAD(&cgrp->e_csets[ssid]); | 1569 | INIT_LIST_HEAD(&cgrp->e_csets[ssid]); |
1598 | 1570 | ||
1599 | init_waitqueue_head(&cgrp->offline_waitq); | 1571 | init_waitqueue_head(&cgrp->offline_waitq); |
1572 | INIT_WORK(&cgrp->release_agent_work, cgroup_release_agent); | ||
1600 | } | 1573 | } |
1601 | 1574 | ||
1602 | static void init_cgroup_root(struct cgroup_root *root, | 1575 | static void init_cgroup_root(struct cgroup_root *root, |
@@ -2052,8 +2025,7 @@ static void cgroup_task_migrate(struct cgroup *old_cgrp, | |||
2052 | * task. As trading it for new_cset is protected by cgroup_mutex, | 2025 | * task. As trading it for new_cset is protected by cgroup_mutex, |
2053 | * we're safe to drop it here; it will be freed under RCU. | 2026 | * we're safe to drop it here; it will be freed under RCU. |
2054 | */ | 2027 | */ |
2055 | set_bit(CGRP_RELEASABLE, &old_cgrp->flags); | 2028 | put_css_set_locked(old_cset); |
2056 | put_css_set_locked(old_cset, false); | ||
2057 | } | 2029 | } |
2058 | 2030 | ||
2059 | /** | 2031 | /** |
@@ -2074,7 +2046,7 @@ static void cgroup_migrate_finish(struct list_head *preloaded_csets) | |||
2074 | cset->mg_src_cgrp = NULL; | 2046 | cset->mg_src_cgrp = NULL; |
2075 | cset->mg_dst_cset = NULL; | 2047 | cset->mg_dst_cset = NULL; |
2076 | list_del_init(&cset->mg_preload_node); | 2048 | list_del_init(&cset->mg_preload_node); |
2077 | put_css_set_locked(cset, false); | 2049 | put_css_set_locked(cset); |
2078 | } | 2050 | } |
2079 | up_write(&css_set_rwsem); | 2051 | up_write(&css_set_rwsem); |
2080 | } | 2052 | } |
@@ -2168,8 +2140,8 @@ static int cgroup_migrate_prepare_dst(struct cgroup *dst_cgrp, | |||
2168 | if (src_cset == dst_cset) { | 2140 | if (src_cset == dst_cset) { |
2169 | src_cset->mg_src_cgrp = NULL; | 2141 | src_cset->mg_src_cgrp = NULL; |
2170 | list_del_init(&src_cset->mg_preload_node); | 2142 | list_del_init(&src_cset->mg_preload_node); |
2171 | put_css_set(src_cset, false); | 2143 | put_css_set(src_cset); |
2172 | put_css_set(dst_cset, false); | 2144 | put_css_set(dst_cset); |
2173 | continue; | 2145 | continue; |
2174 | } | 2146 | } |
2175 | 2147 | ||
@@ -2178,7 +2150,7 @@ static int cgroup_migrate_prepare_dst(struct cgroup *dst_cgrp, | |||
2178 | if (list_empty(&dst_cset->mg_preload_node)) | 2150 | if (list_empty(&dst_cset->mg_preload_node)) |
2179 | list_add(&dst_cset->mg_preload_node, &csets); | 2151 | list_add(&dst_cset->mg_preload_node, &csets); |
2180 | else | 2152 | else |
2181 | put_css_set(dst_cset, false); | 2153 | put_css_set(dst_cset); |
2182 | } | 2154 | } |
2183 | 2155 | ||
2184 | list_splice_tail(&csets, preloaded_csets); | 2156 | list_splice_tail(&csets, preloaded_csets); |
@@ -4173,7 +4145,6 @@ static u64 cgroup_read_notify_on_release(struct cgroup_subsys_state *css, | |||
4173 | static int cgroup_write_notify_on_release(struct cgroup_subsys_state *css, | 4145 | static int cgroup_write_notify_on_release(struct cgroup_subsys_state *css, |
4174 | struct cftype *cft, u64 val) | 4146 | struct cftype *cft, u64 val) |
4175 | { | 4147 | { |
4176 | clear_bit(CGRP_RELEASABLE, &css->cgroup->flags); | ||
4177 | if (val) | 4148 | if (val) |
4178 | set_bit(CGRP_NOTIFY_ON_RELEASE, &css->cgroup->flags); | 4149 | set_bit(CGRP_NOTIFY_ON_RELEASE, &css->cgroup->flags); |
4179 | else | 4150 | else |
@@ -4351,6 +4322,7 @@ static void css_free_work_fn(struct work_struct *work) | |||
4351 | /* cgroup free path */ | 4322 | /* cgroup free path */ |
4352 | atomic_dec(&cgrp->root->nr_cgrps); | 4323 | atomic_dec(&cgrp->root->nr_cgrps); |
4353 | cgroup_pidlist_destroy_all(cgrp); | 4324 | cgroup_pidlist_destroy_all(cgrp); |
4325 | cancel_work_sync(&cgrp->release_agent_work); | ||
4354 | 4326 | ||
4355 | if (cgroup_parent(cgrp)) { | 4327 | if (cgroup_parent(cgrp)) { |
4356 | /* | 4328 | /* |
@@ -4813,19 +4785,12 @@ static int cgroup_destroy_locked(struct cgroup *cgrp) | |||
4813 | for_each_css(css, ssid, cgrp) | 4785 | for_each_css(css, ssid, cgrp) |
4814 | kill_css(css); | 4786 | kill_css(css); |
4815 | 4787 | ||
4816 | /* CSS_ONLINE is clear, remove from ->release_list for the last time */ | ||
4817 | raw_spin_lock(&release_list_lock); | ||
4818 | if (!list_empty(&cgrp->release_list)) | ||
4819 | list_del_init(&cgrp->release_list); | ||
4820 | raw_spin_unlock(&release_list_lock); | ||
4821 | |||
4822 | /* | 4788 | /* |
4823 | * Remove @cgrp directory along with the base files. @cgrp has an | 4789 | * Remove @cgrp directory along with the base files. @cgrp has an |
4824 | * extra ref on its kn. | 4790 | * extra ref on its kn. |
4825 | */ | 4791 | */ |
4826 | kernfs_remove(cgrp->kn); | 4792 | kernfs_remove(cgrp->kn); |
4827 | 4793 | ||
4828 | set_bit(CGRP_RELEASABLE, &cgroup_parent(cgrp)->flags); | ||
4829 | check_for_release(cgroup_parent(cgrp)); | 4794 | check_for_release(cgroup_parent(cgrp)); |
4830 | 4795 | ||
4831 | /* put the base reference */ | 4796 | /* put the base reference */ |
@@ -4842,13 +4807,10 @@ static int cgroup_rmdir(struct kernfs_node *kn) | |||
4842 | cgrp = cgroup_kn_lock_live(kn); | 4807 | cgrp = cgroup_kn_lock_live(kn); |
4843 | if (!cgrp) | 4808 | if (!cgrp) |
4844 | return 0; | 4809 | return 0; |
4845 | cgroup_get(cgrp); /* for @kn->priv clearing */ | ||
4846 | 4810 | ||
4847 | ret = cgroup_destroy_locked(cgrp); | 4811 | ret = cgroup_destroy_locked(cgrp); |
4848 | 4812 | ||
4849 | cgroup_kn_unlock(kn); | 4813 | cgroup_kn_unlock(kn); |
4850 | |||
4851 | cgroup_put(cgrp); | ||
4852 | return ret; | 4814 | return ret; |
4853 | } | 4815 | } |
4854 | 4816 | ||
@@ -5052,12 +5014,9 @@ core_initcall(cgroup_wq_init); | |||
5052 | * - Print task's cgroup paths into seq_file, one line for each hierarchy | 5014 | * - Print task's cgroup paths into seq_file, one line for each hierarchy |
5053 | * - Used for /proc/<pid>/cgroup. | 5015 | * - Used for /proc/<pid>/cgroup. |
5054 | */ | 5016 | */ |
5055 | 5017 | int proc_cgroup_show(struct seq_file *m, struct pid_namespace *ns, | |
5056 | /* TODO: Use a proper seq_file iterator */ | 5018 | struct pid *pid, struct task_struct *tsk) |
5057 | int proc_cgroup_show(struct seq_file *m, void *v) | ||
5058 | { | 5019 | { |
5059 | struct pid *pid; | ||
5060 | struct task_struct *tsk; | ||
5061 | char *buf, *path; | 5020 | char *buf, *path; |
5062 | int retval; | 5021 | int retval; |
5063 | struct cgroup_root *root; | 5022 | struct cgroup_root *root; |
@@ -5067,14 +5026,6 @@ int proc_cgroup_show(struct seq_file *m, void *v) | |||
5067 | if (!buf) | 5026 | if (!buf) |
5068 | goto out; | 5027 | goto out; |
5069 | 5028 | ||
5070 | retval = -ESRCH; | ||
5071 | pid = m->private; | ||
5072 | tsk = get_pid_task(pid, PIDTYPE_PID); | ||
5073 | if (!tsk) | ||
5074 | goto out_free; | ||
5075 | |||
5076 | retval = 0; | ||
5077 | |||
5078 | mutex_lock(&cgroup_mutex); | 5029 | mutex_lock(&cgroup_mutex); |
5079 | down_read(&css_set_rwsem); | 5030 | down_read(&css_set_rwsem); |
5080 | 5031 | ||
@@ -5104,11 +5055,10 @@ int proc_cgroup_show(struct seq_file *m, void *v) | |||
5104 | seq_putc(m, '\n'); | 5055 | seq_putc(m, '\n'); |
5105 | } | 5056 | } |
5106 | 5057 | ||
5058 | retval = 0; | ||
5107 | out_unlock: | 5059 | out_unlock: |
5108 | up_read(&css_set_rwsem); | 5060 | up_read(&css_set_rwsem); |
5109 | mutex_unlock(&cgroup_mutex); | 5061 | mutex_unlock(&cgroup_mutex); |
5110 | put_task_struct(tsk); | ||
5111 | out_free: | ||
5112 | kfree(buf); | 5062 | kfree(buf); |
5113 | out: | 5063 | out: |
5114 | return retval; | 5064 | return retval; |
@@ -5179,7 +5129,7 @@ void cgroup_post_fork(struct task_struct *child) | |||
5179 | int i; | 5129 | int i; |
5180 | 5130 | ||
5181 | /* | 5131 | /* |
5182 | * This may race against cgroup_enable_task_cg_links(). As that | 5132 | * This may race against cgroup_enable_task_cg_lists(). As that |
5183 | * function sets use_task_css_set_links before grabbing | 5133 | * function sets use_task_css_set_links before grabbing |
5184 | * tasklist_lock and we just went through tasklist_lock to add | 5134 | * tasklist_lock and we just went through tasklist_lock to add |
5185 | * @child, it's guaranteed that either we see the set | 5135 | * @child, it's guaranteed that either we see the set |
@@ -5194,7 +5144,7 @@ void cgroup_post_fork(struct task_struct *child) | |||
5194 | * when implementing operations which need to migrate all tasks of | 5144 | * when implementing operations which need to migrate all tasks of |
5195 | * a cgroup to another. | 5145 | * a cgroup to another. |
5196 | * | 5146 | * |
5197 | * Note that if we lose to cgroup_enable_task_cg_links(), @child | 5147 | * Note that if we lose to cgroup_enable_task_cg_lists(), @child |
5198 | * will remain in init_css_set. This is safe because all tasks are | 5148 | * will remain in init_css_set. This is safe because all tasks are |
5199 | * in the init_css_set before cg_links is enabled and there's no | 5149 | * in the init_css_set before cg_links is enabled and there's no |
5200 | * operation which transfers all tasks out of init_css_set. | 5150 | * operation which transfers all tasks out of init_css_set. |
@@ -5278,30 +5228,14 @@ void cgroup_exit(struct task_struct *tsk) | |||
5278 | } | 5228 | } |
5279 | 5229 | ||
5280 | if (put_cset) | 5230 | if (put_cset) |
5281 | put_css_set(cset, true); | 5231 | put_css_set(cset); |
5282 | } | 5232 | } |
5283 | 5233 | ||
5284 | static void check_for_release(struct cgroup *cgrp) | 5234 | static void check_for_release(struct cgroup *cgrp) |
5285 | { | 5235 | { |
5286 | if (cgroup_is_releasable(cgrp) && list_empty(&cgrp->cset_links) && | 5236 | if (notify_on_release(cgrp) && !cgroup_has_tasks(cgrp) && |
5287 | !css_has_online_children(&cgrp->self)) { | 5237 | !css_has_online_children(&cgrp->self) && !cgroup_is_dead(cgrp)) |
5288 | /* | 5238 | schedule_work(&cgrp->release_agent_work); |
5289 | * Control Group is currently removeable. If it's not | ||
5290 | * already queued for a userspace notification, queue | ||
5291 | * it now | ||
5292 | */ | ||
5293 | int need_schedule_work = 0; | ||
5294 | |||
5295 | raw_spin_lock(&release_list_lock); | ||
5296 | if (!cgroup_is_dead(cgrp) && | ||
5297 | list_empty(&cgrp->release_list)) { | ||
5298 | list_add(&cgrp->release_list, &release_list); | ||
5299 | need_schedule_work = 1; | ||
5300 | } | ||
5301 | raw_spin_unlock(&release_list_lock); | ||
5302 | if (need_schedule_work) | ||
5303 | schedule_work(&release_agent_work); | ||
5304 | } | ||
5305 | } | 5239 | } |
5306 | 5240 | ||
5307 | /* | 5241 | /* |
@@ -5329,52 +5263,39 @@ static void check_for_release(struct cgroup *cgrp) | |||
5329 | */ | 5263 | */ |
5330 | static void cgroup_release_agent(struct work_struct *work) | 5264 | static void cgroup_release_agent(struct work_struct *work) |
5331 | { | 5265 | { |
5332 | BUG_ON(work != &release_agent_work); | 5266 | struct cgroup *cgrp = |
5267 | container_of(work, struct cgroup, release_agent_work); | ||
5268 | char *pathbuf = NULL, *agentbuf = NULL, *path; | ||
5269 | char *argv[3], *envp[3]; | ||
5270 | |||
5333 | mutex_lock(&cgroup_mutex); | 5271 | mutex_lock(&cgroup_mutex); |
5334 | raw_spin_lock(&release_list_lock); | 5272 | |
5335 | while (!list_empty(&release_list)) { | 5273 | pathbuf = kmalloc(PATH_MAX, GFP_KERNEL); |
5336 | char *argv[3], *envp[3]; | 5274 | agentbuf = kstrdup(cgrp->root->release_agent_path, GFP_KERNEL); |
5337 | int i; | 5275 | if (!pathbuf || !agentbuf) |
5338 | char *pathbuf = NULL, *agentbuf = NULL, *path; | 5276 | goto out; |
5339 | struct cgroup *cgrp = list_entry(release_list.next, | 5277 | |
5340 | struct cgroup, | 5278 | path = cgroup_path(cgrp, pathbuf, PATH_MAX); |
5341 | release_list); | 5279 | if (!path) |
5342 | list_del_init(&cgrp->release_list); | 5280 | goto out; |
5343 | raw_spin_unlock(&release_list_lock); | 5281 | |
5344 | pathbuf = kmalloc(PATH_MAX, GFP_KERNEL); | 5282 | argv[0] = agentbuf; |
5345 | if (!pathbuf) | 5283 | argv[1] = path; |
5346 | goto continue_free; | 5284 | argv[2] = NULL; |
5347 | path = cgroup_path(cgrp, pathbuf, PATH_MAX); | 5285 | |
5348 | if (!path) | 5286 | /* minimal command environment */ |
5349 | goto continue_free; | 5287 | envp[0] = "HOME=/"; |
5350 | agentbuf = kstrdup(cgrp->root->release_agent_path, GFP_KERNEL); | 5288 | envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; |
5351 | if (!agentbuf) | 5289 | envp[2] = NULL; |
5352 | goto continue_free; | 5290 | |
5353 | 5291 | mutex_unlock(&cgroup_mutex); | |
5354 | i = 0; | 5292 | call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC); |
5355 | argv[i++] = agentbuf; | 5293 | goto out_free; |
5356 | argv[i++] = path; | 5294 | out: |
5357 | argv[i] = NULL; | ||
5358 | |||
5359 | i = 0; | ||
5360 | /* minimal command environment */ | ||
5361 | envp[i++] = "HOME=/"; | ||
5362 | envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; | ||
5363 | envp[i] = NULL; | ||
5364 | |||
5365 | /* Drop the lock while we invoke the usermode helper, | ||
5366 | * since the exec could involve hitting disk and hence | ||
5367 | * be a slow process */ | ||
5368 | mutex_unlock(&cgroup_mutex); | ||
5369 | call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC); | ||
5370 | mutex_lock(&cgroup_mutex); | ||
5371 | continue_free: | ||
5372 | kfree(pathbuf); | ||
5373 | kfree(agentbuf); | ||
5374 | raw_spin_lock(&release_list_lock); | ||
5375 | } | ||
5376 | raw_spin_unlock(&release_list_lock); | ||
5377 | mutex_unlock(&cgroup_mutex); | 5295 | mutex_unlock(&cgroup_mutex); |
5296 | out_free: | ||
5297 | kfree(agentbuf); | ||
5298 | kfree(pathbuf); | ||
5378 | } | 5299 | } |
5379 | 5300 | ||
5380 | static int __init cgroup_disable(char *str) | 5301 | static int __init cgroup_disable(char *str) |
@@ -5562,7 +5483,8 @@ static int cgroup_css_links_read(struct seq_file *seq, void *v) | |||
5562 | 5483 | ||
5563 | static u64 releasable_read(struct cgroup_subsys_state *css, struct cftype *cft) | 5484 | static u64 releasable_read(struct cgroup_subsys_state *css, struct cftype *cft) |
5564 | { | 5485 | { |
5565 | return test_bit(CGRP_RELEASABLE, &css->cgroup->flags); | 5486 | return (!cgroup_has_tasks(css->cgroup) && |
5487 | !css_has_online_children(&css->cgroup->self)); | ||
5566 | } | 5488 | } |
5567 | 5489 | ||
5568 | static struct cftype debug_files[] = { | 5490 | static struct cftype debug_files[] = { |