diff options
author | KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> | 2008-07-25 04:47:15 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-25 13:53:37 -0400 |
commit | c9b0ed51483cc2fc42bb801b6675c4231b0e4634 (patch) | |
tree | 1d322b4bfcaad3296752f6efcab918d1b13b50a3 /mm/shmem.c | |
parent | 69029cd550284e32de13d6dd2f77b723c8a0e444 (diff) |
memcg: helper function for relcaim from shmem.
A new call, mem_cgroup_shrink_usage() is added for shmem handling and
relacing non-standard usage of mem_cgroup_charge/uncharge.
Now, shmem calls mem_cgroup_charge() just for reclaim some pages from
mem_cgroup. In general, shmem is used by some process group and not for
global resource (like file caches). So, it's reasonable to reclaim pages
from mem_cgroup where shmem is mainly used.
[hugh@veritas.com: shmem_getpage release page sooner]
[hugh@veritas.com: mem_cgroup_shrink_usage css_put]
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Pavel Emelyanov <xemul@openvz.org>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Cc: Paul Menage <menage@google.com>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/shmem.c')
-rw-r--r-- | mm/shmem.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/mm/shmem.c b/mm/shmem.c index d58305e8a484..f92fea94d037 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
@@ -1315,17 +1315,14 @@ repeat: | |||
1315 | shmem_swp_unmap(entry); | 1315 | shmem_swp_unmap(entry); |
1316 | spin_unlock(&info->lock); | 1316 | spin_unlock(&info->lock); |
1317 | unlock_page(swappage); | 1317 | unlock_page(swappage); |
1318 | page_cache_release(swappage); | ||
1318 | if (error == -ENOMEM) { | 1319 | if (error == -ENOMEM) { |
1319 | /* allow reclaim from this memory cgroup */ | 1320 | /* allow reclaim from this memory cgroup */ |
1320 | error = mem_cgroup_cache_charge(swappage, | 1321 | error = mem_cgroup_shrink_usage(current->mm, |
1321 | current->mm, gfp & ~__GFP_HIGHMEM); | 1322 | gfp); |
1322 | if (error) { | 1323 | if (error) |
1323 | page_cache_release(swappage); | ||
1324 | goto failed; | 1324 | goto failed; |
1325 | } | ||
1326 | mem_cgroup_uncharge_cache_page(swappage); | ||
1327 | } | 1325 | } |
1328 | page_cache_release(swappage); | ||
1329 | goto repeat; | 1326 | goto repeat; |
1330 | } | 1327 | } |
1331 | } else if (sgp == SGP_READ && !filepage) { | 1328 | } else if (sgp == SGP_READ && !filepage) { |