]> err.no Git - linux-2.6/commitdiff
[PATCH] initialise total_memory() earlier
authorAndrew Morton <akpm@osdl.org>
Fri, 23 Jun 2006 09:03:47 +0000 (02:03 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Fri, 23 Jun 2006 14:42:52 +0000 (07:42 -0700)
Initialise total_memory earlier in boot.  Because if for some reason we run
page reclaim early in boot, we don't want total_memory to be zero when we use
it as a divisor.

And rename total_memory to vm_total_pages to avoid naming clashes with
architectures.

Cc: Yasunori Goto <y-goto@jp.fujitsu.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Martin Bligh <mbligh@google.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
include/linux/swap.h
mm/page_alloc.c
mm/vmscan.c

index f1a827a972e0c1295846caeb1c333cf9524708f3..dc3f3aa0c83e89ec345caac3d4af9fdb1eae35b1 100644 (file)
@@ -185,6 +185,7 @@ extern unsigned long try_to_free_pages(struct zone **, gfp_t);
 extern unsigned long shrink_all_memory(unsigned long nr_pages);
 extern int vm_swappiness;
 extern int remove_mapping(struct address_space *mapping, struct page *page);
+extern long vm_total_pages;
 
 #ifdef CONFIG_NUMA
 extern int zone_reclaim_mode;
index 5af33186a25feb86afd4db40462f74340e09488e..71a0b2a23f5b83c2ec6d7a6f49550208f10fb1ce 100644 (file)
@@ -1725,9 +1725,9 @@ void __meminit build_all_zonelists(void)
                stop_machine_run(__build_all_zonelists, NULL, NR_CPUS);
                /* cpuset refresh routine should be here */
        }
-
-       printk("Built %i zonelists\n", num_online_nodes());
-
+       vm_total_pages = nr_free_pagecache_pages();
+       printk("Built %i zonelists.  Total pages: %ld\n",
+                       num_online_nodes(), vm_total_pages);
 }
 
 /*
index 71a02e2950379626001ea4d7d87f46a875ee7c45..72babac71deaba28f9c75a1b6d2ccacb8ba537fa 100644 (file)
@@ -110,7 +110,7 @@ struct shrinker {
  * From 0 .. 100.  Higher means more swappy.
  */
 int vm_swappiness = 60;
-static long total_memory;
+long vm_total_pages;   /* The total number of pages which the VM controls */
 
 static LIST_HEAD(shrinker_list);
 static DECLARE_RWSEM(shrinker_rwsem);
@@ -743,7 +743,7 @@ static void shrink_active_list(unsigned long nr_pages, struct zone *zone,
                 * how much memory
                 * is mapped.
                 */
-               mapped_ratio = (sc->nr_mapped * 100) / total_memory;
+               mapped_ratio = (sc->nr_mapped * 100) / vm_total_pages;
 
                /*
                 * Now decide how much we really want to unmap some pages.  The
@@ -1482,7 +1482,6 @@ static int __init kswapd_init(void)
                pgdat->kswapd = find_task_by_pid(pid);
                read_unlock(&tasklist_lock);
        }
-       total_memory = nr_free_pagecache_pages();
        hotcpu_notifier(cpu_callback, 0);
        return 0;
 }