[Devel] [PATCH rh7 5/6] memcg: pass struct mem_cgroup instead of cgroup to ub-related methods

Vladimir Davydov vdavydov at parallels.com
Sun Jun 7 04:57:17 PDT 2015


All other public memcg functions require struct mem_cgroup, not struct
cgroup. Let's follow the trend.

Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
 kernel/bc/beancounter.c | 17 +++++++++--------
 mm/memcontrol.c         | 14 +++++++-------
 2 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/kernel/bc/beancounter.c b/kernel/bc/beancounter.c
index c01fbb330522..7d20f734fad4 100644
--- a/kernel/bc/beancounter.c
+++ b/kernel/bc/beancounter.c
@@ -210,10 +210,12 @@ fail_blkio:
 	goto out;
 }
 
-extern void mem_cgroup_sync_beancounter(struct cgroup *cg,
+extern void mem_cgroup_sync_beancounter(struct mem_cgroup *memcg,
 					struct user_beancounter *ub);
-extern int mem_cgroup_apply_beancounter(struct cgroup *cg,
+extern int mem_cgroup_apply_beancounter(struct mem_cgroup *memcg,
 					struct user_beancounter *ub);
+extern void mem_cgroup_get_nr_pages(struct mem_cgroup *memcg, int nid,
+				    unsigned long *pages);
 
 /*
  * Update memcg limits according to beancounter configuration.
@@ -224,7 +226,8 @@ int ub_update_memcg(struct user_beancounter *ub)
 	int ret;
 
 	css = ub_get_mem_css(ub);
-	ret = mem_cgroup_apply_beancounter(css->cgroup, ub);
+	ret = mem_cgroup_apply_beancounter(mem_cgroup_from_cont(css->cgroup),
+					   ub);
 	css_put(css);
 	return ret;
 }
@@ -237,13 +240,10 @@ void ub_sync_memcg(struct user_beancounter *ub)
 	struct cgroup_subsys_state *css;
 
 	css = ub_get_mem_css(ub);
-	mem_cgroup_sync_beancounter(css->cgroup, ub);
+	mem_cgroup_sync_beancounter(mem_cgroup_from_cont(css->cgroup), ub);
 	css_put(css);
 }
 
-extern void mem_cgroup_get_nr_pages(struct cgroup *cg, int nid,
-				    unsigned long *pages);
-
 void ub_page_stat(struct user_beancounter *ub, const nodemask_t *nodemask,
 		  unsigned long *pages)
 {
@@ -254,7 +254,8 @@ void ub_page_stat(struct user_beancounter *ub, const nodemask_t *nodemask,
 
 	css = ub_get_mem_css(ub);
 	for_each_node_mask(nid, *nodemask)
-		mem_cgroup_get_nr_pages(css->cgroup, nid, pages);
+		mem_cgroup_get_nr_pages(mem_cgroup_from_cont(css->cgroup),
+					nid, pages);
 	css_put(css);
 }
 
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 6573ce3231b7..6beded785d39 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1292,13 +1292,13 @@ void mem_cgroup_iter_break(struct mem_cgroup *root,
 	     iter != NULL;				\
 	     iter = mem_cgroup_iter(NULL, iter, NULL))
 
-void mem_cgroup_get_nr_pages(struct cgroup *cg, int nid, unsigned long *pages)
+void mem_cgroup_get_nr_pages(struct mem_cgroup *memcg, int nid,
+			     unsigned long *pages)
 {
-	struct mem_cgroup *root = mem_cgroup_from_cont(cg);
 	struct mem_cgroup *iter;
 	int i;
 
-	for_each_mem_cgroup_tree(iter, root) {
+	for_each_mem_cgroup_tree(iter, memcg) {
 		for (i = 0; i < NR_LRU_LISTS; i++)
 			pages[i] += mem_cgroup_node_nr_lru_pages(iter, nid,
 								 BIT(i));
@@ -5374,9 +5374,9 @@ static int mem_cgroup_move_charge_write(struct cgroup *cgrp,
 
 #include <bc/beancounter.h>
 
-void mem_cgroup_sync_beancounter(struct cgroup *cg, struct user_beancounter *ub)
+void mem_cgroup_sync_beancounter(struct mem_cgroup *memcg,
+				 struct user_beancounter *ub)
 {
-	struct mem_cgroup *memcg = mem_cgroup_from_cont(cg);
 	unsigned long long lim, held, maxheld;
 	volatile struct ubparm *k, *d, *p, *s, *o;
 
@@ -5432,9 +5432,9 @@ void mem_cgroup_sync_beancounter(struct cgroup *cg, struct user_beancounter *ub)
 	o->barrier = o->limit = lim;
 }
 
-int mem_cgroup_apply_beancounter(struct cgroup *cg, struct user_beancounter *ub)
+int mem_cgroup_apply_beancounter(struct mem_cgroup *memcg,
+				 struct user_beancounter *ub)
 {
-	struct mem_cgroup *memcg = mem_cgroup_from_cont(cg);
 	unsigned long long mem, memsw, mem_old, memsw_old, oomguar;
 	int ret = 0;
 
-- 
2.1.4




More information about the Devel mailing list