[ 3.8.y.z extended stable ] Patch "memcg: fix multiple large threshold notifications" has been added to staging queue
kamal at canonical.com
Fri Sep 20 00:36:31 UTC 2013
This is a note to let you know that I have just added a patch titled
memcg: fix multiple large threshold notifications
to the linux-3.8.y-queue branch of the 3.8.y.z extended stable tree
which can be found at:
This patch is scheduled to be released in version 18.104.22.168.
If you, or anyone else, feels it should not be added to this tree, please
reply to this email.
For more information about the 3.8.y.z tree, see
>From 020a95908a52a11c4414fd62bb4a6abd61ccca18 Mon Sep 17 00:00:00 2001
From: Greg Thelen <gthelen at google.com>
Date: Wed, 11 Sep 2013 14:23:08 -0700
Subject: memcg: fix multiple large threshold notifications
commit 2bff24a3707093c435ab3241c47dcdb5f16e432b upstream.
A memory cgroup with (1) multiple threshold notifications and (2) at least
one threshold >=2G was not reliable. Specifically the notifications would
either not fire or would not fire in the proper order.
The __mem_cgroup_threshold() signaling logic depends on keeping 64 bit
thresholds in sorted order. mem_cgroup_usage_register_event() sorts them
with compare_thresholds(), which returns the difference of two 64 bit
thresholds as an int. If the difference is positive but has bit set,
then sort() treats the difference as negative and breaks sort order.
This fix compares the two arbitrary 64 bit thresholds returning the
classic -1, 0, 1 result.
The test below sets two notifications (at 0x1000 and 0x81001000):
for x in 4096 2164264960; do
cgroup_event_listener x/memory.usage_in_bytes $x | sed "s/^/$x listener:/" &
echo $$ > x/cgroup.procs
v3.11-rc7 fails to signal the 4096 event listener:
Done leaking pages.
Patched v3.11-rc7 properly notifies:
Done leaking pages.
The fixed bug is old. It appears to date back to the introduction of
memcg threshold notifications in v2.6.34-rc1-116-g2e72b6347c94 "memcg:
implement memory thresholds"
Signed-off-by: Greg Thelen <gthelen at google.com>
Acked-by: Michal Hocko <mhocko at suse.cz>
Acked-by: Kirill A. Shutemov <kirill.shutemov at linux.intel.com>
Acked-by: Johannes Weiner <hannes at cmpxchg.org>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
Signed-off-by: Kamal Mostafa <kamal at canonical.com>
mm/memcontrol.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index fd7c0d3..6b7ff19 100644
@@ -5428,7 +5428,13 @@ static int compare_thresholds(const void *a, const void *b)
const struct mem_cgroup_threshold *_a = a;
const struct mem_cgroup_threshold *_b = b;
- return _a->threshold - _b->threshold;
+ if (_a->threshold > _b->threshold)
+ return 1;
+ if (_a->threshold < _b->threshold)
+ return -1;
+ return 0;
static int mem_cgroup_oom_notify_cb(struct mem_cgroup *memcg)
More information about the kernel-team