Skip to contentSkip to conversation

x86-64 linux: cleanup use of reserve_bootmem_generic()

PATCH New Jan Beulich 1 participant 1 message May 5, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86-64 linux: cleanup use of reserve_bootmem_generic()

Make reserve_bootmem_generic() an empty inline function, thus allowing to reduce the amount of changes needed elsewhere. At once, this recovers two pages needlessly getting reserved on SMP.

arch/x86_64/kernel/setup-xen.c +8 -22
Index: head-2006-05-03/arch/x86_64/kernel/setup-xen.c
===================================================================
@@ -616,10 +616,10 @@ static inline void copy_edd(void)
 }
 #endif
 
-#ifndef CONFIG_XEN
 #define EBDA_ADDR_POINTER 0x40E
 static void __init reserve_ebda_region(void)
 {
+#ifndef CONFIG_XEN
 	unsigned int addr;
 	/** 
 	 * there is a real-mode segmented pointer pointing to the 
@@ -629,8 +629,8 @@ static void __init reserve_ebda_region(v
 	addr <<= 4;
 	if (addr)
 		reserve_bootmem_generic(addr, PAGE_SIZE);
-}
 #endif
+}
 
 void __init setup_arch(char **cmdline_p)
 {
@@ -740,7 +740,6 @@ void __init setup_arch(char **cmdline_p)
 	contig_initmem_init(start_pfn, end_pfn);
 #endif
 
-#ifndef CONFIG_XEN
 	/* Reserve direct mapping */
 	reserve_bootmem_generic(table_start << PAGE_SHIFT, 
 				(table_end - table_start) << PAGE_SHIFT);
@@ -757,7 +756,6 @@ void __init setup_arch(char **cmdline_p)
 
 	/* reserve ebda region */
 	reserve_ebda_region();
-#endif
 
 #ifdef CONFIG_SMP
 	/*
@@ -777,31 +775,20 @@ void __init setup_arch(char **cmdline_p)
         */
        acpi_reserve_bootmem();
 #endif
-#ifdef CONFIG_XEN
 #ifdef CONFIG_BLK_DEV_INITRD
+#ifndef CONFIG_XEN
+	if (LOADER_TYPE && INITRD_START) {
+#else
 	if (xen_start_info->mod_start) {
-		if (INITRD_START + INITRD_SIZE <= (end_pfn << PAGE_SHIFT)) {
-			/*reserve_bootmem_generic(INITRD_START, INITRD_SIZE);*/
-			initrd_start = INITRD_START + PAGE_OFFSET;
-			initrd_end = initrd_start+INITRD_SIZE;
-			initrd_below_start_ok = 1;
-		} else {
-			printk(KERN_ERR "initrd extends beyond end of memory "
-				"(0x%08lx > 0x%08lx)\ndisabling initrd\n",
-				(unsigned long)(INITRD_START + INITRD_SIZE),
-				(unsigned long)(end_pfn << PAGE_SHIFT));
-			initrd_start = 0;
-		}
-	}
 #endif
-#else	/* CONFIG_XEN */
-#ifdef CONFIG_BLK_DEV_INITRD
-	if (LOADER_TYPE && INITRD_START) {
 		if (INITRD_START + INITRD_SIZE <= (end_pfn << PAGE_SHIFT)) {
 			reserve_bootmem_generic(INITRD_START, INITRD_SIZE);
 			initrd_start =
 				INITRD_START ? INITRD_START + PAGE_OFFSET : 0;
 			initrd_end = initrd_start+INITRD_SIZE;
+#ifdef CONFIG_XEN
+			initrd_below_start_ok = 1;
+#endif
 		}
 		else {
 			printk(KERN_ERR "initrd extends beyond end of memory "
@@ -812,7 +799,6 @@ void __init setup_arch(char **cmdline_p)
 		}
 	}
 #endif
-#endif	/* !CONFIG_XEN */
 #ifdef CONFIG_KEXEC
 	if (crashk_res.start != crashk_res.end) {
 		reserve_bootmem(crashk_res.start,
arch/x86_64/mm/init-xen.c +4 -0
Index: head-2006-05-03/arch/x86_64/mm/init-xen.c
===================================================================
@@ -58,7 +58,9 @@ EXPORT_SYMBOL(dma_ops);
 
 extern unsigned long *contiguous_bitmap;
 
+#ifndef CONFIG_XEN
 static unsigned long dma_reserve __initdata;
+#endif
 
 DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
 extern unsigned long start_pfn;
@@ -985,6 +987,7 @@ void free_initrd_mem(unsigned long start
 }
 #endif
 
+#ifndef CONFIG_XEN
 void __init reserve_bootmem_generic(unsigned long phys, unsigned len) 
 { 
 	/* Should check here against the e820 map to avoid double free */ 
@@ -997,6 +1000,7 @@ void __init reserve_bootmem_generic(unsi
 	if (phys+len <= MAX_DMA_PFN*PAGE_SIZE)
 		dma_reserve += len / PAGE_SIZE;
 }
+#endif
 
 int kern_addr_valid(unsigned long addr) 
 { 
include/asm-x86_64/proto.h +4 -0
Index: head-2006-05-03/include/asm-x86_64/proto.h
===================================================================
@@ -67,8 +67,12 @@ extern int k8_scan_nodes(unsigned long s
 extern void numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn);
 extern unsigned long numa_free_all_bootmem(void);
 
+#ifndef CONFIG_XEN
 extern void reserve_bootmem_generic(unsigned long phys, unsigned len);
 extern void free_bootmem_generic(unsigned long phys, unsigned len);
+#else
+static inline void reserve_bootmem_generic(unsigned long phys, unsigned len) {}
+#endif
 
 extern void load_gs_index(unsigned gs);
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel