提交 bd1e22b8 编写于 作者: A Andrew Morton 提交者: Linus Torvalds

[PATCH] initialise total_memory() earlier

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: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 e0a42726
...@@ -185,6 +185,7 @@ extern unsigned long try_to_free_pages(struct zone **, gfp_t); ...@@ -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 unsigned long shrink_all_memory(unsigned long nr_pages);
extern int vm_swappiness; extern int vm_swappiness;
extern int remove_mapping(struct address_space *mapping, struct page *page); extern int remove_mapping(struct address_space *mapping, struct page *page);
extern long vm_total_pages;
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
extern int zone_reclaim_mode; extern int zone_reclaim_mode;
......
...@@ -1725,9 +1725,9 @@ void __meminit build_all_zonelists(void) ...@@ -1725,9 +1725,9 @@ void __meminit build_all_zonelists(void)
stop_machine_run(__build_all_zonelists, NULL, NR_CPUS); stop_machine_run(__build_all_zonelists, NULL, NR_CPUS);
/* cpuset refresh routine should be here */ /* cpuset refresh routine should be here */
} }
vm_total_pages = nr_free_pagecache_pages();
printk("Built %i zonelists\n", num_online_nodes()); printk("Built %i zonelists. Total pages: %ld\n",
num_online_nodes(), vm_total_pages);
} }
/* /*
......
...@@ -110,7 +110,7 @@ struct shrinker { ...@@ -110,7 +110,7 @@ struct shrinker {
* From 0 .. 100. Higher means more swappy. * From 0 .. 100. Higher means more swappy.
*/ */
int vm_swappiness = 60; 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 LIST_HEAD(shrinker_list);
static DECLARE_RWSEM(shrinker_rwsem); static DECLARE_RWSEM(shrinker_rwsem);
...@@ -743,7 +743,7 @@ static void shrink_active_list(unsigned long nr_pages, struct zone *zone, ...@@ -743,7 +743,7 @@ static void shrink_active_list(unsigned long nr_pages, struct zone *zone,
* how much memory * how much memory
* is mapped. * 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 * Now decide how much we really want to unmap some pages. The
...@@ -1482,7 +1482,6 @@ static int __init kswapd_init(void) ...@@ -1482,7 +1482,6 @@ static int __init kswapd_init(void)
pgdat->kswapd = find_task_by_pid(pid); pgdat->kswapd = find_task_by_pid(pid);
read_unlock(&tasklist_lock); read_unlock(&tasklist_lock);
} }
total_memory = nr_free_pagecache_pages();
hotcpu_notifier(cpu_callback, 0); hotcpu_notifier(cpu_callback, 0);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册