]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.0.1/memcg-fix-behavior-of-mem_cgroup_resize_limit.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.0.1 / memcg-fix-behavior-of-mem_cgroup_resize_limit.patch
1 From 108b6a78463bb8c7163e4f9779f36ad8bbade334 Mon Sep 17 00:00:00 2001
2 From: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
3 Date: Tue, 26 Jul 2011 16:08:25 -0700
4 Subject: memcg: fix behavior of mem_cgroup_resize_limit()
5
6 From: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
7
8 commit 108b6a78463bb8c7163e4f9779f36ad8bbade334 upstream.
9
10 Commit 22a668d7c3ef ("memcg: fix behavior under memory.limit equals to
11 memsw.limit") introduced "memsw_is_minimum" flag, which becomes true
12 when mem_limit == memsw_limit. The flag is checked at the beginning of
13 reclaim, and "noswap" is set if the flag is true, because using swap is
14 meaningless in this case.
15
16 This works well in most cases, but when we try to shrink mem_limit,
17 which is the same as memsw_limit now, we might fail to shrink mem_limit
18 because swap doesn't used.
19
20 This patch fixes this behavior by:
21 - check MEM_CGROUP_RECLAIM_SHRINK at the begining of reclaim
22 - If it is set, don't set "noswap" flag even if memsw_is_minimum is true.
23
24 Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
25 Cc: Balbir Singh <bsingharora@gmail.com>
26 Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
27 Cc: Michal Hocko <mhocko@suse.cz>
28 Cc: Ying Han <yinghan@google.com>
29 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
30 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
31 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
32
33 ---
34 mm/memcontrol.c | 2 +-
35 1 file changed, 1 insertion(+), 1 deletion(-)
36
37 --- a/mm/memcontrol.c
38 +++ b/mm/memcontrol.c
39 @@ -1730,7 +1730,7 @@ static int mem_cgroup_hierarchical_recla
40 excess = res_counter_soft_limit_excess(&root_mem->res) >> PAGE_SHIFT;
41
42 /* If memsw_is_minimum==1, swap-out is of-no-use. */
43 - if (!check_soft && root_mem->memsw_is_minimum)
44 + if (!check_soft && !shrink && root_mem->memsw_is_minimum)
45 noswap = true;
46
47 while (1) {