From 6447937cae423990096fb38a002931339c34b6ca Mon Sep 17 00:00:00 2001 From: Daisuke Nishimura Date: Wed, 10 Mar 2010 15:22:05 -0800 Subject: [PATCH] --- yaml --- r: 187205 b: refs/heads/master c: d7b9fff711d5e8db8c844161c684017e556c38a0 h: refs/heads/master i: 187203: 3a6da556cfa8d230575f830f096cfc18b2d351ee v: v3 --- [refs] | 2 +- trunk/include/linux/cgroup.h | 12 +++++++++--- trunk/kernel/cgroup.c | 5 +++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/[refs] b/[refs] index 5aa226a24031..9f5b76f0295c 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 2468c7234b366eeb799ee0648cb58f9cba394a54 +refs/heads/master: d7b9fff711d5e8db8c844161c684017e556c38a0 diff --git a/trunk/include/linux/cgroup.h b/trunk/include/linux/cgroup.h index d08cfe7e12e5..14160b5b693f 100644 --- a/trunk/include/linux/cgroup.h +++ b/trunk/include/linux/cgroup.h @@ -76,6 +76,12 @@ enum { CSS_REMOVED, /* This CSS is dead */ }; +/* Caller must verify that the css is not for root cgroup */ +static inline void __css_get(struct cgroup_subsys_state *css, int count) +{ + atomic_add(count, &css->refcnt); +} + /* * Call css_get() to hold a reference on the css; it can be used * for a reference obtained via: @@ -87,7 +93,7 @@ static inline void css_get(struct cgroup_subsys_state *css) { /* We don't need to reference count the root state */ if (!test_bit(CSS_ROOT, &css->flags)) - atomic_inc(&css->refcnt); + __css_get(css, 1); } static inline bool css_is_removed(struct cgroup_subsys_state *css) @@ -118,11 +124,11 @@ static inline bool css_tryget(struct cgroup_subsys_state *css) * css_get() or css_tryget() */ -extern void __css_put(struct cgroup_subsys_state *css); +extern void __css_put(struct cgroup_subsys_state *css, int count); static inline void css_put(struct cgroup_subsys_state *css) { if (!test_bit(CSS_ROOT, &css->flags)) - __css_put(css); + __css_put(css, 1); } /* bits in struct cgroup flags field */ diff --git a/trunk/kernel/cgroup.c b/trunk/kernel/cgroup.c index be45d2f6008a..cace83ddbcdc 100644 --- a/trunk/kernel/cgroup.c +++ b/trunk/kernel/cgroup.c @@ -3746,12 +3746,13 @@ static void check_for_release(struct cgroup *cgrp) } } -void __css_put(struct cgroup_subsys_state *css) +/* Caller must verify that the css is not for root cgroup */ +void __css_put(struct cgroup_subsys_state *css, int count) { struct cgroup *cgrp = css->cgroup; int val; rcu_read_lock(); - val = atomic_dec_return(&css->refcnt); + val = atomic_sub_return(count, &css->refcnt); if (val == 1) { if (notify_on_release(cgrp)) { set_bit(CGRP_RELEASABLE, &cgrp->flags);