page-allocator: add inactive ratio calculation function of each zone
authorMinchan Kim <minchan.kim@gmail.com>
Tue, 16 Jun 2009 22:32:49 +0000 (15:32 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 17 Jun 2009 02:47:42 +0000 (19:47 -0700)
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>
include/linux/mm.h
mm/page_alloc.c

index 6e11cda1ba0208854bf14a97a1c9c44d4a500467..f0473a88ca2e0a220a2557b2be2bbdd3d26ce488 100644 (file)
@@ -1053,6 +1053,7 @@ extern void set_dma_reserve(unsigned long new_dma_reserve);
 extern void memmap_init_zone(unsigned long, int, unsigned long,
                                unsigned long, enum memmap_context);
 extern void setup_per_zone_wmarks(void);
+extern void calculate_zone_inactive_ratio(struct zone *zone);
 extern void mem_init(void);
 extern void __init mmap_init(void);
 extern void show_mem(void);
index 8629c84fd9ba1f4b7ad00b24242bef6d6813edeb..303607f1d323a2eb830d418c7892da777d1f2ce1 100644 (file)
@@ -4478,22 +4478,26 @@ void setup_per_zone_wmarks(void)
  *    1TB     101        10GB
  *   10TB     320        32GB
  */
-static void __init setup_per_zone_inactive_ratio(void)
+void calculate_zone_inactive_ratio(struct zone *zone)
 {
-       struct zone *zone;
+       unsigned int gb, ratio;
 
-       for_each_zone(zone) {
-               unsigned int gb, ratio;
+       /* Zone size in gigabytes */
+       gb = zone->present_pages >> (30 - PAGE_SHIFT);
+       if (gb)
+               ratio = int_sqrt(10 * gb);
+       else
+               ratio = 1;
 
-               /* Zone size in gigabytes */
-               gb = zone->present_pages >> (30 - PAGE_SHIFT);
-               if (gb)
-                       ratio = int_sqrt(10 * gb);
-               else
-                       ratio = 1;
+       zone->inactive_ratio = ratio;
+}
 
-               zone->inactive_ratio = ratio;
-       }
+static void __init setup_per_zone_inactive_ratio(void)
+{
+       struct zone *zone;
+
+       for_each_zone(zone)
+               calculate_zone_inactive_ratio(zone);
 }
 
 /*