aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
authorKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>2009-12-15 19:47:09 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-16 10:20:07 -0500
commitd8046582d5ee24448800e71c6933fdb6813aa062 (patch)
tree857d014a850deee5ddb6da6550d81ce0122f03b1 /mm/memcontrol.c
parentcdec2e4265dfa09490601b00aeabd8a8d4af30f0 (diff)
memcg: make memcg's file mapped consistent with global VM
In global VM, FILE_MAPPED is used but memcg uses MAPPED_FILE. This makes grep difficult. Replace memcg's MAPPED_FILE with FILE_MAPPED And in global VM, mapped shared memory is accounted into FILE_MAPPED. But memcg doesn't. fix it. Note: page_is_file_cache() just checks SwapBacked or not. So, we need to check PageAnon. Cc: Balbir Singh <balbir@in.ibm.com> Reviewed-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r--mm/memcontrol.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 6587f657d57c..0b3efb843a87 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -67,7 +67,7 @@ enum mem_cgroup_stat_index {
67 */ 67 */
68 MEM_CGROUP_STAT_CACHE, /* # of pages charged as cache */ 68 MEM_CGROUP_STAT_CACHE, /* # of pages charged as cache */
69 MEM_CGROUP_STAT_RSS, /* # of pages charged as anon rss */ 69 MEM_CGROUP_STAT_RSS, /* # of pages charged as anon rss */
70 MEM_CGROUP_STAT_MAPPED_FILE, /* # of pages charged as file rss */ 70 MEM_CGROUP_STAT_FILE_MAPPED, /* # of pages charged as file rss */
71 MEM_CGROUP_STAT_PGPGIN_COUNT, /* # of pages paged in */ 71 MEM_CGROUP_STAT_PGPGIN_COUNT, /* # of pages paged in */
72 MEM_CGROUP_STAT_PGPGOUT_COUNT, /* # of pages paged out */ 72 MEM_CGROUP_STAT_PGPGOUT_COUNT, /* # of pages paged out */
73 MEM_CGROUP_STAT_EVENTS, /* sum of pagein + pageout for internal use */ 73 MEM_CGROUP_STAT_EVENTS, /* sum of pagein + pageout for internal use */
@@ -1227,7 +1227,7 @@ static void record_last_oom(struct mem_cgroup *mem)
1227 * Currently used to update mapped file statistics, but the routine can be 1227 * Currently used to update mapped file statistics, but the routine can be
1228 * generalized to update other statistics as well. 1228 * generalized to update other statistics as well.
1229 */ 1229 */
1230void mem_cgroup_update_mapped_file_stat(struct page *page, int val) 1230void mem_cgroup_update_file_mapped(struct page *page, int val)
1231{ 1231{
1232 struct mem_cgroup *mem; 1232 struct mem_cgroup *mem;
1233 struct mem_cgroup_stat *stat; 1233 struct mem_cgroup_stat *stat;
@@ -1235,9 +1235,6 @@ void mem_cgroup_update_mapped_file_stat(struct page *page, int val)
1235 int cpu; 1235 int cpu;
1236 struct page_cgroup *pc; 1236 struct page_cgroup *pc;
1237 1237
1238 if (!page_is_file_cache(page))
1239 return;
1240
1241 pc = lookup_page_cgroup(page); 1238 pc = lookup_page_cgroup(page);
1242 if (unlikely(!pc)) 1239 if (unlikely(!pc))
1243 return; 1240 return;
@@ -1257,7 +1254,7 @@ void mem_cgroup_update_mapped_file_stat(struct page *page, int val)
1257 stat = &mem->stat; 1254 stat = &mem->stat;
1258 cpustat = &stat->cpustat[cpu]; 1255 cpustat = &stat->cpustat[cpu];
1259 1256
1260 __mem_cgroup_stat_add_safe(cpustat, MEM_CGROUP_STAT_MAPPED_FILE, val); 1257 __mem_cgroup_stat_add_safe(cpustat, MEM_CGROUP_STAT_FILE_MAPPED, val);
1261done: 1258done:
1262 unlock_page_cgroup(pc); 1259 unlock_page_cgroup(pc);
1263} 1260}
@@ -1654,18 +1651,18 @@ static int mem_cgroup_move_account(struct page_cgroup *pc,
1654 mem_cgroup_charge_statistics(from, pc, false); 1651 mem_cgroup_charge_statistics(from, pc, false);
1655 1652
1656 page = pc->page; 1653 page = pc->page;
1657 if (page_is_file_cache(page) && page_mapped(page)) { 1654 if (page_mapped(page) && !PageAnon(page)) {
1658 cpu = smp_processor_id(); 1655 cpu = smp_processor_id();
1659 /* Update mapped_file data for mem_cgroup "from" */ 1656 /* Update mapped_file data for mem_cgroup "from" */
1660 stat = &from->stat; 1657 stat = &from->stat;
1661 cpustat = &stat->cpustat[cpu]; 1658 cpustat = &stat->cpustat[cpu];
1662 __mem_cgroup_stat_add_safe(cpustat, MEM_CGROUP_STAT_MAPPED_FILE, 1659 __mem_cgroup_stat_add_safe(cpustat, MEM_CGROUP_STAT_FILE_MAPPED,
1663 -1); 1660 -1);
1664 1661
1665 /* Update mapped_file data for mem_cgroup "to" */ 1662 /* Update mapped_file data for mem_cgroup "to" */
1666 stat = &to->stat; 1663 stat = &to->stat;
1667 cpustat = &stat->cpustat[cpu]; 1664 cpustat = &stat->cpustat[cpu];
1668 __mem_cgroup_stat_add_safe(cpustat, MEM_CGROUP_STAT_MAPPED_FILE, 1665 __mem_cgroup_stat_add_safe(cpustat, MEM_CGROUP_STAT_FILE_MAPPED,
1669 1); 1666 1);
1670 } 1667 }
1671 1668
@@ -2889,7 +2886,7 @@ static int mem_cgroup_reset(struct cgroup *cont, unsigned int event)
2889enum { 2886enum {
2890 MCS_CACHE, 2887 MCS_CACHE,
2891 MCS_RSS, 2888 MCS_RSS,
2892 MCS_MAPPED_FILE, 2889 MCS_FILE_MAPPED,
2893 MCS_PGPGIN, 2890 MCS_PGPGIN,
2894 MCS_PGPGOUT, 2891 MCS_PGPGOUT,
2895 MCS_SWAP, 2892 MCS_SWAP,
@@ -2933,8 +2930,8 @@ static int mem_cgroup_get_local_stat(struct mem_cgroup *mem, void *data)
2933 s->stat[MCS_CACHE] += val * PAGE_SIZE; 2930 s->stat[MCS_CACHE] += val * PAGE_SIZE;
2934 val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS); 2931 val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS);
2935 s->stat[MCS_RSS] += val * PAGE_SIZE; 2932 s->stat[MCS_RSS] += val * PAGE_SIZE;
2936 val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_MAPPED_FILE); 2933 val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_FILE_MAPPED);
2937 s->stat[MCS_MAPPED_FILE] += val * PAGE_SIZE; 2934 s->stat[MCS_FILE_MAPPED] += val * PAGE_SIZE;
2938 val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_PGPGIN_COUNT); 2935 val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_PGPGIN_COUNT);
2939 s->stat[MCS_PGPGIN] += val; 2936 s->stat[MCS_PGPGIN] += val;
2940 val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_PGPGOUT_COUNT); 2937 val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_PGPGOUT_COUNT);