提交 38b53aba 编写于 作者: T Tejun Heo

cgroup: make CSS_* flags bit masks instead of bit positions

Currently, CSS_* flags are defined as bit positions and manipulated
using atomic bitops.  There's no reason to use atomic bitops for them
and bit positions are clunkier to deal with than bit masks.  Make
CSS_* bit masks instead and use the usual C bitwise operators to
access them.
Signed-off-by: NTejun Heo <tj@kernel.org>
Acked-by: NLi Zefan <lizefan@huawei.com>
上级 febfcef6
...@@ -81,7 +81,7 @@ struct cgroup_subsys_state { ...@@ -81,7 +81,7 @@ struct cgroup_subsys_state {
/* bits in struct cgroup_subsys_state flags field */ /* bits in struct cgroup_subsys_state flags field */
enum { enum {
CSS_ROOT, /* This CSS is the root of the subsystem */ CSS_ROOT = (1 << 0), /* this CSS is the root of the subsystem */
}; };
/* Caller must verify that the css is not for root cgroup */ /* Caller must verify that the css is not for root cgroup */
...@@ -100,7 +100,7 @@ static inline void __css_get(struct cgroup_subsys_state *css, int count) ...@@ -100,7 +100,7 @@ static inline void __css_get(struct cgroup_subsys_state *css, int count)
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 (!test_bit(CSS_ROOT, &css->flags)) if (!(css->flags & CSS_ROOT))
__css_get(css, 1); __css_get(css, 1);
} }
...@@ -113,7 +113,7 @@ static inline void css_get(struct cgroup_subsys_state *css) ...@@ -113,7 +113,7 @@ static inline void css_get(struct cgroup_subsys_state *css)
extern bool __css_tryget(struct cgroup_subsys_state *css); extern bool __css_tryget(struct cgroup_subsys_state *css);
static inline bool css_tryget(struct cgroup_subsys_state *css) static inline bool css_tryget(struct cgroup_subsys_state *css)
{ {
if (test_bit(CSS_ROOT, &css->flags)) if (css->flags & CSS_ROOT)
return true; return true;
return __css_tryget(css); return __css_tryget(css);
} }
...@@ -126,7 +126,7 @@ static inline bool css_tryget(struct cgroup_subsys_state *css) ...@@ -126,7 +126,7 @@ static inline bool css_tryget(struct cgroup_subsys_state *css)
extern void __css_put(struct cgroup_subsys_state *css); extern void __css_put(struct cgroup_subsys_state *css);
static inline void css_put(struct cgroup_subsys_state *css) static inline void css_put(struct cgroup_subsys_state *css)
{ {
if (!test_bit(CSS_ROOT, &css->flags)) if (!(css->flags & CSS_ROOT))
__css_put(css); __css_put(css);
} }
......
...@@ -4020,7 +4020,7 @@ static void init_cgroup_css(struct cgroup_subsys_state *css, ...@@ -4020,7 +4020,7 @@ static void init_cgroup_css(struct cgroup_subsys_state *css,
css->flags = 0; css->flags = 0;
css->id = NULL; css->id = NULL;
if (cgrp == dummytop) if (cgrp == dummytop)
set_bit(CSS_ROOT, &css->flags); css->flags |= CSS_ROOT;
BUG_ON(cgrp->subsys[ss->subsys_id]); BUG_ON(cgrp->subsys[ss->subsys_id]);
cgrp->subsys[ss->subsys_id] = css; cgrp->subsys[ss->subsys_id] = css;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册