diff options
author | Tejun Heo <tj@kernel.org> | 2012-11-09 12:12:29 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2012-11-09 12:12:29 -0500 |
commit | bcd66c894ac994ef5d6fbbaa9a24506ffaf64fd4 (patch) | |
tree | 5310a91996bfead85115d4b028deaad52a3b242c | |
parent | 574bd9f7c7c1d32f52dea5488018a6ff79031e22 (diff) |
cgroup_freezer: trivial cleanups
* Clean-up indentation and line-breaks. Drop the invalid comment
about freezer->lock.
* Make all internal functions take @freezer instead of both @cgroup
and @freezer.
Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Reviewed-by: Michal Hocko <mhocko@suse.cz>
-rw-r--r-- | kernel/cgroup_freezer.c | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c index bedefd9a22df..975b3d8732f4 100644 --- a/kernel/cgroup_freezer.c +++ b/kernel/cgroup_freezer.c | |||
@@ -29,17 +29,15 @@ enum freezer_state { | |||
29 | }; | 29 | }; |
30 | 30 | ||
31 | struct freezer { | 31 | struct freezer { |
32 | struct cgroup_subsys_state css; | 32 | struct cgroup_subsys_state css; |
33 | enum freezer_state state; | 33 | enum freezer_state state; |
34 | spinlock_t lock; /* protects _writes_ to state */ | 34 | spinlock_t lock; |
35 | }; | 35 | }; |
36 | 36 | ||
37 | static inline struct freezer *cgroup_freezer( | 37 | static inline struct freezer *cgroup_freezer(struct cgroup *cgroup) |
38 | struct cgroup *cgroup) | ||
39 | { | 38 | { |
40 | return container_of( | 39 | return container_of(cgroup_subsys_state(cgroup, freezer_subsys_id), |
41 | cgroup_subsys_state(cgroup, freezer_subsys_id), | 40 | struct freezer, css); |
42 | struct freezer, css); | ||
43 | } | 41 | } |
44 | 42 | ||
45 | static inline struct freezer *task_freezer(struct task_struct *task) | 43 | static inline struct freezer *task_freezer(struct task_struct *task) |
@@ -180,8 +178,9 @@ out: | |||
180 | * migrated into or out of @cgroup, so we can't verify task states against | 178 | * migrated into or out of @cgroup, so we can't verify task states against |
181 | * @freezer state here. See freezer_attach() for details. | 179 | * @freezer state here. See freezer_attach() for details. |
182 | */ | 180 | */ |
183 | static void update_if_frozen(struct cgroup *cgroup, struct freezer *freezer) | 181 | static void update_if_frozen(struct freezer *freezer) |
184 | { | 182 | { |
183 | struct cgroup *cgroup = freezer->css.cgroup; | ||
185 | struct cgroup_iter it; | 184 | struct cgroup_iter it; |
186 | struct task_struct *task; | 185 | struct task_struct *task; |
187 | 186 | ||
@@ -211,12 +210,11 @@ notyet: | |||
211 | static int freezer_read(struct cgroup *cgroup, struct cftype *cft, | 210 | static int freezer_read(struct cgroup *cgroup, struct cftype *cft, |
212 | struct seq_file *m) | 211 | struct seq_file *m) |
213 | { | 212 | { |
214 | struct freezer *freezer; | 213 | struct freezer *freezer = cgroup_freezer(cgroup); |
215 | enum freezer_state state; | 214 | enum freezer_state state; |
216 | 215 | ||
217 | freezer = cgroup_freezer(cgroup); | ||
218 | spin_lock_irq(&freezer->lock); | 216 | spin_lock_irq(&freezer->lock); |
219 | update_if_frozen(cgroup, freezer); | 217 | update_if_frozen(freezer); |
220 | state = freezer->state; | 218 | state = freezer->state; |
221 | spin_unlock_irq(&freezer->lock); | 219 | spin_unlock_irq(&freezer->lock); |
222 | 220 | ||
@@ -225,8 +223,9 @@ static int freezer_read(struct cgroup *cgroup, struct cftype *cft, | |||
225 | return 0; | 223 | return 0; |
226 | } | 224 | } |
227 | 225 | ||
228 | static void freeze_cgroup(struct cgroup *cgroup, struct freezer *freezer) | 226 | static void freeze_cgroup(struct freezer *freezer) |
229 | { | 227 | { |
228 | struct cgroup *cgroup = freezer->css.cgroup; | ||
230 | struct cgroup_iter it; | 229 | struct cgroup_iter it; |
231 | struct task_struct *task; | 230 | struct task_struct *task; |
232 | 231 | ||
@@ -236,8 +235,9 @@ static void freeze_cgroup(struct cgroup *cgroup, struct freezer *freezer) | |||
236 | cgroup_iter_end(cgroup, &it); | 235 | cgroup_iter_end(cgroup, &it); |
237 | } | 236 | } |
238 | 237 | ||
239 | static void unfreeze_cgroup(struct cgroup *cgroup, struct freezer *freezer) | 238 | static void unfreeze_cgroup(struct freezer *freezer) |
240 | { | 239 | { |
240 | struct cgroup *cgroup = freezer->css.cgroup; | ||
241 | struct cgroup_iter it; | 241 | struct cgroup_iter it; |
242 | struct task_struct *task; | 242 | struct task_struct *task; |
243 | 243 | ||
@@ -247,11 +247,9 @@ static void unfreeze_cgroup(struct cgroup *cgroup, struct freezer *freezer) | |||
247 | cgroup_iter_end(cgroup, &it); | 247 | cgroup_iter_end(cgroup, &it); |
248 | } | 248 | } |
249 | 249 | ||
250 | static void freezer_change_state(struct cgroup *cgroup, | 250 | static void freezer_change_state(struct freezer *freezer, |
251 | enum freezer_state goal_state) | 251 | enum freezer_state goal_state) |
252 | { | 252 | { |
253 | struct freezer *freezer = cgroup_freezer(cgroup); | ||
254 | |||
255 | /* also synchronizes against task migration, see freezer_attach() */ | 253 | /* also synchronizes against task migration, see freezer_attach() */ |
256 | spin_lock_irq(&freezer->lock); | 254 | spin_lock_irq(&freezer->lock); |
257 | 255 | ||
@@ -260,13 +258,13 @@ static void freezer_change_state(struct cgroup *cgroup, | |||
260 | if (freezer->state != CGROUP_THAWED) | 258 | if (freezer->state != CGROUP_THAWED) |
261 | atomic_dec(&system_freezing_cnt); | 259 | atomic_dec(&system_freezing_cnt); |
262 | freezer->state = CGROUP_THAWED; | 260 | freezer->state = CGROUP_THAWED; |
263 | unfreeze_cgroup(cgroup, freezer); | 261 | unfreeze_cgroup(freezer); |
264 | break; | 262 | break; |
265 | case CGROUP_FROZEN: | 263 | case CGROUP_FROZEN: |
266 | if (freezer->state == CGROUP_THAWED) | 264 | if (freezer->state == CGROUP_THAWED) |
267 | atomic_inc(&system_freezing_cnt); | 265 | atomic_inc(&system_freezing_cnt); |
268 | freezer->state = CGROUP_FREEZING; | 266 | freezer->state = CGROUP_FREEZING; |
269 | freeze_cgroup(cgroup, freezer); | 267 | freeze_cgroup(freezer); |
270 | break; | 268 | break; |
271 | default: | 269 | default: |
272 | BUG(); | 270 | BUG(); |
@@ -275,8 +273,7 @@ static void freezer_change_state(struct cgroup *cgroup, | |||
275 | spin_unlock_irq(&freezer->lock); | 273 | spin_unlock_irq(&freezer->lock); |
276 | } | 274 | } |
277 | 275 | ||
278 | static int freezer_write(struct cgroup *cgroup, | 276 | static int freezer_write(struct cgroup *cgroup, struct cftype *cft, |
279 | struct cftype *cft, | ||
280 | const char *buffer) | 277 | const char *buffer) |
281 | { | 278 | { |
282 | enum freezer_state goal_state; | 279 | enum freezer_state goal_state; |
@@ -288,7 +285,7 @@ static int freezer_write(struct cgroup *cgroup, | |||
288 | else | 285 | else |
289 | return -EINVAL; | 286 | return -EINVAL; |
290 | 287 | ||
291 | freezer_change_state(cgroup, goal_state); | 288 | freezer_change_state(cgroup_freezer(cgroup), goal_state); |
292 | return 0; | 289 | return 0; |
293 | } | 290 | } |
294 | 291 | ||