[Devel] [PATCH RHEL7 COMMIT] bc: deprecate kmemsize limit

Konstantin Khorenko khorenko at virtuozzo.com
Mon May 25 02:19:16 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 89790f478519e4b319446fb9ebc2d50a5141034e
Author: Vladimir Davydov <vdavydov at parallels.com>
Date:   Mon May 25 13:19:16 2015 +0400

    bc: deprecate kmemsize limit
    
    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:
    
    Setting kmemsize limit < physpages limit is useless, because hitting
    kmemsize limit does not trigger reclaim. This is upstream behavior and
    we are not going to fix it for now, because kmemsize is accounted to and
    limited by physpages anyway.
    
    This patch makes the kernel ignore kmemsize limit, issuing a warning on
    an attempt to set it.
    
    Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
    Reviewed-by: Kirill Tkhai <ktkhai at odin.com>
---
 kernel/bc/beancounter.c |  4 +---
 mm/memcontrol.c         | 16 +++++++---------
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/kernel/bc/beancounter.c b/kernel/bc/beancounter.c
index 88faa1c..8cbf7d4 100644
--- a/kernel/bc/beancounter.c
+++ b/kernel/bc/beancounter.c
@@ -986,9 +986,7 @@ static void init_beancounter_syslimits(struct user_beancounter *ub)
 	int k;
 
 	mp = num_physpages;
-	ub->ub_parms[UB_KMEMSIZE].limit = 
-		mp > (192*1024*1024 >> PAGE_SHIFT) ?
-				32*1024*1024 : (mp << PAGE_SHIFT) / 6;
+	ub->ub_parms[UB_KMEMSIZE].limit = UB_MAXVALUE;
 	ub->ub_parms[UB_LOCKEDPAGES].limit = 8;
 	ub->ub_parms[UB_PRIVVMPAGES].limit = UB_MAXVALUE;
 	ub->ub_parms[UB_SHMPAGES].limit = 64;
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index ba6fc0f..01a8e5a 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5194,7 +5194,7 @@ void mem_cgroup_fill_ub_parms(struct cgroup *cg,
 int mem_cgroup_apply_beancounter(struct cgroup *cg, struct user_beancounter *ub)
 {
 	struct mem_cgroup *memcg = mem_cgroup_from_cont(cg);
-	unsigned long long mem, memsw, kmem, mem_old, memsw_old;
+	unsigned long long mem, memsw, mem_old, memsw_old;
 	int ret = 0;
 
 	mem = ub->ub_parms[UB_PHYSPAGES].limit;
@@ -5213,15 +5213,13 @@ int mem_cgroup_apply_beancounter(struct cgroup *cg, struct user_beancounter *ub)
 	else
 		memsw = RESOURCE_MAX;
 
-	kmem = ub->ub_parms[UB_KMEMSIZE].limit;
-	if (kmem >= RESOURCE_MAX)
-		kmem = RESOURCE_MAX - 1; /* not 'unlimited' */
+	if (ub->ub_parms[UB_KMEMSIZE].limit != UB_MAXVALUE)
+		pr_warn_once("ub: kmemsize limit is deprecated\n");
 
-	if (res_counter_read_u64(&memcg->kmem, RES_LIMIT) != kmem) {
-		ret = memcg_update_kmem_limit(memcg, kmem);
-		if (ret)
-			goto out;
-	}
+	/* activate kmem accounting */
+	ret = memcg_update_kmem_limit(memcg, RESOURCE_MAX);
+	if (ret)
+		goto out;
 
 	/* try change mem+swap before changing mem limit */
 	if (res_counter_read_u64(&memcg->memsw, RES_LIMIT) != memsw)



More information about the Devel mailing list