Commit 46a84132 authored by Jiang Liu's avatar Jiang Liu Committed by Linus Torvalds

mm/x86: prepare for removing num_physpages and simplify mem_init()

Prepare for removing num_physpages and simplify mem_init().
Signed-off-by: default avatarJiang Liu <jiang.liu@huawei.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Andreas Herrmann <andreas.herrmann3@amd.com>
Cc: Tang Chen <tangchen@cn.fujitsu.com>
Cc: Wen Congyang <wency@cn.fujitsu.com>
Cc: Jianguo Wu <wujianguo@huawei.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 0d0b6d26
...@@ -90,7 +90,7 @@ static void __cpuinit init_amd_k5(struct cpuinfo_x86 *c) ...@@ -90,7 +90,7 @@ static void __cpuinit init_amd_k5(struct cpuinfo_x86 *c)
static void __cpuinit init_amd_k6(struct cpuinfo_x86 *c) static void __cpuinit init_amd_k6(struct cpuinfo_x86 *c)
{ {
u32 l, h; u32 l, h;
int mbytes = num_physpages >> (20-PAGE_SHIFT); int mbytes = get_num_physpages() >> (20-PAGE_SHIFT);
if (c->x86_model < 6) { if (c->x86_model < 6) {
/* Based on AMD doc 20734R - June 2000 */ /* Based on AMD doc 20734R - June 2000 */
......
...@@ -1040,8 +1040,6 @@ void __init setup_arch(char **cmdline_p) ...@@ -1040,8 +1040,6 @@ void __init setup_arch(char **cmdline_p)
/* max_low_pfn get updated here */ /* max_low_pfn get updated here */
find_low_pfn_range(); find_low_pfn_range();
#else #else
num_physpages = max_pfn;
check_x2apic(); check_x2apic();
/* How many end-of-memory variables you have, grandma! */ /* How many end-of-memory variables you have, grandma! */
......
...@@ -660,10 +660,8 @@ void __init initmem_init(void) ...@@ -660,10 +660,8 @@ void __init initmem_init(void)
highstart_pfn = max_low_pfn; highstart_pfn = max_low_pfn;
printk(KERN_NOTICE "%ldMB HIGHMEM available.\n", printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
pages_to_mb(highend_pfn - highstart_pfn)); pages_to_mb(highend_pfn - highstart_pfn));
num_physpages = highend_pfn;
high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1; high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
#else #else
num_physpages = max_low_pfn;
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1; high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
#endif #endif
...@@ -671,7 +669,7 @@ void __init initmem_init(void) ...@@ -671,7 +669,7 @@ void __init initmem_init(void)
sparse_memory_present_with_active_regions(0); sparse_memory_present_with_active_regions(0);
#ifdef CONFIG_FLATMEM #ifdef CONFIG_FLATMEM
max_mapnr = num_physpages; max_mapnr = IS_ENABLED(CONFIG_HIGHMEM) ? highend_pfn : max_low_pfn;
#endif #endif
__vmalloc_start_set = true; __vmalloc_start_set = true;
...@@ -739,9 +737,6 @@ static void __init test_wp_bit(void) ...@@ -739,9 +737,6 @@ static void __init test_wp_bit(void)
void __init mem_init(void) void __init mem_init(void)
{ {
int codesize, reservedpages, datasize, initsize;
int tmp;
pci_iommu_alloc(); pci_iommu_alloc();
#ifdef CONFIG_FLATMEM #ifdef CONFIG_FLATMEM
...@@ -761,30 +756,9 @@ void __init mem_init(void) ...@@ -761,30 +756,9 @@ void __init mem_init(void)
/* this will put all low memory onto the freelists */ /* this will put all low memory onto the freelists */
free_all_bootmem(); free_all_bootmem();
reservedpages = 0;
for (tmp = 0; tmp < max_low_pfn; tmp++)
/*
* Only count reserved RAM pages:
*/
if (page_is_ram(tmp) && PageReserved(pfn_to_page(tmp)))
reservedpages++;
after_bootmem = 1; after_bootmem = 1;
codesize = (unsigned long) &_etext - (unsigned long) &_text; mem_init_print_info(NULL);
datasize = (unsigned long) &_edata - (unsigned long) &_etext;
initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
"%dk reserved, %dk data, %dk init, %ldk highmem)\n",
nr_free_pages() << (PAGE_SHIFT-10),
num_physpages << (PAGE_SHIFT-10),
codesize >> 10,
reservedpages << (PAGE_SHIFT-10),
datasize >> 10,
initsize >> 10,
totalhigh_pages << (PAGE_SHIFT-10));
printk(KERN_INFO "virtual kernel memory layout:\n" printk(KERN_INFO "virtual kernel memory layout:\n"
" fixmap : 0x%08lx - 0x%08lx (%4ld kB)\n" " fixmap : 0x%08lx - 0x%08lx (%4ld kB)\n"
#ifdef CONFIG_HIGHMEM #ifdef CONFIG_HIGHMEM
......
...@@ -1044,9 +1044,6 @@ static void __init register_page_bootmem_info(void) ...@@ -1044,9 +1044,6 @@ static void __init register_page_bootmem_info(void)
void __init mem_init(void) void __init mem_init(void)
{ {
long codesize, reservedpages, datasize, initsize;
unsigned long absent_pages;
pci_iommu_alloc(); pci_iommu_alloc();
/* clear_bss() already clear the empty_zero_page */ /* clear_bss() already clear the empty_zero_page */
...@@ -1055,28 +1052,13 @@ void __init mem_init(void) ...@@ -1055,28 +1052,13 @@ void __init mem_init(void)
/* this will put all memory onto the freelists */ /* this will put all memory onto the freelists */
free_all_bootmem(); free_all_bootmem();
absent_pages = absent_pages_in_range(0, max_pfn);
reservedpages = max_pfn - totalram_pages - absent_pages;
after_bootmem = 1; after_bootmem = 1;
codesize = (unsigned long) &_etext - (unsigned long) &_text;
datasize = (unsigned long) &_edata - (unsigned long) &_etext;
initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
/* Register memory areas for /proc/kcore */ /* Register memory areas for /proc/kcore */
kclist_add(&kcore_vsyscall, (void *)VSYSCALL_START, kclist_add(&kcore_vsyscall, (void *)VSYSCALL_START,
VSYSCALL_END - VSYSCALL_START, KCORE_OTHER); VSYSCALL_END - VSYSCALL_START, KCORE_OTHER);
printk(KERN_INFO "Memory: %luk/%luk available (%ldk kernel code, " mem_init_print_info(NULL);
"%ldk absent, %ldk reserved, %ldk data, %ldk init)\n",
nr_free_pages() << (PAGE_SHIFT-10),
max_pfn << (PAGE_SHIFT-10),
codesize >> 10,
absent_pages << (PAGE_SHIFT-10),
reservedpages << (PAGE_SHIFT-10),
datasize >> 10,
initsize >> 10);
} }
#ifdef CONFIG_DEBUG_RODATA #ifdef CONFIG_DEBUG_RODATA
......
...@@ -83,10 +83,8 @@ void __init initmem_init(void) ...@@ -83,10 +83,8 @@ void __init initmem_init(void)
highstart_pfn = max_low_pfn; highstart_pfn = max_low_pfn;
printk(KERN_NOTICE "%ldMB HIGHMEM available.\n", printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
pages_to_mb(highend_pfn - highstart_pfn)); pages_to_mb(highend_pfn - highstart_pfn));
num_physpages = highend_pfn;
high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1; high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
#else #else
num_physpages = max_low_pfn;
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1; high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
#endif #endif
printk(KERN_NOTICE "%ldMB LOWMEM available.\n", printk(KERN_NOTICE "%ldMB LOWMEM available.\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment