[Devel] [PATCH RHEL7 COMMIT] ve/memcg: enable kmem accounting for all cgroups

Konstantin Khorenko khorenko at virtuozzo.com
Mon Nov 23 08:19:26 PST 2015


The commit is pushed to "branch-rh7-3.10.0-229.7.2.vz7.9.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-229.7.2.vz7.9.12
------>
commit 35bf94617485b3842f8a45241673fb0f7e81189d
Author: Vladimir Davydov <vdavydov at virtuozzo.com>
Date:   Mon Nov 23 20:19:26 2015 +0400

    ve/memcg: enable kmem accounting for all cgroups
    
    Currently, kmem accounting is only enabled for a cgroup upon write to
    memory.kmem.limit_in_bytes. This is fine in case of containers, because
    we've already taught vzctl to do it, but we also want to enable it for
    system.slice, otherwise dcache used by the host will be scanned too
    aggressively in case all cgroups are protected with memory.low, and here
    comes the problem: system.slice is populated by systemd, which never
    sets memory.kmem.limit_in_bytes, and once a cgroup is populated one
    cannot enable kmem accounting for it.
    
    To overcome this, let's enable kmem accounting by default for all memory
    cgroups. Since we already enable it for most cgroups, this shouldn't
    cause any problems apart from perhaps small performance degradation of
    processes on the host, which is of least importance. Note, the system
    can be still returned to the former behavior by passing kmemaccount=0 on
    boot.
    
    Signed-off-by: Vladimir Davydov <vdavydov at virtuozzo.com>
---
 mm/memcontrol.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 26c1265..15bbd26 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5069,6 +5069,18 @@ static int memcg_update_kmem_limit(struct mem_cgroup *memcg,
 	return ret;
 }
 
+static bool do_kmem_account = true;
+
+static int __init enable_kmem_account(char *s)
+{
+	if (!strcmp(s, "1"))
+		do_kmem_account = true;
+	else if (!strcmp(s, "0"))
+		do_kmem_account = false;
+	return 1;
+}
+__setup("kmemaccount=", enable_kmem_account);
+
 static int memcg_propagate_kmem(struct mem_cgroup *memcg)
 {
 	int ret = 0;
@@ -5082,7 +5094,7 @@ static int memcg_propagate_kmem(struct mem_cgroup *memcg)
 	 * If the parent cgroup is not kmem-active now, it cannot be activated
 	 * after this point, because it has at least one child already.
 	 */
-	if (memcg_kmem_is_active(parent))
+	if (do_kmem_account || memcg_kmem_is_active(parent))
 		ret = __memcg_activate_kmem(memcg, RESOURCE_MAX);
 	mutex_unlock(&activate_kmem_mutex);
 	return ret;


More information about the Devel mailing list