aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-08-08 20:11:22 -0400
committerTejun Heo <tj@kernel.org>2013-08-08 20:11:22 -0400
commit3f79851831a135c5cebbcaa8cddb07d02870b069 (patch)
treeafe7ebf14a4ffecc5bb053d6c0c1474155b598e1
parent6d37b97428d20a21ffc39ba90e97e91e2a79a986 (diff)
hugetlb_cgroup: pass around @hugetlb_cgroup instead of @cgroup
cgroup controller API will be converted to primarily use struct cgroup_subsys_state instead of struct cgroup. In preparation, make hugetlb_cgroup functions pass around struct hugetlb_cgroup instead of struct cgroup. This patch shouldn't cause any behavior differences. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com> Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Reviewed-by: Michal Hocko <mhocko@suse.cz> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Johannes Weiner <hannes@cmpxchg.org>
-rw-r--r--mm/hugetlb_cgroup.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c
index 50f213fc52c7..d2f9fc0b186e 100644
--- a/mm/hugetlb_cgroup.c
+++ b/mm/hugetlb_cgroup.c
@@ -56,17 +56,19 @@ static inline bool hugetlb_cgroup_is_root(struct hugetlb_cgroup *h_cg)
56 return (h_cg == root_h_cgroup); 56 return (h_cg == root_h_cgroup);
57} 57}
58 58
59static inline struct hugetlb_cgroup *parent_hugetlb_cgroup(struct cgroup *cg) 59static inline struct hugetlb_cgroup *
60parent_hugetlb_cgroup(struct hugetlb_cgroup *h_cg)
60{ 61{
61 if (!cg->parent) 62 struct cgroup *parent = h_cg->css.cgroup->parent;
63
64 if (!parent)
62 return NULL; 65 return NULL;
63 return hugetlb_cgroup_from_cgroup(cg->parent); 66 return hugetlb_cgroup_from_cgroup(parent);
64} 67}
65 68
66static inline bool hugetlb_cgroup_have_usage(struct cgroup *cg) 69static inline bool hugetlb_cgroup_have_usage(struct hugetlb_cgroup *h_cg)
67{ 70{
68 int idx; 71 int idx;
69 struct hugetlb_cgroup *h_cg = hugetlb_cgroup_from_cgroup(cg);
70 72
71 for (idx = 0; idx < hugetlb_max_hstate; idx++) { 73 for (idx = 0; idx < hugetlb_max_hstate; idx++) {
72 if ((res_counter_read_u64(&h_cg->hugepage[idx], RES_USAGE)) > 0) 74 if ((res_counter_read_u64(&h_cg->hugepage[idx], RES_USAGE)) > 0)
@@ -115,15 +117,14 @@ static void hugetlb_cgroup_css_free(struct cgroup *cgroup)
115 * page reference and test for page active here. This function 117 * page reference and test for page active here. This function
116 * cannot fail. 118 * cannot fail.
117 */ 119 */
118static void hugetlb_cgroup_move_parent(int idx, struct cgroup *cgroup, 120static void hugetlb_cgroup_move_parent(int idx, struct hugetlb_cgroup *h_cg,
119 struct page *page) 121 struct page *page)
120{ 122{
121 int csize; 123 int csize;
122 struct res_counter *counter; 124 struct res_counter *counter;
123 struct res_counter *fail_res; 125 struct res_counter *fail_res;
124 struct hugetlb_cgroup *page_hcg; 126 struct hugetlb_cgroup *page_hcg;
125 struct hugetlb_cgroup *h_cg = hugetlb_cgroup_from_cgroup(cgroup); 127 struct hugetlb_cgroup *parent = parent_hugetlb_cgroup(h_cg);
126 struct hugetlb_cgroup *parent = parent_hugetlb_cgroup(cgroup);
127 128
128 page_hcg = hugetlb_cgroup_from_page(page); 129 page_hcg = hugetlb_cgroup_from_page(page);
129 /* 130 /*
@@ -155,6 +156,7 @@ out:
155 */ 156 */
156static void hugetlb_cgroup_css_offline(struct cgroup *cgroup) 157static void hugetlb_cgroup_css_offline(struct cgroup *cgroup)
157{ 158{
159 struct hugetlb_cgroup *h_cg = hugetlb_cgroup_from_cgroup(cgroup);
158 struct hstate *h; 160 struct hstate *h;
159 struct page *page; 161 struct page *page;
160 int idx = 0; 162 int idx = 0;
@@ -163,13 +165,13 @@ static void hugetlb_cgroup_css_offline(struct cgroup *cgroup)
163 for_each_hstate(h) { 165 for_each_hstate(h) {
164 spin_lock(&hugetlb_lock); 166 spin_lock(&hugetlb_lock);
165 list_for_each_entry(page, &h->hugepage_activelist, lru) 167 list_for_each_entry(page, &h->hugepage_activelist, lru)
166 hugetlb_cgroup_move_parent(idx, cgroup, page); 168 hugetlb_cgroup_move_parent(idx, h_cg, page);
167 169
168 spin_unlock(&hugetlb_lock); 170 spin_unlock(&hugetlb_lock);
169 idx++; 171 idx++;
170 } 172 }
171 cond_resched(); 173 cond_resched();
172 } while (hugetlb_cgroup_have_usage(cgroup)); 174 } while (hugetlb_cgroup_have_usage(h_cg));
173} 175}
174 176
175int hugetlb_cgroup_charge_cgroup(int idx, unsigned long nr_pages, 177int hugetlb_cgroup_charge_cgroup(int idx, unsigned long nr_pages,