From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: "linux-mm@kvack.org" <linux-mm@kvack.org>
Cc: "lizf@cn.fujitsu.com" <lizf@cn.fujitsu.com>,
"nishimura@mxp.nes.nec.co.jp" <nishimura@mxp.nes.nec.co.jp>,
"menage@google.com" <menage@google.com>,
"balbir@linux.vnet.ibm.com" <balbir@linux.vnet.ibm.com>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>
Subject: [PATCH mmotm 1/2] cgroup: fix to stop adding a new task while rmdir going on
Date: Wed, 10 Dec 2008 13:35:08 +0900 [thread overview]
Message-ID: <20081210133508.3ee454ae.kamezawa.hiroyu@jp.fujitsu.com> (raw)
still need reviews.
==
Recently, pre_destroy() was moved to out of cgroup_lock() for avoiding
dead lock. But, by this, serialization between task attach and rmdir()
is lost.
This adds CGRP_TRY_REMOVE flag to cgroup and check it at attaching.
If attach_pid founds CGRP_TRY_REMOVE, it returns -EBUSY.
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
---
include/linux/cgroup.h | 2 ++
kernel/cgroup.c | 11 +++++++++++
2 files changed, 13 insertions(+)
Index: mmotm-2.6.28-Dec09/include/linux/cgroup.h
===================================================================
--- mmotm-2.6.28-Dec09.orig/include/linux/cgroup.h
+++ mmotm-2.6.28-Dec09/include/linux/cgroup.h
@@ -98,6 +98,8 @@ enum {
CGRP_RELEASABLE,
/* Control Group requires release notifications to userspace */
CGRP_NOTIFY_ON_RELEASE,
+ /* Control Group is in rmdir() sequence. stop adding new tasks */
+ CGRP_TRY_REMOVE,
};
struct cgroup {
Index: mmotm-2.6.28-Dec09/kernel/cgroup.c
===================================================================
--- mmotm-2.6.28-Dec09.orig/kernel/cgroup.c
+++ mmotm-2.6.28-Dec09/kernel/cgroup.c
@@ -122,6 +122,11 @@ inline int cgroup_is_removed(const struc
{
return test_bit(CGRP_REMOVED, &cgrp->flags);
}
+/* cgroup is in rmdir() sequnece */
+static inline int cgroup_is_being_removed(const struct cgroup *cgrp)
+{
+ return test_bit(CGRP_TRY_REMOVE, &cgrp->flags);
+}
/* bits in struct cgroupfs_root flags field */
enum {
@@ -1307,6 +1312,10 @@ static int cgroup_tasks_write(struct cgr
int ret;
if (!cgroup_lock_live_group(cgrp))
return -ENODEV;
+ if (cgroup_is_being_removed(cgrp)) {
+ cgroup_unlock();
+ return -EBUSY;
+ }
ret = attach_task_by_pid(cgrp, pid);
cgroup_unlock();
return ret;
@@ -2469,6 +2478,7 @@ static int cgroup_rmdir(struct inode *un
mutex_unlock(&cgroup_mutex);
return -EBUSY;
}
+ set_bit(CGRP_TRY_REMOVE, &cgrp->flags);
mutex_unlock(&cgroup_mutex);
/*
@@ -2483,6 +2493,7 @@ static int cgroup_rmdir(struct inode *un
if (atomic_read(&cgrp->count)
|| !list_empty(&cgrp->children)
|| cgroup_has_css_refs(cgrp)) {
+ clear_bit(CGRP_TRY_REMOVE, &cgrp->flags);
mutex_unlock(&cgroup_mutex);
return -EBUSY;
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2008-12-10 4:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-10 4:35 KAMEZAWA Hiroyuki [this message]
2008-12-10 4:45 ` [PATCH mmotm 2/2] cgroup: add CSS_POPULATED flag to show css is in use KAMEZAWA Hiroyuki
2008-12-10 22:48 ` [PATCH mmotm 1/2] cgroup: fix to stop adding a new task while rmdir going on Paul Menage
2008-12-11 0:26 ` KAMEZAWA Hiroyuki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081210133508.3ee454ae.kamezawa.hiroyu@jp.fujitsu.com \
--to=kamezawa.hiroyu@jp.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=linux-mm@kvack.org \
--cc=lizf@cn.fujitsu.com \
--cc=menage@google.com \
--cc=nishimura@mxp.nes.nec.co.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox