Skip to content

Commit 8b3cd09

Browse files
yhluIngo Molnar
authored andcommitted
x86_64: make reserve_bootmem_generic() use new reserve_bootmem()
"mm: make reserve_bootmem can crossed the nodes" provides new reserve_bootmem(), let reserve_bootmem_generic() use that. reserve_bootmem_generic() is used to reserve initramdisk, so this way we can make sure even when bootloader or kexec load ranges cross the node memory boundaries, reserve_bootmem still works. Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent a5645a6 commit 8b3cd09

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎arch/x86/mm/init_64.c‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ void free_initrd_mem(unsigned long start, unsigned long end)
810810
void __init reserve_bootmem_generic(unsigned long phys, unsigned len)
811811
{
812812
#ifdef CONFIG_NUMA
813-
int nid = phys_to_nid(phys);
813+
int nid, next_nid;
814814
#endif
815815
unsigned long pfn = phys >> PAGE_SHIFT;
816816

@@ -829,10 +829,16 @@ void __init reserve_bootmem_generic(unsigned long phys, unsigned len)
829829

830830
/* Should check here against the e820 map to avoid double free */
831831
#ifdef CONFIG_NUMA
832-
reserve_bootmem_node(NODE_DATA(nid), phys, len, BOOTMEM_DEFAULT);
832+
nid = phys_to_nid(phys);
833+
next_nid = phys_to_nid(phys + len - 1);
834+
if (nid == next_nid)
835+
reserve_bootmem_node(NODE_DATA(nid), phys, len, BOOTMEM_DEFAULT);
836+
else
837+
reserve_bootmem(phys, len, BOOTMEM_DEFAULT);
833838
#else
834839
reserve_bootmem(phys, len, BOOTMEM_DEFAULT);
835840
#endif
841+
836842
if (phys+len <= MAX_DMA_PFN*PAGE_SIZE) {
837843
dma_reserve += len / PAGE_SIZE;
838844
set_dma_reserve(dma_reserve);

0 commit comments

Comments
 (0)