Subject: [PATCH] x86: Add name for bootmem print out -- part one

So We can get more overview of usages of bootmem.
It is only used when CONFIG_NO_BOOTMEM=y

Signed-off-by: Yinghai <yinghai@kernel.org>

---
 arch/x86/kernel/aperture_64.c |    2 +-
 arch/x86/kernel/check.c       |    2 +-
 arch/x86/kernel/head.c        |    2 +-
 arch/x86/kernel/head32.c      |    6 +++---
 arch/x86/kernel/head64.c      |    6 +++---
 arch/x86/kernel/mpparse.c     |    4 ++--
 arch/x86/kernel/setup.c       |   12 ++++++------
 arch/x86/kernel/trampoline.c  |    2 +-
 arch/x86/mm/init.c            |    2 +-
 arch/x86/mm/memtest.c         |    2 +-
 arch/x86/mm/numa_32.c         |    4 ++--
 arch/x86/mm/numa_emulation.c  |    2 +-
 arch/x86/platform/efi/efi.c   |    4 ++--
 include/linux/memblock.h      |    1 +
 mm/memblock.c                 |   27 +++++++++++++++------------
 15 files changed, 41 insertions(+), 37 deletions(-)

Index: linux-2.6/arch/x86/kernel/aperture_64.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/aperture_64.c
+++ linux-2.6/arch/x86/kernel/aperture_64.c
@@ -94,7 +94,7 @@ static u32 __init allocate_aperture(void
 				addr, aper_size>>10);
 		return 0;
 	}
-	memblock_reserve(addr, aper_size);
+	__memblock_reserve(addr, aper_size, "aperture64");
 	/*
 	 * Kmemleak should not scan this block as it may not be mapped via the
 	 * kernel direct mapping.
Index: linux-2.6/arch/x86/kernel/check.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/check.c
+++ linux-2.6/arch/x86/kernel/check.c
@@ -91,7 +91,7 @@ void __init setup_bios_corruption_check(
 		if (start >= end)
 			continue;
 
-		memblock_reserve(start, end - start);
+		__memblock_reserve(start, end - start, "SCAN RAM");
 		scan_areas[num_scan_areas].addr = start;
 		scan_areas[num_scan_areas].size = end - start;
 
Index: linux-2.6/arch/x86/kernel/head.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/head.c
+++ linux-2.6/arch/x86/kernel/head.c
@@ -52,7 +52,7 @@ void __init reserve_ebda_region(void)
 		lowmem = 0x9f000;
 
 	/* reserve all memory between lowmem and the 1MB mark */
-	memblock_reserve(lowmem, 0x100000 - lowmem);
+	__memblock_reserve(lowmem, 0x100000 - lowmem, "* BIOS reserved");
 }
 
 void __init setup_early_console(void)
Index: linux-2.6/arch/x86/kernel/head32.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/head32.c
+++ linux-2.6/arch/x86/kernel/head32.c
@@ -33,8 +33,8 @@ void __init i386_start_kernel(void)
 {
 	setup_early_console();
 
-	memblock_reserve(__pa_symbol(&_text),
-			 __pa_symbol(&__bss_stop) - __pa_symbol(&_text));
+	__memblock_reserve(__pa_symbol(&_text),
+			 __pa_symbol(&__bss_stop) - __pa_symbol(&_text), "TEXT DATA BSS");
 
 #ifdef CONFIG_BLK_DEV_INITRD
 	/* Reserve INITRD */
@@ -43,7 +43,7 @@ void __init i386_start_kernel(void)
 		u64 ramdisk_image = boot_params.hdr.ramdisk_image;
 		u64 ramdisk_size  = boot_params.hdr.ramdisk_size;
 		u64 ramdisk_end   = PAGE_ALIGN(ramdisk_image + ramdisk_size);
-		memblock_reserve(ramdisk_image, ramdisk_end - ramdisk_image);
+		__memblock_reserve(ramdisk_image, ramdisk_end - ramdisk_image, "RAMDISK");
 	}
 #endif
 
Index: linux-2.6/arch/x86/kernel/head64.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/head64.c
+++ linux-2.6/arch/x86/kernel/head64.c
@@ -109,8 +109,8 @@ void __init x86_64_start_reservations(ch
 		setup_early_console();
 	}
 
-	memblock_reserve(__pa_symbol(&_text),
-			 __pa_symbol(&__bss_stop) - __pa_symbol(&_text));
+	__memblock_reserve(__pa_symbol(&_text),
+			 __pa_symbol(&__bss_stop) - __pa_symbol(&_text), "TEXT DATA BSS");
 
 #ifdef CONFIG_BLK_DEV_INITRD
 	/* Reserve INITRD */
@@ -119,7 +119,7 @@ void __init x86_64_start_reservations(ch
 		unsigned long ramdisk_image = boot_params.hdr.ramdisk_image;
 		unsigned long ramdisk_size  = boot_params.hdr.ramdisk_size;
 		unsigned long ramdisk_end   = PAGE_ALIGN(ramdisk_image + ramdisk_size);
-		memblock_reserve(ramdisk_image, ramdisk_end - ramdisk_image);
+		__memblock_reserve(ramdisk_image, ramdisk_end - ramdisk_image, "RAMDISK");
 	}
 #endif
 
Index: linux-2.6/arch/x86/kernel/mpparse.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/mpparse.c
+++ linux-2.6/arch/x86/kernel/mpparse.c
@@ -564,7 +564,7 @@ void __init default_get_smp_config(unsig
 
 static void __init smp_reserve_memory(struct mpf_intel *mpf)
 {
-	memblock_reserve(mpf->physptr, get_mpc_size(mpf->physptr));
+	__memblock_reserve(mpf->physptr, get_mpc_size(mpf->physptr), "* MP-table mpc");
 }
 
 static int __init smp_scan_config(unsigned long base, unsigned long length)
@@ -593,7 +593,7 @@ static int __init smp_scan_config(unsign
 			       mpf, (u64)virt_to_phys(mpf));
 
 			mem = virt_to_phys(mpf);
-			memblock_reserve(mem, sizeof(*mpf));
+			__memblock_reserve(mem, sizeof(*mpf), "* MP-table mpf");
 			if (mpf->physptr)
 				smp_reserve_memory(mpf);
 
Index: linux-2.6/arch/x86/kernel/setup.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/setup.c
+++ linux-2.6/arch/x86/kernel/setup.c
@@ -305,8 +305,8 @@ static void __init cleanup_highmap(void)
 static void __init reserve_brk(void)
 {
 	if (_brk_end > _brk_start)
-		memblock_reserve(__pa(_brk_start),
-				 __pa(_brk_end) - __pa(_brk_start));
+		__memblock_reserve(__pa(_brk_start),
+				 __pa(_brk_end) - __pa(_brk_start), "BRK");
 
 	/* Mark brk area as locked down and no longer taking any
 	   new allocations */
@@ -337,7 +337,7 @@ static void __init relocate_initrd(void)
 
 	/* Note: this includes all the lowmem currently occupied by
 	   the initrd, we rely on that fact to keep the data intact. */
-	memblock_reserve(ramdisk_here, area_size);
+	__memblock_reserve(ramdisk_here, area_size, "NEW RAMDISK");
 	initrd_start = ramdisk_here + PAGE_OFFSET;
 	initrd_end   = initrd_start + ramdisk_size;
 	printk(KERN_INFO "Allocated new RAMDISK: %08llx - %08llx\n",
@@ -496,7 +496,7 @@ static void __init memblock_x86_reserve_
 	pa_data = boot_params.hdr.setup_data;
 	while (pa_data) {
 		data = early_memremap(pa_data, sizeof(*data));
-		memblock_reserve(pa_data, sizeof(*data) + data->len);
+		__memblock_reserve(pa_data, sizeof(*data) + data->len, "SETUP DATA");
 		pa_data = data->next;
 		early_iounmap(data, sizeof(*data));
 	}
@@ -557,7 +557,7 @@ static void __init reserve_crashkernel(v
 			return;
 		}
 	}
-	memblock_reserve(crash_base, crash_size);
+	__memblock_reserve(crash_base, crash_size, "CRASH KERNEL");
 
 	printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
 			"for crashkernel (System RAM: %ldMB)\n",
@@ -615,7 +615,7 @@ static __init void reserve_ibft_region(v
 	addr = find_ibft_region(&size);
 
 	if (size)
-		memblock_reserve(addr, size);
+		__memblock_reserve(addr, size, "* ibft");
 }
 
 static unsigned reserve_low = CONFIG_X86_RESERVE_LOW << 10;
Index: linux-2.6/arch/x86/kernel/trampoline.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/trampoline.c
+++ linux-2.6/arch/x86/kernel/trampoline.c
@@ -18,7 +18,7 @@ void __init setup_trampolines(void)
 		panic("Cannot allocate trampoline\n");
 
 	x86_trampoline_base = __va(mem);
-	memblock_reserve(mem, size);
+	__memblock_reserve(mem, size, "TRAMPOLINE");
 
 	printk(KERN_DEBUG "Base memory trampoline at [%p] %llx size %zu\n",
 	       x86_trampoline_base, (unsigned long long)mem, size);
Index: linux-2.6/arch/x86/mm/init.c
===================================================================
--- linux-2.6.orig/arch/x86/mm/init.c
+++ linux-2.6/arch/x86/mm/init.c
@@ -121,7 +121,7 @@ static void probe_page_size_mask(void)
 }
 void __init native_pagetable_reserve(u64 start, u64 end)
 {
-	memblock_reserve(start, end - start);
+	__memblock_reserve(start, end - start, "PGTABLE");
 }
 
 #ifdef CONFIG_X86_32
Index: linux-2.6/arch/x86/mm/memtest.c
===================================================================
--- linux-2.6.orig/arch/x86/mm/memtest.c
+++ linux-2.6/arch/x86/mm/memtest.c
@@ -34,7 +34,7 @@ static void __init reserve_bad_mem(u64 p
 	       (unsigned long long) pattern,
 	       (unsigned long long) start_bad,
 	       (unsigned long long) end_bad);
-	memblock_reserve(start_bad, end_bad - start_bad);
+	__memblock_reserve(start_bad, end_bad - start_bad, "BAD RAM");
 }
 
 static void __init memtest(u64 pattern, u64 start_phys, u64 size)
Index: linux-2.6/arch/x86/mm/numa_32.c
===================================================================
--- linux-2.6.orig/arch/x86/mm/numa_32.c
+++ linux-2.6/arch/x86/mm/numa_32.c
@@ -204,7 +204,7 @@ void __init init_alloc_remap(int nid, u6
 			   size, nid);
 		return;
 	}
-	memblock_reserve(node_pa, size);
+	__memblock_reserve(node_pa, size, "KVA RAM");
 
 	remap_pa = memblock_find_in_range(min_low_pfn << PAGE_SHIFT,
 					  max_low_pfn << PAGE_SHIFT,
@@ -215,7 +215,7 @@ void __init init_alloc_remap(int nid, u6
 		memblock_free(node_pa, size);
 		return;
 	}
-	memblock_reserve(remap_pa, size);
+	__memblock_reserve(remap_pa, size, "KVA PG");
 	remap_va = phys_to_virt(remap_pa);
 
 	/* perform actual remap */
Index: linux-2.6/arch/x86/mm/numa_emulation.c
===================================================================
--- linux-2.6.orig/arch/x86/mm/numa_emulation.c
+++ linux-2.6/arch/x86/mm/numa_emulation.c
@@ -361,7 +361,7 @@ void __init numa_emulation(struct numa_m
 			pr_warning("NUMA: Warning: can't allocate copy of distance table, disabling emulation\n");
 			goto no_emu;
 		}
-		memblock_reserve(phys, phys_size);
+		__memblock_reserve(phys, phys_size, "TMP NUMA DIST");
 		phys_dist = __va(phys);
 
 		for (i = 0; i < numa_dist_cnt; i++)
Index: linux-2.6/arch/x86/platform/efi/efi.c
===================================================================
--- linux-2.6.orig/arch/x86/platform/efi/efi.c
+++ linux-2.6/arch/x86/platform/efi/efi.c
@@ -369,7 +369,7 @@ int __init efi_memblock_x86_reserve_rang
 		boot_params.efi_info.efi_memdesc_size;
 	memmap.desc_version = boot_params.efi_info.efi_memdesc_version;
 	memmap.desc_size = boot_params.efi_info.efi_memdesc_size;
-	memblock_reserve(pmap, memmap.nr_map * memmap.desc_size);
+	__memblock_reserve(pmap, memmap.nr_map * memmap.desc_size, "EFI memmap");
 
 	return 0;
 }
