aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-06-13 00:04:52 -0400
committerTejun Heo <tj@kernel.org>2013-06-13 13:55:17 -0400
commit5de0107e634ce862f16360139709d9d3a656463e (patch)
tree07e964c35fae8a82fa86275d1c46517403096f06
parentf4f4be2bd2889c69a8698edef8dbfd4f6759aa87 (diff)
cgroup: clean up css_[try]get() and css_put()
* __css_get() isn't used by anyone. Fold it into css_get(). * Add proper function comments to all css reference functions. This patch is purely cosmetic. v2: Typo fix as per Li. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com>
-rw-r--r--include/linux/cgroup.h48
1 files changed, 24 insertions, 24 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 0e32855edc92..a494636a34da 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -94,33 +94,31 @@ enum {
94 CSS_ONLINE = (1 << 1), /* between ->css_online() and ->css_offline() */ 94 CSS_ONLINE = (1 << 1), /* between ->css_online() and ->css_offline() */
95}; 95};
96 96
97/* Caller must verify that the css is not for root cgroup */ 97/**
98static inline void __css_get(struct cgroup_subsys_state *css, int count) 98 * css_get - obtain a reference on the specified css
99{ 99 * @css: target css
100 atomic_add(count, &css->refcnt); 100 *
101} 101 * The caller must already have a reference.
102
103/*
104 * Call css_get() to hold a reference on the css; it can be used
105 * for a reference obtained via:
106 * - an existing ref-counted reference to the css
107 * - task->cgroups for a locked task
108 */ 102 */
109
110static inline void css_get(struct cgroup_subsys_state *css) 103static inline void css_get(struct cgroup_subsys_state *css)
111{ 104{
112 /* We don't need to reference count the root state */ 105 /* We don't need to reference count the root state */
113 if (!(css->flags & CSS_ROOT)) 106 if (!(css->flags & CSS_ROOT))
114 __css_get(css, 1); 107 atomic_inc(&css->refcnt);
115} 108}
116 109
117/*
118 * Call css_tryget() to take a reference on a css if your existing
119 * (known-valid) reference isn't already ref-counted. Returns false if
120 * the css has been destroyed.
121 */
122
123extern bool __css_tryget(struct cgroup_subsys_state *css); 110extern bool __css_tryget(struct cgroup_subsys_state *css);
111
112/**
113 * css_tryget - try to obtain a reference on the specified css
114 * @css: target css
115 *
116 * Obtain a reference on @css if it's alive. The caller naturally needs to
117 * ensure that @css is accessible but doesn't have to be holding a
118 * reference on it - IOW, RCU protected access is good enough for this
119 * function. Returns %true if a reference count was successfully obtained;
120 * %false otherwise.
121 */
124static inline bool css_tryget(struct cgroup_subsys_state *css) 122static inline bool css_tryget(struct cgroup_subsys_state *css)
125{ 123{
126 if (css->flags & CSS_ROOT) 124 if (css->flags & CSS_ROOT)
@@ -128,12 +126,14 @@ static inline bool css_tryget(struct cgroup_subsys_state *css)
128 return __css_tryget(css); 126 return __css_tryget(css);
129} 127}
130 128
131/*
132 * css_put() should be called to release a reference taken by
133 * css_get() or css_tryget()
134 */
135
136extern void __css_put(struct cgroup_subsys_state *css); 129extern void __css_put(struct cgroup_subsys_state *css);
130
131/**
132 * css_put - put a css reference
133 * @css: target css
134 *
135 * Put a reference obtained via css_get() and css_tryget().
136 */
137static inline void css_put(struct cgroup_subsys_state *css) 137static inline void css_put(struct cgroup_subsys_state *css)
138{ 138{
139 if (!(css->flags & CSS_ROOT)) 139 if (!(css->flags & CSS_ROOT))