Commit bcd66c89 authored by Tejun Heo's avatar Tejun Heo

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: default avatarTejun Heo <tj@kernel.org>
Reviewed-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Reviewed-by: default avatarMichal Hocko <mhocko@suse.cz>
parent 574bd9f7
...@@ -31,14 +31,12 @@ enum freezer_state { ...@@ -31,14 +31,12 @@ enum freezer_state {
struct freezer { struct freezer {
struct cgroup_subsys_state css; struct cgroup_subsys_state css;
enum freezer_state state; enum freezer_state state;
spinlock_t lock; /* protects _writes_ to state */ spinlock_t lock;
}; };
static inline struct freezer *cgroup_freezer( static inline struct freezer *cgroup_freezer(struct cgroup *cgroup)
struct cgroup *cgroup)
{ {
return container_of( return container_of(cgroup_subsys_state(cgroup, freezer_subsys_id),
cgroup_subsys_state(cgroup, freezer_subsys_id),
struct freezer, css); struct freezer, css);
} }
...@@ -180,8 +178,9 @@ static void freezer_fork(struct task_struct *task) ...@@ -180,8 +178,9 @@ static void freezer_fork(struct task_struct *task)
* migrated into or out of @cgroup, so we can't verify task states against * migrated into or out of @cgroup, so we can't verify task states against
* @freezer state here. See freezer_attach() for details. * @freezer state here. See freezer_attach() for details.
*/ */
static void update_if_frozen(struct cgroup *cgroup, struct freezer *freezer) static void update_if_frozen(struct freezer *freezer)
{ {
struct cgroup *cgroup = freezer->css.cgroup;
struct cgroup_iter it; struct cgroup_iter it;
struct task_struct *task; struct task_struct *task;
...@@ -211,12 +210,11 @@ static void update_if_frozen(struct cgroup *cgroup, struct freezer *freezer) ...@@ -211,12 +210,11 @@ static void update_if_frozen(struct cgroup *cgroup, struct freezer *freezer)
static int freezer_read(struct cgroup *cgroup, struct cftype *cft, static int freezer_read(struct cgroup *cgroup, struct cftype *cft,
struct seq_file *m) struct seq_file *m)
{ {
struct freezer *freezer; struct freezer *freezer = cgroup_freezer(cgroup);
enum freezer_state state; enum freezer_state state;
freezer = cgroup_freezer(cgroup);
spin_lock_irq(&freezer->lock); spin_lock_irq(&freezer->lock);
update_if_frozen(cgroup, freezer); update_if_frozen(freezer);
state = freezer->state; state = freezer->state;
spin_unlock_irq(&freezer->lock); spin_unlock_irq(&freezer->lock);
...@@ -225,8 +223,9 @@ static int freezer_read(struct cgroup *cgroup, struct cftype *cft, ...@@ -225,8 +223,9 @@ static int freezer_read(struct cgroup *cgroup, struct cftype *cft,
return 0; return 0;
} }
static void freeze_cgroup(struct cgroup *cgroup, struct freezer *freezer) static void freeze_cgroup(struct freezer *freezer)
{ {
struct cgroup *cgroup = freezer->css.cgroup;
struct cgroup_iter it; struct cgroup_iter it;
struct task_struct *task; struct task_struct *task;
...@@ -236,8 +235,9 @@ static void freeze_cgroup(struct cgroup *cgroup, struct freezer *freezer) ...@@ -236,8 +235,9 @@ static void freeze_cgroup(struct cgroup *cgroup, struct freezer *freezer)
cgroup_iter_end(cgroup, &it); cgroup_iter_end(cgroup, &it);
} }
static void unfreeze_cgroup(struct cgroup *cgroup, struct freezer *freezer) static void unfreeze_cgroup(struct freezer *freezer)
{ {
struct cgroup *cgroup = freezer->css.cgroup;
struct cgroup_iter it; struct cgroup_iter it;
struct task_struct *task; struct task_struct *task;
...@@ -247,11 +247,9 @@ static void unfreeze_cgroup(struct cgroup *cgroup, struct freezer *freezer) ...@@ -247,11 +247,9 @@ static void unfreeze_cgroup(struct cgroup *cgroup, struct freezer *freezer)
cgroup_iter_end(cgroup, &it); cgroup_iter_end(cgroup, &it);
} }
static void freezer_change_state(struct cgroup *cgroup, static void freezer_change_state(struct freezer *freezer,
enum freezer_state goal_state) enum freezer_state goal_state)
{ {
struct freezer *freezer = cgroup_freezer(cgroup);
/* also synchronizes against task migration, see freezer_attach() */ /* also synchronizes against task migration, see freezer_attach() */
spin_lock_irq(&freezer->lock); spin_lock_irq(&freezer->lock);
...@@ -260,13 +258,13 @@ static void freezer_change_state(struct cgroup *cgroup, ...@@ -260,13 +258,13 @@ static void freezer_change_state(struct cgroup *cgroup,
if (freezer->state != CGROUP_THAWED) if (freezer->state != CGROUP_THAWED)
atomic_dec(&system_freezing_cnt); atomic_dec(&system_freezing_cnt);
freezer->state = CGROUP_THAWED; freezer->state = CGROUP_THAWED;
unfreeze_cgroup(cgroup, freezer); unfreeze_cgroup(freezer);
break; break;
case CGROUP_FROZEN: case CGROUP_FROZEN:
if (freezer->state == CGROUP_THAWED) if (freezer->state == CGROUP_THAWED)
atomic_inc(&system_freezing_cnt); atomic_inc(&system_freezing_cnt);
freezer->state = CGROUP_FREEZING; freezer->state = CGROUP_FREEZING;
freeze_cgroup(cgroup, freezer); freeze_cgroup(freezer);
break; break;
default: default:
BUG(); BUG();
...@@ -275,8 +273,7 @@ static void freezer_change_state(struct cgroup *cgroup, ...@@ -275,8 +273,7 @@ static void freezer_change_state(struct cgroup *cgroup,
spin_unlock_irq(&freezer->lock); spin_unlock_irq(&freezer->lock);
} }
static int freezer_write(struct cgroup *cgroup, static int freezer_write(struct cgroup *cgroup, struct cftype *cft,
struct cftype *cft,
const char *buffer) const char *buffer)
{ {
enum freezer_state goal_state; enum freezer_state goal_state;
...@@ -288,7 +285,7 @@ static int freezer_write(struct cgroup *cgroup, ...@@ -288,7 +285,7 @@ static int freezer_write(struct cgroup *cgroup,
else else
return -EINVAL; return -EINVAL;
freezer_change_state(cgroup, goal_state); freezer_change_state(cgroup_freezer(cgroup), goal_state);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment