diff options
author | Balbir Singh <balbir@linux.vnet.ibm.com> | 2009-06-17 19:26:34 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-18 16:03:47 -0400 |
commit | d69b042f3d7406ddba560143b1796020df760800 (patch) | |
tree | 6b704864716240aa1282d06bb79c02ef4b77e16d /mm/rmap.c | |
parent | cd5008196f7e583f4c558531a2bca59f6c674c5b (diff) |
memcg: add file-based RSS accounting
Add file RSS tracking per memory cgroup
We currently don't track file RSS, the RSS we report is actually anon RSS.
All the file mapped pages, come in through the page cache and get
accounted there. This patch adds support for accounting file RSS pages.
It should
1. Help improve the metrics reported by the memory resource controller
2. Will form the basis for a future shared memory accounting heuristic
that has been proposed by Kamezawa.
Unfortunately, we cannot rename the existing "rss" keyword used in
memory.stat to "anon_rss". We however, add "mapped_file" data and hope to
educate the end user through documentation.
[hugh.dickins@tiscali.co.uk: fix mem_cgroup_update_mapped_file_stat oops]
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Li Zefan <lizf@cn.fujitsu.cn>
Cc: Paul Menage <menage@google.com>
Cc: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Cc: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/rmap.c')
-rw-r--r-- | mm/rmap.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -703,8 +703,10 @@ void page_add_new_anon_rmap(struct page *page, | |||
703 | */ | 703 | */ |
704 | void page_add_file_rmap(struct page *page) | 704 | void page_add_file_rmap(struct page *page) |
705 | { | 705 | { |
706 | if (atomic_inc_and_test(&page->_mapcount)) | 706 | if (atomic_inc_and_test(&page->_mapcount)) { |
707 | __inc_zone_page_state(page, NR_FILE_MAPPED); | 707 | __inc_zone_page_state(page, NR_FILE_MAPPED); |
708 | mem_cgroup_update_mapped_file_stat(page, 1); | ||
709 | } | ||
708 | } | 710 | } |
709 | 711 | ||
710 | #ifdef CONFIG_DEBUG_VM | 712 | #ifdef CONFIG_DEBUG_VM |
@@ -753,6 +755,7 @@ void page_remove_rmap(struct page *page) | |||
753 | mem_cgroup_uncharge_page(page); | 755 | mem_cgroup_uncharge_page(page); |
754 | __dec_zone_page_state(page, | 756 | __dec_zone_page_state(page, |
755 | PageAnon(page) ? NR_ANON_PAGES : NR_FILE_MAPPED); | 757 | PageAnon(page) ? NR_ANON_PAGES : NR_FILE_MAPPED); |
758 | mem_cgroup_update_mapped_file_stat(page, -1); | ||
756 | /* | 759 | /* |
757 | * It would be tidy to reset the PageAnon mapping here, | 760 | * It would be tidy to reset the PageAnon mapping here, |
758 | * but that might overwrite a racing page_add_anon_rmap | 761 | * but that might overwrite a racing page_add_anon_rmap |