diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/cgroup.h | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index e345d8b90046..b7bd4beae294 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/workqueue.h> | 20 | #include <linux/workqueue.h> |
21 | #include <linux/xattr.h> | 21 | #include <linux/xattr.h> |
22 | #include <linux/fs.h> | 22 | #include <linux/fs.h> |
23 | #include <linux/percpu-refcount.h> | ||
23 | 24 | ||
24 | #ifdef CONFIG_CGROUPS | 25 | #ifdef CONFIG_CGROUPS |
25 | 26 | ||
@@ -72,13 +73,8 @@ struct cgroup_subsys_state { | |||
72 | */ | 73 | */ |
73 | struct cgroup *cgroup; | 74 | struct cgroup *cgroup; |
74 | 75 | ||
75 | /* | 76 | /* reference count - access via css_[try]get() and css_put() */ |
76 | * State maintained by the cgroup system to allow subsystems | 77 | struct percpu_ref refcnt; |
77 | * to be "busy". Should be accessed via css_get(), | ||
78 | * css_tryget() and css_put(). | ||
79 | */ | ||
80 | |||
81 | atomic_t refcnt; | ||
82 | 78 | ||
83 | unsigned long flags; | 79 | unsigned long flags; |
84 | /* ID for this css, if possible */ | 80 | /* ID for this css, if possible */ |
@@ -104,11 +100,9 @@ static inline void css_get(struct cgroup_subsys_state *css) | |||
104 | { | 100 | { |
105 | /* We don't need to reference count the root state */ | 101 | /* We don't need to reference count the root state */ |
106 | if (!(css->flags & CSS_ROOT)) | 102 | if (!(css->flags & CSS_ROOT)) |
107 | atomic_inc(&css->refcnt); | 103 | percpu_ref_get(&css->refcnt); |
108 | } | 104 | } |
109 | 105 | ||
110 | extern bool __css_tryget(struct cgroup_subsys_state *css); | ||
111 | |||
112 | /** | 106 | /** |
113 | * css_tryget - try to obtain a reference on the specified css | 107 | * css_tryget - try to obtain a reference on the specified css |
114 | * @css: target css | 108 | * @css: target css |
@@ -123,11 +117,9 @@ static inline bool css_tryget(struct cgroup_subsys_state *css) | |||
123 | { | 117 | { |
124 | if (css->flags & CSS_ROOT) | 118 | if (css->flags & CSS_ROOT) |
125 | return true; | 119 | return true; |
126 | return __css_tryget(css); | 120 | return percpu_ref_tryget(&css->refcnt); |
127 | } | 121 | } |
128 | 122 | ||
129 | extern void __css_put(struct cgroup_subsys_state *css); | ||
130 | |||
131 | /** | 123 | /** |
132 | * css_put - put a css reference | 124 | * css_put - put a css reference |
133 | * @css: target css | 125 | * @css: target css |
@@ -137,7 +129,7 @@ extern void __css_put(struct cgroup_subsys_state *css); | |||
137 | static inline void css_put(struct cgroup_subsys_state *css) | 129 | static inline void css_put(struct cgroup_subsys_state *css) |
138 | { | 130 | { |
139 | if (!(css->flags & CSS_ROOT)) | 131 | if (!(css->flags & CSS_ROOT)) |
140 | __css_put(css); | 132 | percpu_ref_put(&css->refcnt); |
141 | } | 133 | } |
142 | 134 | ||
143 | /* bits in struct cgroup flags field */ | 135 | /* bits in struct cgroup flags field */ |
@@ -231,9 +223,10 @@ struct cgroup { | |||
231 | struct list_head pidlists; | 223 | struct list_head pidlists; |
232 | struct mutex pidlist_mutex; | 224 | struct mutex pidlist_mutex; |
233 | 225 | ||
234 | /* For RCU-protected deletion */ | 226 | /* For css percpu_ref killing and RCU-protected deletion */ |
235 | struct rcu_head rcu_head; | 227 | struct rcu_head rcu_head; |
236 | struct work_struct destroy_work; | 228 | struct work_struct destroy_work; |
229 | atomic_t css_kill_cnt; | ||
237 | 230 | ||
238 | /* List of events which userspace want to receive */ | 231 | /* List of events which userspace want to receive */ |
239 | struct list_head event_list; | 232 | struct list_head event_list; |