diff options
author | Minchan Kim <minchan.kim@gmail.com> | 2009-06-16 18:32:49 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-16 22:47:42 -0400 |
commit | 96cb4df5ddf5e6d5785b5acd4003e3689b87f896 (patch) | |
tree | e6bd74df480e9065617aebec29b4285fa021c919 | |
parent | bc75d33f0fc1d56e734db1f56d3cfc8097b8e0cf (diff) |
page-allocator: add inactive ratio calculation function of each zone
Factor the per-zone arithemetic inside setup_per_zone_inactive_ratio()'s
loop into a a separate function, calculate_zone_inactive_ratio(). This
function will be used in a later patch
[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Minchan Kim <minchan.kim@gmail.com>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/mm.h | 1 | ||||
-rw-r--r-- | mm/page_alloc.c | 28 |
2 files changed, 17 insertions, 12 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index 6e11cda1ba02..f0473a88ca2e 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -1053,6 +1053,7 @@ extern void set_dma_reserve(unsigned long new_dma_reserve); | |||
1053 | extern void memmap_init_zone(unsigned long, int, unsigned long, | 1053 | extern void memmap_init_zone(unsigned long, int, unsigned long, |
1054 | unsigned long, enum memmap_context); | 1054 | unsigned long, enum memmap_context); |
1055 | extern void setup_per_zone_wmarks(void); | 1055 | extern void setup_per_zone_wmarks(void); |
1056 | extern void calculate_zone_inactive_ratio(struct zone *zone); | ||
1056 | extern void mem_init(void); | 1057 | extern void mem_init(void); |
1057 | extern void __init mmap_init(void); | 1058 | extern void __init mmap_init(void); |
1058 | extern void show_mem(void); | 1059 | extern void show_mem(void); |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 8629c84fd9ba..303607f1d323 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -4478,22 +4478,26 @@ void setup_per_zone_wmarks(void) | |||
4478 | * 1TB 101 10GB | 4478 | * 1TB 101 10GB |
4479 | * 10TB 320 32GB | 4479 | * 10TB 320 32GB |
4480 | */ | 4480 | */ |
4481 | static void __init setup_per_zone_inactive_ratio(void) | 4481 | void calculate_zone_inactive_ratio(struct zone *zone) |
4482 | { | 4482 | { |
4483 | struct zone *zone; | 4483 | unsigned int gb, ratio; |
4484 | 4484 | ||
4485 | for_each_zone(zone) { | 4485 | /* Zone size in gigabytes */ |
4486 | unsigned int gb, ratio; | 4486 | gb = zone->present_pages >> (30 - PAGE_SHIFT); |
4487 | if (gb) | ||
4488 | ratio = int_sqrt(10 * gb); | ||
4489 | else | ||
4490 | ratio = 1; | ||
4487 | 4491 | ||
4488 | /* Zone size in gigabytes */ | 4492 | zone->inactive_ratio = ratio; |
4489 | gb = zone->present_pages >> (30 - PAGE_SHIFT); | 4493 | } |
4490 | if (gb) | ||
4491 | ratio = int_sqrt(10 * gb); | ||
4492 | else | ||
4493 | ratio = 1; | ||
4494 | 4494 | ||
4495 | zone->inactive_ratio = ratio; | 4495 | static void __init setup_per_zone_inactive_ratio(void) |
4496 | } | 4496 | { |
4497 | struct zone *zone; | ||
4498 | |||
4499 | for_each_zone(zone) | ||
4500 | calculate_zone_inactive_ratio(zone); | ||
4497 | } | 4501 | } |
4498 | 4502 | ||
4499 | /* | 4503 | /* |