cgroup avoid permanent sleep at rmdir
After commit ec64f51545
("cgroup: fix
frequent -EBUSY at rmdir"), cgroup's rmdir (especially against memcg)
doesn't return -EBUSY by temporary ref counts. That commit expects all
refs after pre_destroy() is temporary but...it wasn't. Then, rmdir can
wait permanently. This patch tries to fix that and change followings.
- set CGRP_WAIT_ON_RMDIR flag before pre_destroy().
- clear CGRP_WAIT_ON_RMDIR flag when the subsys finds racy case.
if there are sleeping ones, wakes them up.
- rmdir() sleeps only when CGRP_WAIT_ON_RMDIR flag is set.
Tested-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Reported-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Reviewed-by: Paul Menage <menage@google.com>
Acked-by: Balbir Sigh <balbir@linux.vnet.ibm.com>
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
f0d83679a8
commit
887032670d
@ -362,6 +362,23 @@ int cgroup_task_count(const struct cgroup *cgrp);
|
||||
/* Return true if cgrp is a descendant of the task's cgroup */
|
||||
int cgroup_is_descendant(const struct cgroup *cgrp, struct task_struct *task);
|
||||
|
||||
/*
|
||||
* When the subsys has to access css and may add permanent refcnt to css,
|
||||
* it should take care of racy conditions with rmdir(). Following set of
|
||||
* functions, is for stop/restart rmdir if necessary.
|
||||
* Because these will call css_get/put, "css" should be alive css.
|
||||
*
|
||||
* cgroup_exclude_rmdir();
|
||||
* ...do some jobs which may access arbitrary empty cgroup
|
||||
* cgroup_release_and_wakeup_rmdir();
|
||||
*
|
||||
* When someone removes a cgroup while cgroup_exclude_rmdir() holds it,
|
||||
* it sleeps and cgroup_release_and_wakeup_rmdir() will wake him up.
|
||||
*/
|
||||
|
||||
void cgroup_exclude_rmdir(struct cgroup_subsys_state *css);
|
||||
void cgroup_release_and_wakeup_rmdir(struct cgroup_subsys_state *css);
|
||||
|
||||
/*
|
||||
* Control Group subsystem type.
|
||||
* See Documentation/cgroups/cgroups.txt for details
|
||||
|
Reference in New Issue
Block a user