[PATCH] [11/18] Fix alignment bug in bootmem allocator

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Andi Kleen
Date: Sunday, March 16, 2008 - 6:58 pm

Without this fix bootmem can return unaligned addresses when the start of a
node is not aligned to the align value. Needed for reliably allocating
gigabyte pages.
Signed-off-by: Andi Kleen <ak@suse.de>

---
 mm/bootmem.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Index: linux/mm/bootmem.c
===================================================================
--- linux.orig/mm/bootmem.c
+++ linux/mm/bootmem.c
@@ -197,6 +197,7 @@ __alloc_bootmem_core(struct bootmem_data
 {
 	unsigned long offset, remaining_size, areasize, preferred;
 	unsigned long i, start = 0, incr, eidx, end_pfn;
+	unsigned long pfn;
 	void *ret;
 
 	if (!size) {
@@ -239,12 +240,13 @@ __alloc_bootmem_core(struct bootmem_data
 	preferred = PFN_DOWN(ALIGN(preferred, align)) + offset;
 	areasize = (size + PAGE_SIZE-1) / PAGE_SIZE;
 	incr = align >> PAGE_SHIFT ? : 1;
+	pfn = PFN_DOWN(bdata->node_boot_start);
 
 restart_scan:
 	for (i = preferred; i < eidx; i += incr) {
 		unsigned long j;
 		i = find_next_zero_bit(bdata->node_bootmem_map, eidx, i);
-		i = ALIGN(i, incr);
+		i = ALIGN(pfn + i, incr) - pfn;
 		if (i >= eidx)
 			break;
 		if (test_bit(i, bdata->node_bootmem_map))
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] [0/18] GB pages hugetlb support, Andi Kleen, (Sun Mar 16, 6:58 pm)
[PATCH] [8/18] Add a __alloc_bootmem_node_nopanic, Andi Kleen, (Sun Mar 16, 6:58 pm)
[PATCH] [11/18] Fix alignment bug in bootmem allocator, Andi Kleen, (Sun Mar 16, 6:58 pm)
[PATCH] [14/18] Clean up hugetlb boot time printk, Andi Kleen, (Sun Mar 16, 6:58 pm)
[PATCH] [16/18] Add huge pud support to hugetlbfs, Andi Kleen, (Sun Mar 16, 6:58 pm)
[PATCH] [17/18] Add huge pud support to mm/memory.c, Andi Kleen, (Sun Mar 16, 6:58 pm)
Re: [PATCH] [0/18] GB pages hugetlb support, Paul Jackson, (Sun Mar 16, 8:11 pm)
Re: [PATCH] [0/18] GB pages hugetlb support, Paul Jackson, (Sun Mar 16, 10:35 pm)
Re: [PATCH] [0/18] GB pages hugetlb support, Andi Kleen, (Sun Mar 16, 11:58 pm)
Re: [PATCH] [0/18] GB pages hugetlb support, Paul Jackson, (Mon Mar 17, 12:00 am)
Re: [PATCH] [0/18] GB pages hugetlb support, Andi Kleen, (Mon Mar 17, 12:00 am)
Re: [PATCH] [0/18] GB pages hugetlb support, Andi Kleen, (Mon Mar 17, 12:29 am)
Re: [PATCH] [0/18] GB pages hugetlb support, Paul Jackson, (Mon Mar 17, 2:26 am)
Re: [PATCH] [0/18] GB pages hugetlb support, Adam Litke, (Mon Mar 17, 8:05 am)
Re: [PATCH] [0/18] GB pages hugetlb support, Andi Kleen, (Mon Mar 17, 8:33 am)
Re: [PATCH] [0/18] GB pages hugetlb support, Adam Litke, (Mon Mar 17, 8:59 am)