Skip to content

Commit

Permalink
cgroup: make CSS_* flags bit masks instead of bit positions
Browse files Browse the repository at this point in the history
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: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizefan@huawei.com>
  • Loading branch information
Tejun Heo committed Nov 19, 2012
1 parent febfcef commit 38b53ab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions include/linux/cgroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct cgroup_subsys_state {

/* bits in struct cgroup_subsys_state flags field */
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 */
Expand All @@ -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)
{
/* 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);
}

Expand All @@ -113,7 +113,7 @@ static inline void css_get(struct cgroup_subsys_state *css)
extern 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 __css_tryget(css);
}
Expand All @@ -126,7 +126,7 @@ static inline bool css_tryget(struct cgroup_subsys_state *css)
extern 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);
}

Expand Down
2 changes: 1 addition & 1 deletion kernel/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -4020,7 +4020,7 @@ static void init_cgroup_css(struct cgroup_subsys_state *css,
css->flags = 0;
css->id = NULL;
if (cgrp == dummytop)
set_bit(CSS_ROOT, &css->flags);
css->flags |= CSS_ROOT;
BUG_ON(cgrp->subsys[ss->subsys_id]);
cgrp->subsys[ss->subsys_id] = css;

Expand Down

0 comments on commit 38b53ab

Please sign in to comment.