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

Submitted by Konstantin Khorenko on March 31, 2017, 3:13 p.m.

Details

Message ID 201703311513.v2VFDIfO001732@finist_cl7.x64_64.work.ct
State New
Series "Series without cover letter"
Headers show

Commit Message

Konstantin Khorenko March 31, 2017, 3:13 p.m.
The commit is pushed to "branch-rh7-3.10.0-514.10.2.vz7.29.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.10.2.vz7.29.9
------>
commit 45e4eda89d310ef720a8aa9eff949f3e8e74c6c5
Author: Vladimir Davydov <vdavydov@virtuozzo.com>
Date:   Fri Mar 31 19:13:18 2017 +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@virtuozzo.com>
    
    https://jira.sw.ru/browse/PSBM-62827
    Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 mm/memcontrol.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index bc72a26..4e1dbbb 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4382,6 +4382,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;
@@ -4395,7 +4407,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, PAGE_COUNTER_MAX);
 	mutex_unlock(&activate_kmem_mutex);
 	return ret;