提交 5de0107e 编写于 作者: T Tejun Heo

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: NTejun Heo <tj@kernel.org>
Acked-by: NLi Zefan <lizefan@huawei.com>
上级 f4f4be2b
...@@ -94,33 +94,31 @@ enum { ...@@ -94,33 +94,31 @@ enum {
CSS_ONLINE = (1 << 1), /* between ->css_online() and ->css_offline() */ CSS_ONLINE = (1 << 1), /* between ->css_online() and ->css_offline() */
}; };
/* Caller must verify that the css is not for root cgroup */ /**
static inline void __css_get(struct cgroup_subsys_state *css, int count) * css_get - obtain a reference on the specified css
{ * @css: target css
atomic_add(count, &css->refcnt); *
} * The caller must already have a reference.
/*
* Call css_get() to hold a reference on the css; it can be used
* for a reference obtained via:
* - an existing ref-counted reference to the css
* - task->cgroups for a locked task
*/ */
static inline void css_get(struct cgroup_subsys_state *css) static inline void css_get(struct cgroup_subsys_state *css)
{ {
/* We don't need to reference count the root state */ /* We don't need to reference count the root state */
if (!(css->flags & CSS_ROOT)) if (!(css->flags & CSS_ROOT))
__css_get(css, 1); atomic_inc(&css->refcnt);
} }
/*
* Call css_tryget() to take a reference on a css if your existing
* (known-valid) reference isn't already ref-counted. Returns false if
* the css has been destroyed.
*/
extern bool __css_tryget(struct cgroup_subsys_state *css); extern bool __css_tryget(struct cgroup_subsys_state *css);
/**
* css_tryget - try to obtain a reference on the specified css
* @css: target css
*
* Obtain a reference on @css if it's alive. The caller naturally needs to
* ensure that @css is accessible but doesn't have to be holding a
* reference on it - IOW, RCU protected access is good enough for this
* function. Returns %true if a reference count was successfully obtained;
* %false otherwise.
*/
static inline bool css_tryget(struct cgroup_subsys_state *css) static inline bool css_tryget(struct cgroup_subsys_state *css)
{ {
if (css->flags & CSS_ROOT) if (css->flags & CSS_ROOT)
...@@ -128,12 +126,14 @@ static inline bool css_tryget(struct cgroup_subsys_state *css) ...@@ -128,12 +126,14 @@ static inline bool css_tryget(struct cgroup_subsys_state *css)
return __css_tryget(css); return __css_tryget(css);
} }
/*
* css_put() should be called to release a reference taken by
* css_get() or css_tryget()
*/
extern void __css_put(struct cgroup_subsys_state *css); extern void __css_put(struct cgroup_subsys_state *css);
/**
* css_put - put a css reference
* @css: target css
*
* Put a reference obtained via css_get() and css_tryget().
*/
static inline void css_put(struct cgroup_subsys_state *css) static inline void css_put(struct cgroup_subsys_state *css)
{ {
if (!(css->flags & CSS_ROOT)) if (!(css->flags & CSS_ROOT))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册