[Devel] [PATCH rh7 3/4] memcg: assure swap->held/maxheld < swap->limit for beancounters

Vladimir Davydov vdavydov at parallels.com
Tue May 19 07:31:47 PDT 2015


We assume UB_SWAPPAGES held/maxheld is equal to

  memory.memsw.usage - memory.usage

but this can be greater than UB_SWAPPAGES limit, which is defined as

  memory.memsw.limit - memory.limit

e.g. due to global reclaim. Fix that.

Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
 mm/memcontrol.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 7d7c2e8fa145..ba6fc0f641cf 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5184,6 +5184,11 @@ void mem_cgroup_fill_ub_parms(struct cgroup *cg,
 	if (lim != UB_MAXVALUE)
 		lim -= p->limit;
 	s->barrier = s->limit = lim;
+
+	/* Due to global reclaim, memory.memsw.usage can be greater than
+	 * (memory.memsw.limit - memory.limit). */
+	s->held = min(s->held, s->limit);
+	s->maxheld = min(s->maxheld, s->limit);
 }
 
 int mem_cgroup_apply_beancounter(struct cgroup *cg, struct user_beancounter *ub)
-- 
1.7.10.4




More information about the Devel mailing list