aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>2009-01-07 21:08:35 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-08 11:31:10 -0500
commitb5a84319a4343a0db753436fd8147e61eaafa7ea (patch)
tree5faae671b431b50a32a2d8c7a57cc9361d8f336d /include/linux
parent544122e5e0ee27d5aac4a441f7746712afbf248c (diff)
memcg: fix shmem's swap accounting
Now, you can see following even when swap accounting is enabled. 1. Create Group 01, and 02. 2. allocate a "file" on tmpfs by a task under 01. 3. swap out the "file" (by memory pressure) 4. Read "file" from a task in group 02. 5. the charge of "file" is moved to group 02. This is not ideal behavior. This is because SwapCache which was loaded by read-ahead is not taken into account.. This is a patch to fix shmem's swapcache behavior. - remove mem_cgroup_cache_charge_swapin(). - Add SwapCache handler routine to mem_cgroup_cache_charge(). By this, shmem's file cache is charged at add_to_page_cache() with GFP_NOWAIT. - pass the page of swapcache to shrink_mem_cgroup. Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> Cc: Balbir Singh <balbir@in.ibm.com> Cc: Paul Menage <menage@google.com> Cc: Li Zefan <lizf@cn.fujitsu.com> Cc: 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 'include/linux')
-rw-r--r--include/linux/memcontrol.h6
-rw-r--r--include/linux/swap.h8
2 files changed, 4 insertions, 10 deletions
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 8ae6ece8c962..326f45c86530 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -56,7 +56,8 @@ extern void mem_cgroup_move_lists(struct page *page,
56 enum lru_list from, enum lru_list to); 56 enum lru_list from, enum lru_list to);
57extern void mem_cgroup_uncharge_page(struct page *page); 57extern void mem_cgroup_uncharge_page(struct page *page);
58extern void mem_cgroup_uncharge_cache_page(struct page *page); 58extern void mem_cgroup_uncharge_cache_page(struct page *page);
59extern int mem_cgroup_shrink_usage(struct mm_struct *mm, gfp_t gfp_mask); 59extern int mem_cgroup_shrink_usage(struct page *page,
60 struct mm_struct *mm, gfp_t gfp_mask);
60 61
61extern unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, 62extern unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
62 struct list_head *dst, 63 struct list_head *dst,
@@ -155,7 +156,8 @@ static inline void mem_cgroup_uncharge_cache_page(struct page *page)
155{ 156{
156} 157}
157 158
158static inline int mem_cgroup_shrink_usage(struct mm_struct *mm, gfp_t gfp_mask) 159static inline int mem_cgroup_shrink_usage(struct page *page,
160 struct mm_struct *mm, gfp_t gfp_mask)
159{ 161{
160 return 0; 162 return 0;
161} 163}
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 4ccca25d0f05..d30215578877 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -335,16 +335,8 @@ static inline void disable_swap_token(void)
335} 335}
336 336
337#ifdef CONFIG_CGROUP_MEM_RES_CTLR 337#ifdef CONFIG_CGROUP_MEM_RES_CTLR
338extern int mem_cgroup_cache_charge_swapin(struct page *page,
339 struct mm_struct *mm, gfp_t mask, bool locked);
340extern void mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent); 338extern void mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent);
341#else 339#else
342static inline
343int mem_cgroup_cache_charge_swapin(struct page *page,
344 struct mm_struct *mm, gfp_t mask, bool locked)
345{
346 return 0;
347}
348static inline void 340static inline void
349mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent) 341mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent)
350{ 342{