[Devel] [PATCH RHEL7 COMMIT] memcg: ignore memory.low for cgroups w/o tasks

Konstantin Khorenko khorenko at virtuozzo.com
Fri Feb 26 04:19:34 PST 2016


The commit is pushed to "branch-rh7-3.10.0-327.3.1-vz7.10.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.3.1.vz7.10.13
------>
commit 2f39f1ef3fa884221b04c9e5f9619f0bf4d504a8
Author: Vladimir Davydov <vdavydov at virtuozzo.com>
Date:   Fri Feb 26 16:19:34 2016 +0400

    memcg: ignore memory.low for cgroups w/o tasks
    
    It's OK to set memory.low for a cgroup to infinity. This might be useful
    if no tasks are supposed to run inside the cgroup itself, but only in
    its sub-cgroups (e.g. /machine.slice). In this case protection against
    memory pressure originating on upper levels will be guarded solely by
    memory.low configuration in sub-cgroups.
    
    However, in the current implementation, in contrast to mainstream,
    charges can appear in a cgroup even if there's no tasks in it - they can
    be reparented from a dead sub-cgroup. If the cgroup has memory.low set
    to inf, such reparented charges will not get reclaimed normally on
    memory pressure, resulting in performance degradation in other cgroups.
    To avoid that, let's ignore memory.low for cgroups w/o tasks.
    
    https://jira.sw.ru/browse/PSBM-44192
    
    Signed-off-by: Vladimir Davydov <vdavydov at virtuozzo.com>
    Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 mm/memcontrol.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index ddd162a..6009ff5 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1607,6 +1607,24 @@ bool mem_cgroup_low(struct mem_cgroup *root, struct mem_cgroup *memcg)
 	if (res_counter_read_u64(&memcg->res, RES_USAGE) >= memcg->low)
 		return false;
 
+	/*
+	 * XXX: It's OK to set memory.low for a cgroup to infinity. This might
+	 * be useful if no tasks are supposed to run inside the cgroup itself,
+	 * but only in its sub-cgroups (e.g. /machine.slice). In this case
+	 * protection against memory pressure originating on upper levels will
+	 * be guarded solely by memory.low configuration in sub-cgroups.
+	 *
+	 * However, in the current implementation, in contrast to mainstream,
+	 * charges can appear in a cgroup even if there's no tasks in it - they
+	 * can be reparented from a dead sub-cgroup. If the cgroup has
+	 * memory.low set to inf, such reparented charges will not get
+	 * reclaimed normally on memory pressure, resulting in performance
+	 * degradation in other cgroups. To avoid that, let's ignore memory.low
+	 * for cgroups w/o tasks.
+	 */
+	if (cgroup_task_count(memcg->css.cgroup) == 0)
+		return false;
+
 	while (memcg != root) {
 		memcg = parent_mem_cgroup(memcg);
 		if (!memcg)


More information about the Devel mailing list