aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/sparc64/mm/init.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c
index 40276189c107..cafadcbcdf38 100644
--- a/arch/sparc64/mm/init.c
+++ b/arch/sparc64/mm/init.c
@@ -938,6 +938,20 @@ static void __init trim_pavail(unsigned long *cur_size_p,
938 } 938 }
939} 939}
940 940
941/* About pages_avail, this is the value we will use to calculate
942 * the zholes_size[] argument given to free_area_init_node(). The
943 * page allocator uses this to calculate nr_kernel_pages,
944 * nr_all_pages and zone->present_pages. On NUMA it is used
945 * to calculate zone->min_unmapped_pages and zone->min_slab_pages.
946 *
947 * So this number should really be set to what the page allocator
948 * actually ends up with. This means:
949 * 1) It should include bootmem map pages, we'll release those.
950 * 2) It should not include the kernel image, except for the
951 * __init sections which we will also release.
952 * 3) It should include the initrd image, since we'll release
953 * that too.
954 */
941static unsigned long __init bootmem_init(unsigned long *pages_avail, 955static unsigned long __init bootmem_init(unsigned long *pages_avail,
942 unsigned long phys_base) 956 unsigned long phys_base)
943{ 957{
@@ -1024,7 +1038,6 @@ static unsigned long __init bootmem_init(unsigned long *pages_avail,
1024 initrd_start, initrd_end); 1038 initrd_start, initrd_end);
1025#endif 1039#endif
1026 reserve_bootmem(initrd_start, size); 1040 reserve_bootmem(initrd_start, size);
1027 *pages_avail -= PAGE_ALIGN(size) >> PAGE_SHIFT;
1028 1041
1029 initrd_start += PAGE_OFFSET; 1042 initrd_start += PAGE_OFFSET;
1030 initrd_end += PAGE_OFFSET; 1043 initrd_end += PAGE_OFFSET;
@@ -1037,6 +1050,11 @@ static unsigned long __init bootmem_init(unsigned long *pages_avail,
1037 reserve_bootmem(kern_base, kern_size); 1050 reserve_bootmem(kern_base, kern_size);
1038 *pages_avail -= PAGE_ALIGN(kern_size) >> PAGE_SHIFT; 1051 *pages_avail -= PAGE_ALIGN(kern_size) >> PAGE_SHIFT;
1039 1052
1053 /* Add back in the initmem pages. */
1054 size = ((unsigned long)(__init_end) & PAGE_MASK) -
1055 PAGE_ALIGN((unsigned long)__init_begin);
1056 *pages_avail += size >> PAGE_SHIFT;
1057
1040 /* Reserve the bootmem map. We do not account for it 1058 /* Reserve the bootmem map. We do not account for it
1041 * in pages_avail because we will release that memory 1059 * in pages_avail because we will release that memory
1042 * in free_all_bootmem. 1060 * in free_all_bootmem.
@@ -1047,7 +1065,6 @@ static unsigned long __init bootmem_init(unsigned long *pages_avail,
1047 (bootmap_pfn << PAGE_SHIFT), size); 1065 (bootmap_pfn << PAGE_SHIFT), size);
1048#endif 1066#endif
1049 reserve_bootmem((bootmap_pfn << PAGE_SHIFT), size); 1067 reserve_bootmem((bootmap_pfn << PAGE_SHIFT), size);
1050 *pages_avail -= PAGE_ALIGN(size) >> PAGE_SHIFT;
1051 1068
1052 for (i = 0; i < pavail_ents; i++) { 1069 for (i = 0; i < pavail_ents; i++) {
1053 unsigned long start_pfn, end_pfn; 1070 unsigned long start_pfn, end_pfn;
@@ -1539,6 +1556,10 @@ void __init mem_init(void)
1539#ifdef CONFIG_DEBUG_BOOTMEM 1556#ifdef CONFIG_DEBUG_BOOTMEM
1540 prom_printf("mem_init: Calling free_all_bootmem().\n"); 1557 prom_printf("mem_init: Calling free_all_bootmem().\n");
1541#endif 1558#endif
1559
1560 /* We subtract one to account for the mem_map_zero page
1561 * allocated below.
1562 */
1542 totalram_pages = num_physpages = free_all_bootmem() - 1; 1563 totalram_pages = num_physpages = free_all_bootmem() - 1;
1543 1564
1544 /* 1565 /*