aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorZou Nan hai <nanhai.zou@intel.com>2007-03-20 16:41:57 -0400
committerTony Luck <tony.luck@intel.com>2007-03-20 16:41:57 -0400
commita3f5c338b9f30f328276739d9589beae19254936 (patch)
tree5c197e9c6565382a548180bdfb57ee5315d9fc60 /arch
parentbe521466feb3bb1cd89de82a2b1d080e9ebd3cb6 (diff)
[IA64] min_low_pfn and max_low_pfn calculation fix
We have seen bad_pte_print when testing crashdump on an SN machine in recent 2.6.20 kernel. There are tons of bad pte print (pfn < max_low_pfn) reports when the crash kernel boots up, all those reported bad pages are inside initmem range; That is because if the crash kernel code and data happens to be at the beginning of the 1st node. build_node_maps in discontig.c will bypass reserved regions with filter_rsvd_memory. Since min_low_pfn is calculated in build_node_map, so in this case, min_low_pfn will be greater than kernel code and data. Because pages inside initmem are freed and reused later, we saw pfn_valid check fail on those pages. I think this theoretically happen on a normal kernel. When I check min_low_pfn and max_low_pfn calculation in contig.c and discontig.c. I found more issues than this. 1. min_low_pfn and max_low_pfn calculation is inconsistent between contig.c and discontig.c, min_low_pfn is calculated as the first page number of boot memmap in contig.c (Why? Though this may work at the most of the time, I don't think it is the right logic). It is calculated as the lowest physical memory page number bypass reserved regions in discontig.c. max_low_pfn is calculated include reserved regions in contig.c. It is calculated exclude reserved regions in discontig.c. 2. If kernel code and data region is happen to be at the begin or the end of physical memory, when min_low_pfn and max_low_pfn calculation is bypassed kernel code and data, pages in initmem will report bad. 3. initrd is also in reserved regions, if it is at the begin or at the end of physical memory, kernel will refuse to reuse the memory. Because the virt_addr_valid check in free_initrd_mem. So it is better to fix and clean up those issues. Calculate min_low_pfn and max_low_pfn in a consistent way. Signed-off-by: Zou Nan hai <nanhai.zou@intel.com> Acked-by: Jay Lan <jlan@sgi.com> Signed-off-by: Tony Luck <tony.luck@intel.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/ia64/mm/contig.c30
-rw-r--r--arch/ia64/mm/discontig.c4
-rw-r--r--arch/ia64/mm/init.c16
3 files changed, 23 insertions, 27 deletions
diff --git a/arch/ia64/mm/contig.c b/arch/ia64/mm/contig.c
index fb0f4698f5d0..44ce5ed9444c 100644
--- a/arch/ia64/mm/contig.c
+++ b/arch/ia64/mm/contig.c
@@ -97,26 +97,6 @@ void show_mem(void)
97unsigned long bootmap_start; 97unsigned long bootmap_start;
98 98
99/** 99/**
100 * find_max_pfn - adjust the maximum page number callback
101 * @start: start of range
102 * @end: end of range
103 * @arg: address of pointer to global max_pfn variable
104 *
105 * Passed as a callback function to efi_memmap_walk() to determine the highest
106 * available page frame number in the system.
107 */
108int
109find_max_pfn (unsigned long start, unsigned long end, void *arg)
110{
111 unsigned long *max_pfnp = arg, pfn;
112
113 pfn = (PAGE_ALIGN(end - 1) - PAGE_OFFSET) >> PAGE_SHIFT;
114 if (pfn > *max_pfnp)
115 *max_pfnp = pfn;
116 return 0;
117}
118
119/**
120 * find_bootmap_location - callback to find a memory area for the bootmap 100 * find_bootmap_location - callback to find a memory area for the bootmap
121 * @start: start of region 101 * @start: start of region
122 * @end: end of region 102 * @end: end of region
@@ -177,9 +157,10 @@ find_memory (void)
177 reserve_memory(); 157 reserve_memory();
178 158
179 /* first find highest page frame number */ 159 /* first find highest page frame number */
180 max_pfn = 0; 160 min_low_pfn = ~0UL;
181 efi_memmap_walk(find_max_pfn, &max_pfn); 161 max_low_pfn = 0;
182 162 efi_memmap_walk(find_max_min_low_pfn, NULL);
163 max_pfn = max_low_pfn;
183 /* how many bytes to cover all the pages */ 164 /* how many bytes to cover all the pages */
184 bootmap_size = bootmem_bootmap_pages(max_pfn) << PAGE_SHIFT; 165 bootmap_size = bootmem_bootmap_pages(max_pfn) << PAGE_SHIFT;
185 166
@@ -189,7 +170,8 @@ find_memory (void)
189 if (bootmap_start == ~0UL) 170 if (bootmap_start == ~0UL)
190 panic("Cannot find %ld bytes for bootmap\n", bootmap_size); 171 panic("Cannot find %ld bytes for bootmap\n", bootmap_size);
191 172
192 bootmap_size = init_bootmem(bootmap_start >> PAGE_SHIFT, max_pfn); 173 bootmap_size = init_bootmem_node(NODE_DATA(0),
174 (bootmap_start >> PAGE_SHIFT), 0, max_pfn);
193 175
194 /* Free all available memory, then mark bootmem-map as being in use. */ 176 /* Free all available memory, then mark bootmem-map as being in use. */
195 efi_memmap_walk(filter_rsvd_memory, free_bootmem); 177 efi_memmap_walk(filter_rsvd_memory, free_bootmem);
diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
index 11a2d8825d89..872da7a2accd 100644
--- a/arch/ia64/mm/discontig.c
+++ b/arch/ia64/mm/discontig.c
@@ -88,9 +88,6 @@ static int __init build_node_maps(unsigned long start, unsigned long len,
88 bdp->node_low_pfn = max(epfn, bdp->node_low_pfn); 88 bdp->node_low_pfn = max(epfn, bdp->node_low_pfn);
89 } 89 }
90 90
91 min_low_pfn = min(min_low_pfn, bdp->node_boot_start>>PAGE_SHIFT);
92 max_low_pfn = max(max_low_pfn, bdp->node_low_pfn);
93
94 return 0; 91 return 0;
95} 92}
96 93
@@ -438,6 +435,7 @@ void __init find_memory(void)
438 /* These actually end up getting called by call_pernode_memory() */ 435 /* These actually end up getting called by call_pernode_memory() */
439 efi_memmap_walk(filter_rsvd_memory, build_node_maps); 436 efi_memmap_walk(filter_rsvd_memory, build_node_maps);
440 efi_memmap_walk(filter_rsvd_memory, find_pernode_space); 437 efi_memmap_walk(filter_rsvd_memory, find_pernode_space);
438 efi_memmap_walk(find_max_min_low_pfn, NULL);
441 439
442 for_each_online_node(node) 440 for_each_online_node(node)
443 if (mem_data[node].bootmem_data.node_low_pfn) { 441 if (mem_data[node].bootmem_data.node_low_pfn) {
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index f225dd72968b..c8da621aab17 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -648,6 +648,22 @@ count_reserved_pages (u64 start, u64 end, void *arg)
648 return 0; 648 return 0;
649} 649}
650 650
651int
652find_max_min_low_pfn (unsigned long start, unsigned long end, void *arg)
653{
654 unsigned long pfn_start, pfn_end;
655#ifdef CONFIG_FLATMEM
656 pfn_start = (PAGE_ALIGN(__pa(start))) >> PAGE_SHIFT;
657 pfn_end = (PAGE_ALIGN(__pa(end - 1))) >> PAGE_SHIFT;
658#else
659 pfn_start = GRANULEROUNDDOWN(__pa(start)) >> PAGE_SHIFT;
660 pfn_end = GRANULEROUNDUP(__pa(end - 1)) >> PAGE_SHIFT;
661#endif
662 min_low_pfn = min(min_low_pfn, pfn_start);
663 max_low_pfn = max(max_low_pfn, pfn_end);
664 return 0;
665}
666
651/* 667/*
652 * Boot command-line option "nolwsys" can be used to disable the use of any light-weight 668 * Boot command-line option "nolwsys" can be used to disable the use of any light-weight
653 * system call handler. When this option is in effect, all fsyscalls will end up bubbling 669 * system call handler. When this option is in effect, all fsyscalls will end up bubbling