diff options
author | KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> | 2008-02-07 03:14:33 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-07 11:42:21 -0500 |
commit | 5932f3671bb2dd873c5ac443cbf5dc2cd167ae94 (patch) | |
tree | 31e2a8fc80487b5ec80d7730c61b62127aebc15d | |
parent | 58ae83db2a40dea15d4277d499a11dadc823c388 (diff) |
per-zone and reclaim enhancements for memory controller: calculate active/inactive imbalance per cgroup
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Balbir Singh <balbir@linux.vnet.ibm.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Herbert Poetzl <herbert@13thfloor.at>
Cc: Kirill Korotaev <dev@sw.ru>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: Paul Menage <menage@google.com>
Cc: Pavel Emelianov <xemul@openvz.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
Cc: Rik van Riel <riel@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/memcontrol.h | 8 | ||||
-rw-r--r-- | mm/memcontrol.c | 14 |
2 files changed, 22 insertions, 0 deletions
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 085cdcd817b0..bb9c079eeb0c 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h | |||
@@ -68,6 +68,8 @@ extern void mem_cgroup_page_migration(struct page *page, struct page *newpage); | |||
68 | * For memory reclaim. | 68 | * For memory reclaim. |
69 | */ | 69 | */ |
70 | extern int mem_cgroup_calc_mapped_ratio(struct mem_cgroup *mem); | 70 | extern int mem_cgroup_calc_mapped_ratio(struct mem_cgroup *mem); |
71 | extern long mem_cgroup_reclaim_imbalance(struct mem_cgroup *mem); | ||
72 | |||
71 | 73 | ||
72 | 74 | ||
73 | #else /* CONFIG_CGROUP_MEM_CONT */ | 75 | #else /* CONFIG_CGROUP_MEM_CONT */ |
@@ -145,6 +147,12 @@ static inline int mem_cgroup_calc_mapped_ratio(struct mem_cgroup *mem) | |||
145 | { | 147 | { |
146 | return 0; | 148 | return 0; |
147 | } | 149 | } |
150 | |||
151 | static inline int mem_cgroup_reclaim_imbalance(struct mem_cgroup *mem) | ||
152 | { | ||
153 | return 0; | ||
154 | } | ||
155 | |||
148 | #endif /* CONFIG_CGROUP_MEM_CONT */ | 156 | #endif /* CONFIG_CGROUP_MEM_CONT */ |
149 | 157 | ||
150 | #endif /* _LINUX_MEMCONTROL_H */ | 158 | #endif /* _LINUX_MEMCONTROL_H */ |
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 2ef214ed5cf8..78a928d90267 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -436,6 +436,20 @@ int mem_cgroup_calc_mapped_ratio(struct mem_cgroup *mem) | |||
436 | rss = (long)mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS); | 436 | rss = (long)mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS); |
437 | return (int)((rss * 100L) / total); | 437 | return (int)((rss * 100L) / total); |
438 | } | 438 | } |
439 | /* | ||
440 | * This function is called from vmscan.c. In page reclaiming loop. balance | ||
441 | * between active and inactive list is calculated. For memory controller | ||
442 | * page reclaiming, we should use using mem_cgroup's imbalance rather than | ||
443 | * zone's global lru imbalance. | ||
444 | */ | ||
445 | long mem_cgroup_reclaim_imbalance(struct mem_cgroup *mem) | ||
446 | { | ||
447 | unsigned long active, inactive; | ||
448 | /* active and inactive are the number of pages. 'long' is ok.*/ | ||
449 | active = mem_cgroup_get_all_zonestat(mem, MEM_CGROUP_ZSTAT_ACTIVE); | ||
450 | inactive = mem_cgroup_get_all_zonestat(mem, MEM_CGROUP_ZSTAT_INACTIVE); | ||
451 | return (long) (active / (inactive + 1)); | ||
452 | } | ||
439 | 453 | ||
440 | unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, | 454 | unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, |
441 | struct list_head *dst, | 455 | struct list_head *dst, |