aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
authorKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>2009-01-07 21:08:20 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-08 11:31:08 -0500
commit3e2f41f1f64744f7942980d93cc93dd3e5924560 (patch)
tree7b605c407b7470877fd9c5c853407f75edcbeb49 /mm/memcontrol.c
parenta3d8e0549d913e30968fa02e505dfe02c0a23e0d (diff)
memcg: add zone_reclaim_stat
Introduce mem_cgroup_per_zone::reclaim_stat member and its statics collecting function. Now, get_scan_ratio() can calculate correct value on memcg reclaim. [hugh@veritas.com: avoid reclaim_stat oops when disabled] Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Acked-by: Rik van Riel <riel@redhat.com> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: Balbir Singh <balbir@in.ibm.com> Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> Cc: Hugh Dickins <hugh@veritas.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.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/memcontrol.c')
-rw-r--r--mm/memcontrol.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 313247e6c503..7b7f4dc05035 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -103,6 +103,8 @@ struct mem_cgroup_per_zone {
103 */ 103 */
104 struct list_head lists[NR_LRU_LISTS]; 104 struct list_head lists[NR_LRU_LISTS];
105 unsigned long count[NR_LRU_LISTS]; 105 unsigned long count[NR_LRU_LISTS];
106
107 struct zone_reclaim_stat reclaim_stat;
106}; 108};
107/* Macro for accessing counter */ 109/* Macro for accessing counter */
108#define MEM_CGROUP_ZSTAT(mz, idx) ((mz)->count[(idx)]) 110#define MEM_CGROUP_ZSTAT(mz, idx) ((mz)->count[(idx)])
@@ -458,6 +460,33 @@ unsigned long mem_cgroup_zone_nr_pages(struct mem_cgroup *memcg,
458 return MEM_CGROUP_ZSTAT(mz, lru); 460 return MEM_CGROUP_ZSTAT(mz, lru);
459} 461}
460 462
463struct zone_reclaim_stat *mem_cgroup_get_reclaim_stat(struct mem_cgroup *memcg,
464 struct zone *zone)
465{
466 int nid = zone->zone_pgdat->node_id;
467 int zid = zone_idx(zone);
468 struct mem_cgroup_per_zone *mz = mem_cgroup_zoneinfo(memcg, nid, zid);
469
470 return &mz->reclaim_stat;
471}
472
473struct zone_reclaim_stat *
474mem_cgroup_get_reclaim_stat_from_page(struct page *page)
475{
476 struct page_cgroup *pc;
477 struct mem_cgroup_per_zone *mz;
478
479 if (mem_cgroup_disabled())
480 return NULL;
481
482 pc = lookup_page_cgroup(page);
483 mz = page_cgroup_zoneinfo(pc);
484 if (!mz)
485 return NULL;
486
487 return &mz->reclaim_stat;
488}
489
461unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, 490unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
462 struct list_head *dst, 491 struct list_head *dst,
463 unsigned long *scanned, int order, 492 unsigned long *scanned, int order,