memcg: fix mem_cgroup_shrink_usage()

Current mem_cgroup_shrink_usage() has two problems.

1. It doesn't call mem_cgroup_out_of_memory and doesn't update
   last_oom_jiffies, so pagefault_out_of_memory invokes global OOM.

2. Considering hierarchy, shrinking has to be done from the
   mem_over_limit, not from the memcg which the page would be charged to.

mem_cgroup_try_charge_swapin() does all of these things properly, so we
use it and call cancel_charge_swapin when it succeeded.

The name of "shrink_usage" is not appropriate for this behavior, so we
change it too.

Signed-off-by: Daisuke Nishimura <[email protected]>
Acked-by: KAMEZAWA Hiroyuki <[email protected]>
Cc: Li Zefan <[email protected]>
Cc: Paul Menage <[email protected]>
Cc: Dhaval Giani <[email protected]>
Cc: Daisuke Nishimura <[email protected]>
Cc: YAMAMOTO Takashi <[email protected]>
Cc: KOSAKI Motohiro <[email protected]>
Cc: David Rientjes <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
Daisuke Nishimura 2009-04-30 15:08:19 -07:00 • committed by Linus Torvalds
commit ae3abae64f
3 changed files with 20 additions and 25 deletions

View file

@ -1340,8 +1340,12 @@ repeat:
shmem_swp_unmap(entry);
spin_unlock(&info->lock);
if (error == -ENOMEM) {
/* allow reclaim from this memory cgroup */
error = mem_cgroup_shrink_usage(swappage,
/*
* reclaim from proper memory cgroup and
* call memcg's OOM if needed.
*/
error = mem_cgroup_shmem_charge_fallback(
swappage,
current->mm,
gfp);
if (error) {