[BUGFIX][PATCH] memcg: fix thresholds with use_hierarchy == 1

From: Kirill A. Shutsemov
Date: Wed Sep 29 2010 - 08:27:50 EST


From: Kirill A. Shutemov <kirill@xxxxxxxxxxxxx>

We need to check parent's thresholds if parent has use_hierarchy == 1 to
be sure that parent's threshold events will be triggered even if parent
itself is not active (no MEM_CGROUP_EVENTS).

Signed-off-by: Kirill A. Shutemov <kirill@xxxxxxxxxxxxx>
---
mm/memcontrol.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 3eed583..196f710 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3587,9 +3587,20 @@ unlock:

static void mem_cgroup_threshold(struct mem_cgroup *memcg)
{
- __mem_cgroup_threshold(memcg, false);
- if (do_swap_account)
- __mem_cgroup_threshold(memcg, true);
+ struct cgroup *parent;
+
+ while (1) {
+ __mem_cgroup_threshold(memcg, false);
+ if (do_swap_account)
+ __mem_cgroup_threshold(memcg, true);
+
+ parent = memcg->css.cgroup->parent;
+ if (!parent)
+ break;
+ memcg = mem_cgroup_from_cont(parent);
+ if (!memcg->use_hierarchy)
+ break;
+ }
}

static int compare_thresholds(const void *a, const void *b)
--
1.7.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/