[Devel] [PATCH RHEL7 COMMIT] ve/memcg: pass struct mem_cgroup instead of cgroup to ub-related methods

Konstantin Khorenko khorenko at virtuozzo.com
Tue Jun 9 07:45:36 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-123.1.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-123.1.2.vz7.5.11
------>
commit b03f805591907a12268a38f0f4885055d49c48b9
Author: Vladimir Davydov <vdavydov at parallels.com>
Date:   Tue Jun 9 18:45:36 2015 +0400

    ve/memcg: pass struct mem_cgroup instead of cgroup to ub-related methods
    
    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>
    Reviewed-by: Cyrill Gorcunov <gorcunov at openvz.org>
    
    Related to patchset:
    
    https://jira.sw.ru/browse/PSBM-34035
    
    Vladimir Davydov (6):
      cgroup: add function to lookup a cgroup by pathname
      cgroup: make cgroup_kernel_attach safe against cgroup removal
      ub: rename functions for reading/writing cgroup resources
      ub: rework connection between ub and mem/blkio cgroups
      memcg: pass struct mem_cgroup instead of cgroup to ub-related methods
      ub: introduce ub_total_pages
---
 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 c01fbb3..7d20f73 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 164be1b..bda7d42 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1317,13 +1317,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));
@@ -5409,9 +5409,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;
 
@@ -5467,9 +5467,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;
 



More information about the Devel mailing list