aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
Diffstat (limited to 'mm')
-rw-r--r--mm/bootmem.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/mm/bootmem.c b/mm/bootmem.c
index f6ff4337b424..2ccea700968f 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -125,6 +125,7 @@ static int __init reserve_bootmem_core(bootmem_data_t *bdata,
125 BUG_ON(!size); 125 BUG_ON(!size);
126 BUG_ON(PFN_DOWN(addr) >= bdata->node_low_pfn); 126 BUG_ON(PFN_DOWN(addr) >= bdata->node_low_pfn);
127 BUG_ON(PFN_UP(addr + size) > bdata->node_low_pfn); 127 BUG_ON(PFN_UP(addr + size) > bdata->node_low_pfn);
128 BUG_ON(addr < bdata->node_boot_start);
128 129
129 sidx = PFN_DOWN(addr - bdata->node_boot_start); 130 sidx = PFN_DOWN(addr - bdata->node_boot_start);
130 eidx = PFN_UP(addr + size - bdata->node_boot_start); 131 eidx = PFN_UP(addr + size - bdata->node_boot_start);
@@ -156,21 +157,31 @@ static void __init free_bootmem_core(bootmem_data_t *bdata, unsigned long addr,
156 unsigned long sidx, eidx; 157 unsigned long sidx, eidx;
157 unsigned long i; 158 unsigned long i;
158 159
160 BUG_ON(!size);
161
162 /* out range */
163 if (addr + size < bdata->node_boot_start ||
164 PFN_DOWN(addr) > bdata->node_low_pfn)
165 return;
159 /* 166 /*
160 * round down end of usable mem, partially free pages are 167 * round down end of usable mem, partially free pages are
161 * considered reserved. 168 * considered reserved.
162 */ 169 */
163 BUG_ON(!size);
164 BUG_ON(PFN_DOWN(addr + size) > bdata->node_low_pfn);
165 170
166 if (addr < bdata->last_success) 171 if (addr >= bdata->node_boot_start && addr < bdata->last_success)
167 bdata->last_success = addr; 172 bdata->last_success = addr;
168 173
169 /* 174 /*
170 * Round up the beginning of the address. 175 * Round up to index to the range.
171 */ 176 */
172 sidx = PFN_UP(addr) - PFN_DOWN(bdata->node_boot_start); 177 if (PFN_UP(addr) > PFN_DOWN(bdata->node_boot_start))
178 sidx = PFN_UP(addr) - PFN_DOWN(bdata->node_boot_start);
179 else
180 sidx = 0;
181
173 eidx = PFN_DOWN(addr + size - bdata->node_boot_start); 182 eidx = PFN_DOWN(addr + size - bdata->node_boot_start);
183 if (eidx > bdata->node_low_pfn - PFN_DOWN(bdata->node_boot_start))
184 eidx = bdata->node_low_pfn - PFN_DOWN(bdata->node_boot_start);
174 185
175 for (i = sidx; i < eidx; i++) { 186 for (i = sidx; i < eidx; i++) {
176 if (unlikely(!test_and_clear_bit(i, bdata->node_bootmem_map))) 187 if (unlikely(!test_and_clear_bit(i, bdata->node_bootmem_map)))
@@ -421,7 +432,9 @@ int __init reserve_bootmem(unsigned long addr, unsigned long size,
421 432
422void __init free_bootmem(unsigned long addr, unsigned long size) 433void __init free_bootmem(unsigned long addr, unsigned long size)
423{ 434{
424 free_bootmem_core(NODE_DATA(0)->bdata, addr, size); 435 bootmem_data_t *bdata;
436 list_for_each_entry(bdata, &bdata_list, list)
437 free_bootmem_core(bdata, addr, size);
425} 438}
426 439
427unsigned long __init free_all_bootmem(void) 440unsigned long __init free_all_bootmem(void)