[Devel] [PATCH rh7 2/2] memcg: sync UB_DCACHESIZE

Vladimir Davydov vdavydov at parallels.com
Fri May 22 04:08:25 PDT 2015


Sync it with mem_cgroup->dcache. Disallow setting the limit, because we
do not support it, and issue a warning if the user tries to set it via
the legacy UB interface, just like we do in case with UB_KMEMSIZE.

Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
 kernel/bc/beancounter.c |    3 ++-
 kernel/bc/vm_pages.c    |    1 -
 mm/memcontrol.c         |   10 +++++++++-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/kernel/bc/beancounter.c b/kernel/bc/beancounter.c
index 48f5a25d2add..60388ce7cf42 100644
--- a/kernel/bc/beancounter.c
+++ b/kernel/bc/beancounter.c
@@ -396,6 +396,7 @@ static inline int bc_verify_held(struct user_beancounter *ub)
 
 	/* accounted by memcg */
 	ub->ub_parms[UB_KMEMSIZE].held = 0;
+	ub->ub_parms[UB_DCACHESIZE].held = 0;
 	ub->ub_parms[UB_PHYSPAGES].held = 0;
 	ub->ub_parms[UB_SWAPPAGES].held = 0;
 	ub->ub_parms[UB_OOMGUARPAGES].held = 0;
@@ -916,7 +917,7 @@ static void init_beancounter_syslimits(struct user_beancounter *ub)
 	ub->ub_parms[UB_NUMFLOCK].limit = 1024;
 	ub->ub_parms[UB_NUMPTY].limit = 16;
 	ub->ub_parms[UB_NUMSIGINFO].limit = 1024;
-	ub->ub_parms[UB_DCACHESIZE].limit = 1024*1024;
+	ub->ub_parms[UB_DCACHESIZE].limit = UB_MAXVALUE;
 	ub->ub_parms[UB_NUMFILE].limit = 1024;
 	ub->ub_parms[UB_PHYSPAGES].limit = UB_MAXVALUE;
 	ub->ub_parms[UB_SWAPPAGES].limit = UB_MAXVALUE;
diff --git a/kernel/bc/vm_pages.c b/kernel/bc/vm_pages.c
index e0e3c4550ceb..a6f311e33894 100644
--- a/kernel/bc/vm_pages.c
+++ b/kernel/bc/vm_pages.c
@@ -202,7 +202,6 @@ static int bc_fill_meminfo(struct user_beancounter *ub,
 
 		mi->dirty_pages	+= pcpu->dirty_pages;
 		mi->writeback_pages	+= pcpu->writeback_pages;
-		dcache		-= pcpu->precharge[UB_DCACHESIZE];
 	}
 
 	mi->dirty_pages = max_t(long, 0, mi->dirty_pages);
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 1871108bba17..dd7f6ef19d76 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5335,9 +5335,10 @@ void mem_cgroup_sync_beancounter(struct cgroup *cg, struct user_beancounter *ub)
 {
 	struct mem_cgroup *memcg = mem_cgroup_from_cont(cg);
 	unsigned long long lim, held, maxheld;
-	volatile struct ubparm *k, *p, *s, *o;
+	volatile struct ubparm *k, *d, *p, *s, *o;
 
 	k = &ub->ub_parms[UB_KMEMSIZE];
+	d = &ub->ub_parms[UB_DCACHESIZE];
 	p = &ub->ub_parms[UB_PHYSPAGES];
 	s = &ub->ub_parms[UB_SWAPPAGES];
 	o = &ub->ub_parms[UB_OOMGUARPAGES];
@@ -5358,6 +5359,11 @@ void mem_cgroup_sync_beancounter(struct cgroup *cg, struct user_beancounter *ub)
 		min_t(unsigned long long, lim, UB_MAXVALUE);
 	k->barrier = k->limit = lim;
 
+	d->held = res_counter_read_u64(&memcg->dcache, RES_USAGE);
+	d->maxheld = res_counter_read_u64(&memcg->dcache, RES_MAX_USAGE);
+	d->failcnt = 0;
+	d->barrier = d->limit = UB_MAXVALUE;
+
 	held = (res_counter_read_u64(&memcg->memsw, RES_USAGE) -
 		res_counter_read_u64(&memcg->res, RES_USAGE)) >> PAGE_SHIFT;
 	maxheld = memcg->swap_max >> PAGE_SHIFT;
@@ -5413,6 +5419,8 @@ int mem_cgroup_apply_beancounter(struct cgroup *cg, struct user_beancounter *ub)
 
 	if (ub->ub_parms[UB_KMEMSIZE].limit != UB_MAXVALUE)
 		pr_warn_once("ub: kmemsize limit is deprecated\n");
+	if (ub->ub_parms[UB_DCACHESIZE].limit != UB_MAXVALUE)
+		pr_warn_once("ub: dcachesize limit is deprecated\n");
 
 	/* activate kmem accounting */
 	ret = memcg_update_kmem_limit(memcg, RESOURCE_MAX);
-- 
1.7.10.4




More information about the Devel mailing list