[Devel] [PATCH RHEL7 COMMIT] bc/memcg: assure swap->held/maxheld < swap->limit for beancounters

Konstantin Khorenko khorenko at virtuozzo.com
Mon May 25 02:19:10 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.5
------>
commit 6a541e8212b0bffc602a3fb998a04a5484b21c53
Author: Vladimir Davydov <vdavydov at parallels.com>
Date:   Mon May 25 13:19:10 2015 +0400

    bc/memcg: assure swap->held/maxheld < swap->limit for beancounters
    
    Patchset description:
    
    ub: fix memcg resource accounting
    
    UB_PHYSPAGES, UB_SWAPPAGES, UB_KMEMSIZE are now accounted on the memcg
    size. However, some stats differ between beancounters and memcg (e.g.
    failcnt). This patch set fixes them. For more details, see individual
    patches.
    
    Related to https://jira.sw.ru/browse/PSBM-20089
    
    Vladimir Davydov (4):
      memcg: show correct swap max for beancounters
      memcg: show correct mem/swap failcnt for beancounters
      memcg: assure swap->held/maxheld < swap->limit for beancounters
      ub: deprecate kmemsize limit
    
    =================================================================
    This patch description:
    
    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>
    Reviewed-by: Kirill Tkhai <ktkhai at odin.com>
---
 mm/memcontrol.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 7d7c2e8..ba6fc0f 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)



More information about the Devel mailing list