Commit 4d1c6273 authored by Daisuke Nishimura's avatar Daisuke Nishimura Committed by Linus Torvalds

memcg: make oom less frequently

In previous implementation, mem_cgroup_try_charge checked the return
value of mem_cgroup_try_to_free_pages, and just retried if some pages
had been reclaimed.
But now, try_charge(and mem_cgroup_hierarchical_reclaim called from it)
only checks whether the usage is less than the limit.

This patch tries to change the behavior as before to cause oom less
frequently.
Signed-off-by: default avatarDaisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Acked-by: default avatarBalbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Pavel Emelyanov <xemul@openvz.org>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Paul Menage <menage@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c268e994
...@@ -773,10 +773,10 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem, ...@@ -773,10 +773,10 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem,
* but there might be left over accounting, even after children * but there might be left over accounting, even after children
* have left. * have left.
*/ */
ret = try_to_free_mem_cgroup_pages(root_mem, gfp_mask, noswap, ret += try_to_free_mem_cgroup_pages(root_mem, gfp_mask, noswap,
get_swappiness(root_mem)); get_swappiness(root_mem));
if (mem_cgroup_check_under_limit(root_mem)) if (mem_cgroup_check_under_limit(root_mem))
return 0; return 1; /* indicate reclaim has succeeded */
if (!root_mem->use_hierarchy) if (!root_mem->use_hierarchy)
return ret; return ret;
...@@ -787,10 +787,10 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem, ...@@ -787,10 +787,10 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem,
next_mem = mem_cgroup_get_next_node(root_mem); next_mem = mem_cgroup_get_next_node(root_mem);
continue; continue;
} }
ret = try_to_free_mem_cgroup_pages(next_mem, gfp_mask, noswap, ret += try_to_free_mem_cgroup_pages(next_mem, gfp_mask, noswap,
get_swappiness(next_mem)); get_swappiness(next_mem));
if (mem_cgroup_check_under_limit(root_mem)) if (mem_cgroup_check_under_limit(root_mem))
return 0; return 1; /* indicate reclaim has succeeded */
next_mem = mem_cgroup_get_next_node(root_mem); next_mem = mem_cgroup_get_next_node(root_mem);
} }
return ret; return ret;
...@@ -875,6 +875,8 @@ static int __mem_cgroup_try_charge(struct mm_struct *mm, ...@@ -875,6 +875,8 @@ static int __mem_cgroup_try_charge(struct mm_struct *mm,
ret = mem_cgroup_hierarchical_reclaim(mem_over_limit, gfp_mask, ret = mem_cgroup_hierarchical_reclaim(mem_over_limit, gfp_mask,
noswap); noswap);
if (ret)
continue;
/* /*
* try_to_free_mem_cgroup_pages() might not give us a full * try_to_free_mem_cgroup_pages() might not give us a full
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment