diff options
author | KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> | 2008-02-07 03:14:27 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-07 11:42:20 -0500 |
commit | 4fca88c87b7969c698912e2de9b1b31088c777cb (patch) | |
tree | 6a086aaffb4ec17eadd2f2427c5816a02be6606f /kernel/cgroup.c | |
parent | d2ceb9b7ddedbb2e8e590bc6ce33c854043016f9 (diff) |
memory cgroup enhancements: add- pre_destroy() handler
Add a handler "pre_destroy" to cgroup_subsys. It is called before
cgroup_rmdir() checks all subsys's refcnt.
I think this is useful for subsys which have some extra refs even if there
are no tasks in cgroup. By adding pre_destroy(), the kernel keeps the rule
"destroy() against subsystem is called only when refcnt=0." and allows css
ref to be used by other objects than tasks.
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Balbir Singh <balbir@linux.vnet.ibm.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Herbert Poetzl <herbert@13thfloor.at>
Cc: Kirill Korotaev <dev@sw.ru>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: Paul Menage <menage@google.com>
Cc: Pavel Emelianov <xemul@openvz.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r-- | kernel/cgroup.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 4d67a39c58a8..4e8b16a8266c 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -586,6 +586,21 @@ static struct inode *cgroup_new_inode(mode_t mode, struct super_block *sb) | |||
586 | return inode; | 586 | return inode; |
587 | } | 587 | } |
588 | 588 | ||
589 | /* | ||
590 | * Call subsys's pre_destroy handler. | ||
591 | * This is called before css refcnt check. | ||
592 | */ | ||
593 | |||
594 | static void cgroup_call_pre_destroy(struct cgroup *cgrp) | ||
595 | { | ||
596 | struct cgroup_subsys *ss; | ||
597 | for_each_subsys(cgrp->root, ss) | ||
598 | if (ss->pre_destroy && cgrp->subsys[ss->subsys_id]) | ||
599 | ss->pre_destroy(ss, cgrp); | ||
600 | return; | ||
601 | } | ||
602 | |||
603 | |||
589 | static void cgroup_diput(struct dentry *dentry, struct inode *inode) | 604 | static void cgroup_diput(struct dentry *dentry, struct inode *inode) |
590 | { | 605 | { |
591 | /* is dentry a directory ? if so, kfree() associated cgroup */ | 606 | /* is dentry a directory ? if so, kfree() associated cgroup */ |
@@ -2160,6 +2175,13 @@ static int cgroup_rmdir(struct inode *unused_dir, struct dentry *dentry) | |||
2160 | parent = cgrp->parent; | 2175 | parent = cgrp->parent; |
2161 | root = cgrp->root; | 2176 | root = cgrp->root; |
2162 | sb = root->sb; | 2177 | sb = root->sb; |
2178 | /* | ||
2179 | * Call pre_destroy handlers of subsys | ||
2180 | */ | ||
2181 | cgroup_call_pre_destroy(cgrp); | ||
2182 | /* | ||
2183 | * Notify subsyses that rmdir() request comes. | ||
2184 | */ | ||
2163 | 2185 | ||
2164 | if (cgroup_has_css_refs(cgrp)) { | 2186 | if (cgroup_has_css_refs(cgrp)) { |
2165 | mutex_unlock(&cgroup_mutex); | 2187 | mutex_unlock(&cgroup_mutex); |