@@ -422,7 +422,7 @@ void __init efi_reserve_boot_services(vo
 					"[0x%010llx-0x%010llx]\n",
 						start, start+size-1);
 		} else
-			memblock_reserve(start, size);
+			__memblock_reserve(start, size, "EFI Boot");
 	}
 }
 
Index: linux-2.6/include/linux/memblock.h
===================================================================
--- linux-2.6.orig/include/linux/memblock.h
+++ linux-2.6/include/linux/memblock.h
@@ -60,6 +60,7 @@ int memblock_add(phys_addr_t base, phys_
 int memblock_remove(phys_addr_t base, phys_addr_t size);
 int memblock_free(phys_addr_t base, phys_addr_t size);
 int memblock_reserve(phys_addr_t base, phys_addr_t size);
+int __memblock_reserve(phys_addr_t base, phys_addr_t size, char *name);
 
 #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
 void __next_mem_pfn_range(int *idx, int nid, unsigned long *out_start_pfn,
Index: linux-2.6/mm/memblock.c
===================================================================
--- linux-2.6.orig/mm/memblock.c
+++ linux-2.6/mm/memblock.c
@@ -516,25 +516,28 @@ int __init_memblock memblock_free(phys_a
 {
 	WARN_ONCE(!memblock.reserved.max, "memblock.reserved was cleared already!");
 
-	memblock_dbg("   memblock_free: [%#016llx-%#016llx] %pF\n",
+	memblock_dbg("   memblock_free: [%#010llx-%#010llx]",
 		     (unsigned long long)base,
-		     (unsigned long long)base + size,
-		     (void *)_RET_IP_);
+		     (unsigned long long)base + size - 1);
 
 	return __memblock_remove(&memblock.reserved, base, size);
 }
 
-int __init_memblock memblock_reserve(phys_addr_t base, phys_addr_t size)
+int __init_memblock __memblock_reserve(phys_addr_t base, phys_addr_t size,
+					char *name)
 {
-	struct memblock_type *_rgn = &memblock.reserved;
-
 	WARN_ONCE(!memblock.reserved.max, "memblock.reserved was cleared already!");
-	memblock_dbg("memblock_reserve: [%#016llx-%#016llx] %pF\n",
-		     (unsigned long long)base,
-		     (unsigned long long)base + size,
-		     (void *)_RET_IP_);
 
-	return memblock_add_region(_rgn, base, size, MAX_NUMNODES);
+	memblock_dbg("memblock_reserve: [%#010llx-%#010llx] %s\n",
+			(unsigned long long)base,
+			(unsigned long long)base + size - 1, name);
+
+	return memblock_add_region(&memblock.reserved, base, size, MAX_NUMNODES);
+}
+
+int __init_memblock memblock_reserve(phys_addr_t base, phys_addr_t size)
+{
+	return	__memblock_reserve(base, size, "");
 }
 
 /**
@@ -912,7 +915,7 @@ static void __init_memblock memblock_dum
 			snprintf(nid_buf, sizeof(nid_buf), " on node %d",
 				 memblock_get_region_node(rgn));
 #endif
-		pr_info(" %s[%#x]\t[%#016llx-%#016llx], %#llx bytes%s\n",
+		pr_info(" %s[%#x]\t[%#010llx-%#010llx], %#llx bytes%s\n",
 			name, i, base, base + size - 1, size, nid_buf);
 	}
 }
