aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
authorDaisuke Nishimura <nishimura@mxp.nes.nec.co.jp>2010-03-10 18:22:05 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2010-03-12 18:52:36 -0500
commitd7b9fff711d5e8db8c844161c684017e556c38a0 (patch)
treefea09ff79fe543edc2d8c0e85d35de1b2c783f2d /kernel/cgroup.c
parent2468c7234b366eeb799ee0648cb58f9cba394a54 (diff)
cgroup: introduce coalesce css_get() and css_put()
Current css_get() and css_put() increment/decrement css->refcnt one by one. This patch add a new function __css_get(), which takes "count" as a arg and increment the css->refcnt by "count". And this patch also add a new arg("count") to __css_put() and change the function to decrement the css->refcnt by "count". These coalesce version of __css_get()/__css_put() will be used to improve performance of memcg's moving charge feature later, where instead of calling css_get()/css_put() repeatedly, these new functions will be used. No change is needed for current users of css_get()/css_put(). Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> Acked-by: Paul Menage <menage@google.com> Cc: Balbir Singh <balbir@linux.vnet.ibm.com> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Li Zefan <lizf@cn.fujitsu.com> Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> 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.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index be45d2f6008a..cace83ddbcdc 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -3746,12 +3746,13 @@ static void check_for_release(struct cgroup *cgrp)
3746 } 3746 }
3747} 3747}
3748 3748
3749void __css_put(struct cgroup_subsys_state *css) 3749/* Caller must verify that the css is not for root cgroup */
3750void __css_put(struct cgroup_subsys_state *css, int count)
3750{ 3751{
3751 struct cgroup *cgrp = css->cgroup; 3752 struct cgroup *cgrp = css->cgroup;
3752 int val; 3753 int val;
3753 rcu_read_lock(); 3754 rcu_read_lock();
3754 val = atomic_dec_return(&css->refcnt); 3755 val = atomic_sub_return(count, &css->refcnt);
3755 if (val == 1) { 3756 if (val == 1) {
3756 if (notify_on_release(cgrp)) { 3757 if (notify_on_release(cgrp)) {
3757 set_bit(CGRP_RELEASABLE, &cgrp->flags); 3758 set_bit(CGRP_RELEASABLE, &cgrp->flags);