diff options
author | Tejun Heo <tj@kernel.org> | 2014-05-14 09:15:02 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-05-14 09:15:02 -0400 |
commit | 9395a4500404e05173eda9a2d198b6fa500e90c5 (patch) | |
tree | db5e953a6b3e1d074e64c3e36e3b7c90fc564770 /include/linux/cgroup.h | |
parent | 25e15d835036a70a53dcc993beaa036f8919a373 (diff) |
cgroup: enable refcnting for root csses
Currently, css_get(), css_tryget() and css_tryget_online() are noops
for root csses as an optimization; however, we're planning to use css
refcnts to track of cgroup lifetime too and root cgroups also need to
be reference counted. Since css has been converted to percpu_refcnt,
the overhead of refcnting is miniscule and this optimization isn't too
meaningful anymore. Furthermore, controllers which optimize the root
cgroup often never even invoke these functions in their hot paths.
This patch enables refcnting for root csses too. This makes CSS_ROOT
flag unused and removes it.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizefan@huawei.com>
Diffstat (limited to 'include/linux/cgroup.h')
-rw-r--r-- | include/linux/cgroup.h | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 160fcc69149e..286e39e4e9bf 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h | |||
@@ -77,7 +77,6 @@ struct cgroup_subsys_state { | |||
77 | 77 | ||
78 | /* bits in struct cgroup_subsys_state flags field */ | 78 | /* bits in struct cgroup_subsys_state flags field */ |
79 | enum { | 79 | enum { |
80 | CSS_ROOT = (1 << 0), /* this CSS is the root of the subsystem */ | ||
81 | CSS_ONLINE = (1 << 1), /* between ->css_online() and ->css_offline() */ | 80 | CSS_ONLINE = (1 << 1), /* between ->css_online() and ->css_offline() */ |
82 | }; | 81 | }; |
83 | 82 | ||
@@ -89,9 +88,7 @@ enum { | |||
89 | */ | 88 | */ |
90 | static inline void css_get(struct cgroup_subsys_state *css) | 89 | static inline void css_get(struct cgroup_subsys_state *css) |
91 | { | 90 | { |
92 | /* We don't need to reference count the root state */ | 91 | percpu_ref_get(&css->refcnt); |
93 | if (!(css->flags & CSS_ROOT)) | ||
94 | percpu_ref_get(&css->refcnt); | ||
95 | } | 92 | } |
96 | 93 | ||
97 | /** | 94 | /** |
@@ -106,8 +103,6 @@ static inline void css_get(struct cgroup_subsys_state *css) | |||
106 | */ | 103 | */ |
107 | static inline bool css_tryget_online(struct cgroup_subsys_state *css) | 104 | static inline bool css_tryget_online(struct cgroup_subsys_state *css) |
108 | { | 105 | { |
109 | if (css->flags & CSS_ROOT) | ||
110 | return true; | ||
111 | return percpu_ref_tryget_live(&css->refcnt); | 106 | return percpu_ref_tryget_live(&css->refcnt); |
112 | } | 107 | } |
113 | 108 | ||
@@ -119,8 +114,7 @@ static inline bool css_tryget_online(struct cgroup_subsys_state *css) | |||
119 | */ | 114 | */ |
120 | static inline void css_put(struct cgroup_subsys_state *css) | 115 | static inline void css_put(struct cgroup_subsys_state *css) |
121 | { | 116 | { |
122 | if (!(css->flags & CSS_ROOT)) | 117 | percpu_ref_put(&css->refcnt); |
123 | percpu_ref_put(&css->refcnt); | ||
124 | } | 118 | } |
125 | 119 | ||
126 | /* bits in struct cgroup flags field */ | 120 | /* bits in struct cgroup flags field */ |