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 <[email protected]>
---
 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

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to