diff options
author | Tejun Heo <tj@kernel.org> | 2013-08-08 20:11:25 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-08-08 20:11:25 -0400 |
commit | 492eb21b98f88e411a8bb43d6edcd7d7022add10 (patch) | |
tree | da06df9485fd607762fdec06169f7d9f601e3cf6 /mm/memcontrol.c | |
parent | f48e3924dca268c677c4e338e5d91ad9e6fe6b9e (diff) |
cgroup: make hierarchy iterators deal with cgroup_subsys_state instead of cgroup
cgroup is currently in the process of transitioning to using css
(cgroup_subsys_state) as the primary handle instead of cgroup in
subsystem API. For hierarchy iterators, this is beneficial because
* In most cases, css is the only thing subsystems care about anyway.
* On the planned unified hierarchy, iterations for different
subsystems will need to skip over different subtrees of the
hierarchy depending on which subsystems are enabled on each cgroup.
Passing around css makes it unnecessary to explicitly specify the
subsystem in question as css is intersection between cgroup and
subsystem
* For the planned unified hierarchy, css's would need to be created
and destroyed dynamically independent from cgroup hierarchy. Having
cgroup core manage css iteration makes enforcing deref rules a lot
easier.
Most subsystem conversions are straight-forward. Noteworthy changes
are
* blkio: cgroup_to_blkcg() is no longer used. Removed.
* freezer: cgroup_freezer() is no longer used. Removed.
* devices: cgroup_to_devcgroup() is no longer used. Removed.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizefan@huawei.com>
Acked-by: Michal Hocko <mhocko@suse.cz>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Acked-by: Aristeu Rozanski <aris@redhat.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: Matt Helsley <matthltc@us.ibm.com>
Cc: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r-- | mm/memcontrol.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index ab64dfc84f8c..2285319e23a9 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -1082,7 +1082,7 @@ struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm) | |||
1082 | static struct mem_cgroup *__mem_cgroup_iter_next(struct mem_cgroup *root, | 1082 | static struct mem_cgroup *__mem_cgroup_iter_next(struct mem_cgroup *root, |
1083 | struct mem_cgroup *last_visited) | 1083 | struct mem_cgroup *last_visited) |
1084 | { | 1084 | { |
1085 | struct cgroup *prev_cgroup, *next_cgroup; | 1085 | struct cgroup_subsys_state *prev_css, *next_css; |
1086 | 1086 | ||
1087 | /* | 1087 | /* |
1088 | * Root is not visited by cgroup iterators so it needs an | 1088 | * Root is not visited by cgroup iterators so it needs an |
@@ -1091,11 +1091,9 @@ static struct mem_cgroup *__mem_cgroup_iter_next(struct mem_cgroup *root, | |||
1091 | if (!last_visited) | 1091 | if (!last_visited) |
1092 | return root; | 1092 | return root; |
1093 | 1093 | ||
1094 | prev_cgroup = (last_visited == root) ? NULL | 1094 | prev_css = (last_visited == root) ? NULL : &last_visited->css; |
1095 | : last_visited->css.cgroup; | ||
1096 | skip_node: | 1095 | skip_node: |
1097 | next_cgroup = cgroup_next_descendant_pre( | 1096 | next_css = css_next_descendant_pre(prev_css, &root->css); |
1098 | prev_cgroup, root->css.cgroup); | ||
1099 | 1097 | ||
1100 | /* | 1098 | /* |
1101 | * Even if we found a group we have to make sure it is | 1099 | * Even if we found a group we have to make sure it is |
@@ -1104,13 +1102,13 @@ skip_node: | |||
1104 | * last_visited css is safe to use because it is | 1102 | * last_visited css is safe to use because it is |
1105 | * protected by css_get and the tree walk is rcu safe. | 1103 | * protected by css_get and the tree walk is rcu safe. |
1106 | */ | 1104 | */ |
1107 | if (next_cgroup) { | 1105 | if (next_css) { |
1108 | struct mem_cgroup *mem = mem_cgroup_from_cont( | 1106 | struct mem_cgroup *mem = mem_cgroup_from_css(next_css); |
1109 | next_cgroup); | 1107 | |
1110 | if (css_tryget(&mem->css)) | 1108 | if (css_tryget(&mem->css)) |
1111 | return mem; | 1109 | return mem; |
1112 | else { | 1110 | else { |
1113 | prev_cgroup = next_cgroup; | 1111 | prev_css = next_css; |
1114 | goto skip_node; | 1112 | goto skip_node; |
1115 | } | 1113 | } |
1116 | } | 1114 | } |
@@ -4939,10 +4937,10 @@ static void mem_cgroup_reparent_charges(struct mem_cgroup *memcg) | |||
4939 | */ | 4937 | */ |
4940 | static inline bool __memcg_has_children(struct mem_cgroup *memcg) | 4938 | static inline bool __memcg_has_children(struct mem_cgroup *memcg) |
4941 | { | 4939 | { |
4942 | struct cgroup *pos; | 4940 | struct cgroup_subsys_state *pos; |
4943 | 4941 | ||
4944 | /* bounce at first found */ | 4942 | /* bounce at first found */ |
4945 | cgroup_for_each_child(pos, memcg->css.cgroup) | 4943 | css_for_each_child(pos, &memcg->css) |
4946 | return true; | 4944 | return true; |
4947 | return false; | 4945 | return false; |
4948 | } | 4946 | } |