LKML Archive on lore.kernel.org
 help / color / Atom feed
* [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code
@ 2011-07-12  9:15 Tejun Heo
  2011-07-12  9:15 ` [PATCH 01/13] memblock: Remove memblock_memory_can_coalesce() Tejun Heo
                   ` (15 more replies)
  0 siblings, 16 replies; 54+ messages in thread
From: Tejun Heo @ 2011-07-12  9:15 UTC (permalink / raw)
  To: mingo, hpa, tglx, benh, yinghai, davem; +Cc: linux-kernel, linux-arch, x86

Hello,

There are multiple ways to represent memory configuration during boot.
Even with the latest incarnation - nobootmem, the configuration isn't
centralized or easy to use.  NUMA information lives in
early_node_map[] while memory config and alloc/reservation live in
memblock.  This leads to ugly code pieces which try to combine the two
separate information sources both in generic and arch specfic parts.

This patchset extends memblock such that it can also host node
information and allows an arch to do away with early_node_map[] and
use memblock as the sole early memory config / allocation mechanism.

For short term, this adds yet another config option -
HAVE_MEMBLOCK_NODE_MAP in this area.  Longer term goal is removing
early_node_map[] completely and convert everyone over to memblock.  As
early_node_map[] usage is limited only to NUMA archs, this should be
easiser than bootmem allocator conversion.  In the end, memblock will
be the only early mem mechanism.

Note that this patchset still leaves good amount of code which can be
removed / cleaned up in not too distant future.  For example, memblock
non-NUMA alloc code can simply be degenerate case of NUMA aware alloc,
which can also be implemented in simpler and more efficient way with
reverse free area iterator.

This patchset first extends memblock so that it can contain node
information and then replaces x86 specific memblock code with the
generic one.

 0001-memblock-Remove-memblock_memory_can_coalesce.patch
 0002-memblock-Reimplement-memblock_add_region.patch
 0003-memblock-Add-optional-region-nid.patch
 0004-x86-Use-HAVE_MEMBLOCK_NODE_MAP.patch
 0005-x86-Use-__memblock_alloc_base-in-early_reserve_e820.patch
 0006-memblock-Implement-for_each_free_mem_range.patch
 0007-x86-Replace-memblock_x86_find_in_range_size-with-for.patch
 0008-memblock-x86-Make-free_all_memory_core_early-explici.patch
 0009-memblock-x86-Replace-__get_free_all_memory_range-wit.patch
 0010-memblock-x86-Reimplement-memblock_find_dma_reserve-u.patch
 0011-x86-Use-absent_pages_in_range-instead-of-memblock_x8.patch
 0012-memblock-x86-Make-ARCH_DISCARD_MEMBLOCK-a-config-opt.patch
 0013-memblock-x86-Replace-memblock_x86_reserve-free_range.patch

0001-0004 implement HAVE_MEMBLOCK_NODE_MAP and use it in x86.

0005-0013 adds generic memblock free area iterator and gradually
replaces x86 specific memblock mechanism with generic one.

This patchset is on top of

  x86/urgent (5da0ef9a85 "x86: Disable AMD_NUMA for 32bit for now")
+ pfn->nid granularity check patches [1]
+ "memblock, x86: Misc cleanups" patchset [2]
+ "memblock, x86: Implement for_each_mem_pfn_range() and use it to improve memblock allocator" patchset [3]

and available in the following git branch.

 git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.git review-x86-mm-memblock

Diffstat follows.

 arch/x86/Kconfig                |    2
 arch/x86/include/asm/e820.h     |    2
 arch/x86/include/asm/memblock.h |   22 --
 arch/x86/kernel/aperture_64.c   |    2
 arch/x86/kernel/check.c         |   34 +--
 arch/x86/kernel/e820.c          |   55 ++---
 arch/x86/kernel/head.c          |    2
 arch/x86/kernel/head32.c        |    5
 arch/x86/kernel/head64.c        |    5
 arch/x86/kernel/mpparse.c       |   12 -
 arch/x86/kernel/setup.c         |   17 -
 arch/x86/kernel/trampoline.c    |    2
 arch/x86/mm/Makefile            |    2
 arch/x86/mm/init.c              |    6
 arch/x86/mm/init_32.c           |   28 +-
 arch/x86/mm/memblock.c          |  318 ----------------------------
 arch/x86/mm/memtest.c           |   33 +--
 arch/x86/mm/numa.c              |   24 +-
 arch/x86/mm/numa_32.c           |    6
 arch/x86/mm/numa_64.c           |    2
 arch/x86/mm/numa_emulation.c    |   34 +--
 arch/x86/platform/efi/efi.c     |    6
 arch/x86/xen/mmu.c              |   12 -
 arch/x86/xen/setup.c            |    7
 include/linux/bootmem.h         |    2
 include/linux/memblock.h        |   54 ++++
 include/linux/mm.h              |    2
 mm/Kconfig                      |    6
 mm/memblock.c                   |  440 ++++++++++++++++++++++++++++------------
 mm/nobootmem.c                  |   40 ++-
 mm/page_alloc.c                 |   47 ++--
 31 files changed, 554 insertions(+), 675 deletions(-)

Thanks.

--
tejun

[1] http://thread.gmane.org/gmane.linux.kernel/1166521
[2] http://thread.gmane.org/gmane.linux.kernel.cross-arch/10338
[3] http://thread.gmane.org/gmane.linux.kernel.cross-arch/10345

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH 01/13] memblock: Remove memblock_memory_can_coalesce()
  2011-07-12  9:15 [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Tejun Heo
@ 2011-07-12  9:15 ` Tejun Heo
  2011-07-14 21:31   ` [tip:x86/memblock] " tip-bot for Tejun Heo
  2011-07-12  9:15 ` [PATCH 02/13] memblock: Reimplement memblock_add_region() Tejun Heo
                   ` (14 subsequent siblings)
  15 siblings, 1 reply; 54+ messages in thread
From: Tejun Heo @ 2011-07-12  9:15 UTC (permalink / raw)
  To: mingo, hpa, tglx, benh, yinghai, davem
  Cc: linux-kernel, linux-arch, x86, Tejun Heo

Arch could implement memblock_memor_can_coalesce() to veto merging of
adjacent or overlapping memblock regions; however, no arch did and any
vetoing would trigger WARN_ON().  Memblock regions are supposed to
deal with proper memory anyway.  Remove the unused hook.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 include/linux/memblock.h |    4 ----
 mm/memblock.c            |   29 -----------------------------
 2 files changed, 0 insertions(+), 33 deletions(-)

diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 7400d02..aa5df9e 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -92,10 +92,6 @@ extern int memblock_is_region_reserved(phys_addr_t base, phys_addr_t size);
 
 extern void memblock_dump_all(void);
 
-/* Provided by the architecture */
-extern int memblock_memory_can_coalesce(phys_addr_t addr1, phys_addr_t size1,
-				   phys_addr_t addr2, phys_addr_t size2);
-
 /**
  * memblock_set_current_limit - Set the current allocation limit to allow
  *                         limiting allocations to what is currently
diff --git a/mm/memblock.c b/mm/memblock.c
index a8edb42..bd3a3a9 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -251,12 +251,6 @@ static int __init_memblock memblock_double_array(struct memblock_type *type)
 	return 0;
 }
 
-extern int __init_memblock __weak memblock_memory_can_coalesce(phys_addr_t addr1, phys_addr_t size1,
-					  phys_addr_t addr2, phys_addr_t size2)
-{
-	return 1;
-}
-
 static long __init_memblock memblock_add_region(struct memblock_type *type,
 						phys_addr_t base, phys_addr_t size)
 {
@@ -282,17 +276,6 @@ static long __init_memblock memblock_add_region(struct memblock_type *type,
 		 * of a block.
 		 */
 		if (base < rgn->base && end >= rgn->base) {
-			/* If we can't coalesce, create a new block */
-			if (!memblock_memory_can_coalesce(base, size,
-							  rgn->base,
-							  rgn->size)) {
-				/* Overlap & can't coalesce are mutually
-				 * exclusive, if you do that, be prepared
-				 * for trouble
-				 */
-				WARN_ON(end != rgn->base);
-				goto new_block;
-			}
 			/* We extend the bottom of the block down to our
 			 * base
 			 */
@@ -316,17 +299,6 @@ static long __init_memblock memblock_add_region(struct memblock_type *type,
 		 * top of a block
 		 */
 		if (base <= rend && end >= rend) {
-			/* If we can't coalesce, create a new block */
-			if (!memblock_memory_can_coalesce(rgn->base,
-							  rgn->size,
-							  base, size)) {
-				/* Overlap & can't coalesce are mutually
-				 * exclusive, if you do that, be prepared
-				 * for trouble
-				 */
-				WARN_ON(rend != base);
-				goto new_block;
-			}
 			/* We adjust our base down to enclose the
 			 * original block and destroy it. It will be
 			 * part of our new allocation. Since we've
@@ -349,7 +321,6 @@ static long __init_memblock memblock_add_region(struct memblock_type *type,
 		return 0;
 	}
 
- new_block:
 	/* If we are out of space, we fail. It's too late to resize the array
 	 * but then this shouldn't have happened in the first place.
 	 */
-- 
1.7.6


^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH 02/13] memblock: Reimplement memblock_add_region()
  2011-07-12  9:15 [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Tejun Heo
  2011-07-12  9:15 ` [PATCH 01/13] memblock: Remove memblock_memory_can_coalesce() Tejun Heo
@ 2011-07-12  9:15 ` Tejun Heo
  2011-07-14 21:32   ` [tip:x86/memblock] " tip-bot for Tejun Heo
  2011-07-12  9:15 ` [PATCH 03/13] memblock: Add optional region->nid Tejun Heo
                   ` (13 subsequent siblings)
  15 siblings, 1 reply; 54+ messages in thread
From: Tejun Heo @ 2011-07-12  9:15 UTC (permalink / raw)
  To: mingo, hpa, tglx, benh, yinghai, davem
  Cc: linux-kernel, linux-arch, x86, Tejun Heo

memblock_add_region() carefully checked for merge and overlap
conditions while adding a new region, which is complicated and makes
it difficult to allow arbitrary overlaps or add more merge conditions
(e.g. node ID).

This re-implements memblock_add_region() such that insertion is done
in two steps - all non-overlapping portions of new area are inserted
as separate regions first and then memblock_merge_regions() scan and
merge all neighbouring compatible regions.

This makes addition logic simpler and more versatile and enables
adding node information to memblock.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 mm/memblock.c |  197 ++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 111 insertions(+), 86 deletions(-)

diff --git a/mm/memblock.c b/mm/memblock.c
index bd3a3a9..992aa18 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -251,117 +251,142 @@ static int __init_memblock memblock_double_array(struct memblock_type *type)
 	return 0;
 }
 
-static long __init_memblock memblock_add_region(struct memblock_type *type,
-						phys_addr_t base, phys_addr_t size)
+/**
+ * memblock_merge_regions - merge neighboring compatible regions
+ * @type: memblock type to scan
+ *
+ * Scan @type and merge neighboring compatible regions.
+ */
+static void __init_memblock memblock_merge_regions(struct memblock_type *type)
 {
-	phys_addr_t end = base + size;
-	int i, slot = -1;
+	int i = 0;
 
-	/* First try and coalesce this MEMBLOCK with others */
-	for (i = 0; i < type->cnt; i++) {
-		struct memblock_region *rgn = &type->regions[i];
-		phys_addr_t rend = rgn->base + rgn->size;
+	/* cnt never goes below 1 */
+	while (i < type->cnt - 1) {
+		struct memblock_region *this = &type->regions[i];
+		struct memblock_region *next = &type->regions[i + 1];
 
-		/* Exit if there's no possible hits */
-		if (rgn->base > end || rgn->size == 0)
-			break;
-
-		/* Check if we are fully enclosed within an existing
-		 * block
-		 */
-		if (rgn->base <= base && rend >= end)
-			return 0;
+		if (this->base + this->size != next->base) {
+			BUG_ON(this->base + this->size > next->base);
+			i++;
+			continue;
+		}
 
-		/* Check if we overlap or are adjacent with the bottom
-		 * of a block.
-		 */
-		if (base < rgn->base && end >= rgn->base) {
-			/* We extend the bottom of the block down to our
-			 * base
-			 */
-			rgn->base = base;
-			rgn->size = rend - base;
+		this->size += next->size;
+		memmove(next, next + 1, (type->cnt - (i + 1)) * sizeof(*next));
+		type->cnt--;
+	}
+}
 
-			/* Return if we have nothing else to allocate
-			 * (fully coalesced)
-			 */
-			if (rend >= end)
-				return 0;
+/**
+ * memblock_insert_region - insert new memblock region
+ * @type: memblock type to insert into
+ * @idx: index for the insertion point
+ * @base: base address of the new region
+ * @size: size of the new region
+ *
+ * Insert new memblock region [@base,@base+@size) into @type at @idx.
+ * @type must already have extra room to accomodate the new region.
+ */
+static void __init_memblock memblock_insert_region(struct memblock_type *type,
+						   int idx, phys_addr_t base,
+						   phys_addr_t size)
+{
+	struct memblock_region *rgn = &type->regions[idx];
 
-			/* We continue processing from the end of the
-			 * coalesced block.
-			 */
-			base = rend;
-			size = end - base;
-		}
+	BUG_ON(type->cnt >= type->max);
+	memmove(rgn + 1, rgn, (type->cnt - idx) * sizeof(*rgn));
+	rgn->base = base;
+	rgn->size = size;
+	type->cnt++;
+}
 
-		/* Now check if we overlap or are adjacent with the
-		 * top of a block
-		 */
-		if (base <= rend && end >= rend) {
-			/* We adjust our base down to enclose the
-			 * original block and destroy it. It will be
-			 * part of our new allocation. Since we've
-			 * freed an entry, we know we won't fail
-			 * to allocate one later, so we won't risk
-			 * losing the original block allocation.
-			 */
-			size += (base - rgn->base);
-			base = rgn->base;
-			memblock_remove_region(type, i--);
-		}
-	}
+/**
+ * memblock_add_region - add new memblock region
+ * @type: memblock type to add new region into
+ * @base: base address of the new region
+ * @size: size of the new region
+ *
+ * Add new memblock region [@base,@base+@size) into @type.  The new region
+ * is allowed to overlap with existing ones - overlaps don't affect already
+ * existing regions.  @type is guaranteed to be minimal (all neighbouring
+ * compatible regions are merged) after the addition.
+ *
+ * RETURNS:
+ * 0 on success, -errno on failure.
+ */
+static long __init_memblock memblock_add_region(struct memblock_type *type,
+						phys_addr_t base, phys_addr_t size)
+{
+	bool insert = false;
+	phys_addr_t obase = base, end = base + size;
+	int i, nr_new;
 
-	/* If the array is empty, special case, replace the fake
-	 * filler region and return
-	 */
-	if ((type->cnt == 1) && (type->regions[0].size == 0)) {
+	/* special case for empty array */
+	if (type->regions[0].size == 0) {
+		WARN_ON(type->cnt != 1);
 		type->regions[0].base = base;
 		type->regions[0].size = size;
 		return 0;
 	}
-
-	/* If we are out of space, we fail. It's too late to resize the array
-	 * but then this shouldn't have happened in the first place.
+repeat:
+	/*
+	 * The following is executed twice.  Once with %false @insert and
+	 * then with %true.  The first counts the number of regions needed
+	 * to accomodate the new area.  The second actually inserts them.
 	 */
-	if (WARN_ON(type->cnt >= type->max))
-		return -1;
+	base = obase;
+	nr_new = 0;
+
+	for (i = 0; i < type->cnt; i++) {
+		struct memblock_region *rgn = &type->regions[i];
+		phys_addr_t rbase = rgn->base;
+		phys_addr_t rend = rbase + rgn->size;
 
-	/* Couldn't coalesce the MEMBLOCK, so add it to the sorted table. */
-	for (i = type->cnt - 1; i >= 0; i--) {
-		if (base < type->regions[i].base) {
-			type->regions[i+1].base = type->regions[i].base;
-			type->regions[i+1].size = type->regions[i].size;
-		} else {
-			type->regions[i+1].base = base;
-			type->regions[i+1].size = size;
-			slot = i + 1;
+		if (rbase >= end)
 			break;
+		if (rend <= base)
+			continue;
+		/*
+		 * @rgn overlaps.  If it separates the lower part of new
+		 * area, insert that portion.
+		 */
+		if (rbase > base) {
+			nr_new++;
+			if (insert)
+				memblock_insert_region(type, i++, base,
+						       rbase - base);
 		}
+		/* area below @rend is dealt with, forget about it */
+		base = min(rend, end);
 	}
-	if (base < type->regions[0].base) {
-		type->regions[0].base = base;
-		type->regions[0].size = size;
-		slot = 0;
+
+	/* insert the remaining portion */
+	if (base < end) {
+		nr_new++;
+		if (insert)
+			memblock_insert_region(type, i, base, end - base);
 	}
-	type->cnt++;
 
-	/* The array is full ? Try to resize it. If that fails, we undo
-	 * our allocation and return an error
+	/*
+	 * If this was the first round, resize array and repeat for actual
+	 * insertions; otherwise, merge and return.
 	 */
-	if (type->cnt == type->max && memblock_double_array(type)) {
-		BUG_ON(slot < 0);
-		memblock_remove_region(type, slot);
-		return -1;
+	if (!insert) {
+		while (type->cnt + nr_new > type->max)
+			if (memblock_double_array(type) < 0)
+				return -ENOMEM;
+		insert = true;
+		goto repeat;
+	} else {
+		memblock_merge_regions(type);
+		return 0;
 	}
-
-	return 0;
 }
 
 long __init_memblock memblock_add(phys_addr_t base, phys_addr_t size)
 {
 	return memblock_add_region(&memblock.memory, base, size);
-
 }
 
 static long __init_memblock __memblock_remove(struct memblock_type *type,
-- 
1.7.6


^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH 03/13] memblock: Add optional region->nid
  2011-07-12  9:15 [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Tejun Heo
  2011-07-12  9:15 ` [PATCH 01/13] memblock: Remove memblock_memory_can_coalesce() Tejun Heo
  2011-07-12  9:15 ` [PATCH 02/13] memblock: Reimplement memblock_add_region() Tejun Heo
@ 2011-07-12  9:15 ` Tejun Heo
  2011-07-14  9:43   ` [PATCH UPDATED " Tejun Heo
  2011-07-12  9:15 ` [PATCH 04/13] x86: Use HAVE_MEMBLOCK_NODE_MAP Tejun Heo
                   ` (12 subsequent siblings)
  15 siblings, 1 reply; 54+ messages in thread
From: Tejun Heo @ 2011-07-12  9:15 UTC (permalink / raw)
  To: mingo, hpa, tglx, benh, yinghai, davem
  Cc: linux-kernel, linux-arch, x86, Tejun Heo

Add optional region->nid which can be enabled by arch using
CONFIG_HAVE_MEMBLOCK_NODE_MAP.  When enabled, memblock also carries
NUMA node information and replaces early_node_map[].

Newly added memblocks have MAX_NUMNODES as nid.  Arch can then call
memblock_set_node() to set node information.  memblock takes care of
merging and node affine allocations w.r.t. node information.

When MEMBLOCK_NODE_MAP is enabled, early_node_map[], related data
structures and functions to manipulate and iterate it are disabled.
memblock version of __next_mem_pfn_range() is provided such that
for_each_mem_pfn_range() behaves the same and its users don't have to
be updated.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 include/linux/memblock.h |   26 +++++++++
 include/linux/mm.h       |    2 +
 mm/Kconfig               |    3 +
 mm/memblock.c            |  141 ++++++++++++++++++++++++++++++++++++++++------
 mm/page_alloc.c          |   47 +++++++++------
 5 files changed, 182 insertions(+), 37 deletions(-)

diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index aa5df9e..e78a9ad 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -24,6 +24,9 @@
 struct memblock_region {
 	phys_addr_t base;
 	phys_addr_t size;
+#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
+	int nid;
+#endif
 };
 
 struct memblock_type {
@@ -58,6 +61,29 @@ extern long memblock_remove(phys_addr_t base, phys_addr_t size);
 extern long memblock_free(phys_addr_t base, phys_addr_t size);
 extern long memblock_reserve(phys_addr_t base, phys_addr_t size);
 
+#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
+extern int memblock_set_node(phys_addr_t base, phys_addr_t size, int nid);
+
+static inline void memblock_set_region_node(struct memblock_region *r, int nid)
+{
+	r->nid = nid;
+}
+
+static inline int memblock_get_region_node(const struct memblock_region *r)
+{
+	return r->nid;
+}
+#else
+static inline void memblock_set_region_node(struct memblock_region *r, int nid)
+{
+}
+
+static inline int memblock_get_region_node(const struct memblock_region *r)
+{
+	return 0;
+}
+#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
+
 /* The numa aware allocator is only available if
  * CONFIG_ARCH_POPULATES_NODE_MAP is set
  */
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 9ebc65a..ceb1e4a 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1307,12 +1307,14 @@ extern void free_area_init_node(int nid, unsigned long * zones_size,
  * CONFIG_ARCH_POPULATES_NODE_MAP
  */
 extern void free_area_init_nodes(unsigned long *max_zone_pfn);
+#ifndef CONFIG_HAVE_MEMBLOCK_NODE_MAP
 extern void add_active_range(unsigned int nid, unsigned long start_pfn,
 					unsigned long end_pfn);
 extern void remove_active_range(unsigned int nid, unsigned long start_pfn,
 					unsigned long end_pfn);
 extern void remove_all_active_ranges(void);
 void sort_node_map(void);
+#endif
 unsigned long node_map_pfn_alignment(void);
 unsigned long __absent_pages_in_range(int nid, unsigned long start_pfn,
 						unsigned long end_pfn);
diff --git a/mm/Kconfig b/mm/Kconfig
index 8ca47a5..30a5d47 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -131,6 +131,9 @@ config SPARSEMEM_VMEMMAP
 config HAVE_MEMBLOCK
 	boolean
 
+config HAVE_MEMBLOCK_NODE_MAP
+	boolean
+
 # eventually, we can have this option just 'select SPARSEMEM'
 config MEMORY_HOTPLUG
 	bool "Allow for memory hot-add"
diff --git a/mm/memblock.c b/mm/memblock.c
index 992aa18..766adec 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -161,12 +161,8 @@ int __init_memblock memblock_reserve_reserved_regions(void)
 
 static void __init_memblock memblock_remove_region(struct memblock_type *type, unsigned long r)
 {
-	unsigned long i;
-
-	for (i = r; i < type->cnt - 1; i++) {
-		type->regions[i].base = type->regions[i + 1].base;
-		type->regions[i].size = type->regions[i + 1].size;
-	}
+	memmove(&type->regions[r], &type->regions[r + 1],
+		(type->cnt - (r + 1)) * sizeof(type->regions[r]));
 	type->cnt--;
 
 	/* Special case for empty arrays */
@@ -174,6 +170,7 @@ static void __init_memblock memblock_remove_region(struct memblock_type *type, u
 		type->cnt = 1;
 		type->regions[0].base = 0;
 		type->regions[0].size = 0;
+		memblock_set_region_node(&type->regions[0], MAX_NUMNODES);
 	}
 }
 
@@ -266,7 +263,9 @@ static void __init_memblock memblock_merge_regions(struct memblock_type *type)
 		struct memblock_region *this = &type->regions[i];
 		struct memblock_region *next = &type->regions[i + 1];
 
-		if (this->base + this->size != next->base) {
+		if (this->base + this->size != next->base ||
+		    memblock_get_region_node(this) !=
+		    memblock_get_region_node(next)) {
 			BUG_ON(this->base + this->size > next->base);
 			i++;
 			continue;
@@ -290,7 +289,7 @@ static void __init_memblock memblock_merge_regions(struct memblock_type *type)
  */
 static void __init_memblock memblock_insert_region(struct memblock_type *type,
 						   int idx, phys_addr_t base,
-						   phys_addr_t size)
+						   phys_addr_t size, int nid)
 {
 	struct memblock_region *rgn = &type->regions[idx];
 
@@ -298,6 +297,7 @@ static void __init_memblock memblock_insert_region(struct memblock_type *type,
 	memmove(rgn + 1, rgn, (type->cnt - idx) * sizeof(*rgn));
 	rgn->base = base;
 	rgn->size = size;
+	memblock_set_region_node(rgn, nid);
 	type->cnt++;
 }
 
@@ -327,6 +327,7 @@ static long __init_memblock memblock_add_region(struct memblock_type *type,
 		WARN_ON(type->cnt != 1);
 		type->regions[0].base = base;
 		type->regions[0].size = size;
+		memblock_set_region_node(&type->regions[0], MAX_NUMNODES);
 		return 0;
 	}
 repeat:
@@ -355,7 +356,7 @@ repeat:
 			nr_new++;
 			if (insert)
 				memblock_insert_region(type, i++, base,
-						       rbase - base);
+						rbase - base, MAX_NUMNODES);
 		}
 		/* area below @rend is dealt with, forget about it */
 		base = min(rend, end);
@@ -365,7 +366,8 @@ repeat:
 	if (base < end) {
 		nr_new++;
 		if (insert)
-			memblock_insert_region(type, i, base, end - base);
+			memblock_insert_region(type, i, base, end - base,
+					       MAX_NUMNODES);
 	}
 
 	/*
@@ -459,6 +461,100 @@ long __init_memblock memblock_reserve(phys_addr_t base, phys_addr_t size)
 	return memblock_add_region(_rgn, base, size);
 }
 
+#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
+/*
+ * Common iterator interface used to define for_each_mem_range().
+ */
+void __init_memblock __next_mem_pfn_range(int *idx, int nid,
+				unsigned long *out_start_pfn,
+				unsigned long *out_end_pfn, int *out_nid)
+{
+	struct memblock_type *type = &memblock.memory;
+	struct memblock_region *r;
+
+	while (++*idx < type->cnt) {
+		r = &type->regions[*idx];
+
+		if (PFN_UP(r->base) >= PFN_DOWN(r->base + r->size))
+			continue;
+		if (nid == MAX_NUMNODES || nid == r->nid)
+			break;
+	}
+	if (*idx >= type->cnt) {
+		*idx = -1;
+		return;
+	}
+
+	if (out_start_pfn)
+		*out_start_pfn = PFN_UP(r->base);
+	if (out_end_pfn)
+		*out_end_pfn = PFN_DOWN(r->base + r->size);
+	if (out_nid)
+		*out_nid = r->nid;
+}
+
+/**
+ * memblock_set_node - set node ID on memblock regions
+ * @base: base of area to set node ID for
+ * @size: size of area to set node ID for
+ * @nid: node ID to set
+ *
+ * Set the nid of memblock memory regions in [@base,@base+@size) to @nid.
+ * Regions which cross the area boundaries are split as necessary.
+ *
+ * RETURNS:
+ * 0 on success, -errno on failure.
+ */
+int memblock_set_node(phys_addr_t base, phys_addr_t size, int nid)
+{
+	struct memblock_type *type = &memblock.memory;
+	phys_addr_t end = base + size;
+	int i;
+
+	/* we'll create at most two more regions */
+	while (type->cnt + 2 > type->max)
+		if (memblock_double_array(type) < 0)
+			return -ENOMEM;
+
+	for (i = 0; i < type->cnt; i++) {
+		struct memblock_region *rgn = &type->regions[i];
+		phys_addr_t rbase = rgn->base;
+		phys_addr_t rend = rbase + rgn->size;
+
+		if (rbase >= end)
+			break;
+		if (rend <= base)
+			continue;
+
+		if (rbase < base) {
+			/*
+			 * @rgn intersects from below.  Split and continue
+			 * to process the next region - the new top half.
+			 */
+			rgn->base = base;
+			rgn->size = rend - rgn->base;
+			memblock_insert_region(type, i, rbase, base - rbase,
+					       rgn->nid);
+		} else if (rend > end) {
+			/*
+			 * @rgn intersects from above.  Split and redo the
+			 * current region - the new bottom half.
+			 */
+			rgn->base = end;
+			rgn->size = rend - rgn->base;
+			memblock_insert_region(type, i--, rbase, end - rbase,
+					       rgn->nid);
+		} else {
+			/* @rgn is fully contained, set ->nid */
+			rgn->nid = nid;
+		}
+	}
+
+	memblock_merge_regions(type);
+	return 0;
+}
+#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
+
 phys_addr_t __init __memblock_alloc_base(phys_addr_t size, phys_addr_t align, phys_addr_t max_addr)
 {
 	phys_addr_t found;
@@ -689,19 +785,26 @@ void __init_memblock memblock_set_current_limit(phys_addr_t limit)
 	memblock.current_limit = limit;
 }
 
-static void __init_memblock memblock_dump(struct memblock_type *region, char *name)
+static void __init_memblock memblock_dump(struct memblock_type *type, char *name)
 {
 	unsigned long long base, size;
 	int i;
 
-	pr_info(" %s.cnt  = 0x%lx\n", name, region->cnt);
-
-	for (i = 0; i < region->cnt; i++) {
-		base = region->regions[i].base;
-		size = region->regions[i].size;
+	pr_info(" %s.cnt  = 0x%lx\n", name, type->cnt);
 
-		pr_info(" %s[%#x]\t[%#016llx-%#016llx], %#llx bytes\n",
-		    name, i, base, base + size - 1, size);
+	for (i = 0; i < type->cnt; i++) {
+		struct memblock_region *rgn = &type->regions[i];
+		char nid_buf[32] = "";
+
+		base = rgn->base;
+		size = rgn->size;
+#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
+		if (memblock_get_region_node(rgn) != MAX_NUMNODES)
+			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",
+			name, i, base, base + size - 1, size, nid_buf);
 	}
 }
 
@@ -759,11 +862,13 @@ void __init memblock_init(void)
 	 */
 	memblock.memory.regions[0].base = 0;
 	memblock.memory.regions[0].size = 0;
+	memblock_set_region_node(&memblock.memory.regions[0], MAX_NUMNODES);
 	memblock.memory.cnt = 1;
 
 	/* Ditto. */
 	memblock.reserved.regions[0].base = 0;
 	memblock.reserved.regions[0].size = 0;
+	memblock_set_region_node(&memblock.reserved.regions[0], MAX_NUMNODES);
 	memblock.reserved.cnt = 1;
 
 	memblock.current_limit = MEMBLOCK_ALLOC_ANYWHERE;
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 8ab5e5e..3c7ea45 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -182,28 +182,31 @@ static unsigned long __meminitdata nr_all_pages;
 static unsigned long __meminitdata dma_reserve;
 
 #ifdef CONFIG_ARCH_POPULATES_NODE_MAP
-  /*
-   * MAX_ACTIVE_REGIONS determines the maximum number of distinct
-   * ranges of memory (RAM) that may be registered with add_active_range().
-   * Ranges passed to add_active_range() will be merged if possible
-   * so the number of times add_active_range() can be called is
-   * related to the number of nodes and the number of holes
-   */
-  #ifdef CONFIG_MAX_ACTIVE_REGIONS
-    /* Allow an architecture to set MAX_ACTIVE_REGIONS to save memory */
-    #define MAX_ACTIVE_REGIONS CONFIG_MAX_ACTIVE_REGIONS
-  #else
-    #if MAX_NUMNODES >= 32
-      /* If there can be many nodes, allow up to 50 holes per node */
-      #define MAX_ACTIVE_REGIONS (MAX_NUMNODES*50)
+  #ifndef CONFIG_HAVE_MEMBLOCK_NODE_MAP
+    /*
+     * MAX_ACTIVE_REGIONS determines the maximum number of distinct ranges
+     * of memory (RAM) that may be registered with add_active_range().
+     * Ranges passed to add_active_range() will be merged if possible so
+     * the number of times add_active_range() can be called is related to
+     * the number of nodes and the number of holes
+     */
+    #ifdef CONFIG_MAX_ACTIVE_REGIONS
+      /* Allow an architecture to set MAX_ACTIVE_REGIONS to save memory */
+      #define MAX_ACTIVE_REGIONS CONFIG_MAX_ACTIVE_REGIONS
     #else
-      /* By default, allow up to 256 distinct regions */
-      #define MAX_ACTIVE_REGIONS 256
+      #if MAX_NUMNODES >= 32
+        /* If there can be many nodes, allow up to 50 holes per node */
+        #define MAX_ACTIVE_REGIONS (MAX_NUMNODES*50)
+      #else
+        /* By default, allow up to 256 distinct regions */
+        #define MAX_ACTIVE_REGIONS 256
+      #endif
     #endif
-  #endif
 
-  static struct node_active_region __meminitdata early_node_map[MAX_ACTIVE_REGIONS];
-  static int __meminitdata nr_nodemap_entries;
+    static struct node_active_region __meminitdata early_node_map[MAX_ACTIVE_REGIONS];
+    static int __meminitdata nr_nodemap_entries;
+#endif /* !CONFIG_HAVE_MEMBLOCK_NODE_MAP */
+
   static unsigned long __meminitdata arch_zone_lowest_possible_pfn[MAX_NR_ZONES];
   static unsigned long __meminitdata arch_zone_highest_possible_pfn[MAX_NR_ZONES];
   static unsigned long __initdata required_kernelcore;
@@ -4268,6 +4271,7 @@ static inline void setup_nr_node_ids(void)
 }
 #endif
 
+#ifndef CONFIG_HAVE_MEMBLOCK_NODE_MAP
 /*
  * Common iterator interface used to define for_each_mem_pfn_range().
  */
@@ -4456,6 +4460,11 @@ void __init sort_node_map(void)
 			sizeof(struct node_active_region),
 			cmp_node_active_region, NULL);
 }
+#else /* !CONFIG_HAVE_MEMBLOCK_NODE_MAP */
+static inline void sort_node_map(void)
+{
+}
+#endif
 
 /**
  * node_map_pfn_alignment - determine the maximum internode alignment
-- 
1.7.6


^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH 04/13] x86: Use HAVE_MEMBLOCK_NODE_MAP
  2011-07-12  9:15 [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Tejun Heo
                   ` (2 preceding siblings ...)
  2011-07-12  9:15 ` [PATCH 03/13] memblock: Add optional region->nid Tejun Heo
@ 2011-07-12  9:15 ` Tejun Heo
  2011-07-14  1:35   ` H. Peter Anvin
  2011-07-14  9:44   ` [PATCH UPDATED " Tejun Heo
  2011-07-12  9:15 ` [PATCH 05/13] x86: Use __memblock_alloc_base() in early_reserve_e820() Tejun Heo
                   ` (11 subsequent siblings)
  15 siblings, 2 replies; 54+ messages in thread
From: Tejun Heo @ 2011-07-12  9:15 UTC (permalink / raw)
  To: mingo, hpa, tglx, benh, yinghai, davem
  Cc: linux-kernel, linux-arch, x86, Tejun Heo

Convert x86 to HAVE_MEMBLOCK_NODE_MAP.  The only difference in memory
handling is that allocations can't no longer cross node boundaries
whether they're node affine or not, which shouldn't matter at all.

This conversion will enable further simplification of boot memory
handling.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
 arch/x86/Kconfig                |    1 +
 arch/x86/include/asm/memblock.h |    2 --
 arch/x86/mm/memblock.c          |   14 --------------
 arch/x86/mm/numa.c              |   15 +++++++--------
 4 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 37357a5..91aa1b4e 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -25,6 +25,7 @@ config X86
 	select HAVE_IOREMAP_PROT
 	select HAVE_KPROBES
 	select HAVE_MEMBLOCK
+	select HAVE_MEMBLOCK_NODE_MAP
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	select ARCH_WANT_FRAME_POINTERS
 	select HAVE_DMA_ATTRS
diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h
index 161792e..1460db2 100644
--- a/arch/x86/include/asm/memblock.h
+++ b/arch/x86/include/asm/memblock.h
@@ -12,8 +12,6 @@ int __get_free_all_memory_range(struct range **range, int nodeid,
 			 unsigned long start_pfn, unsigned long end_pfn);
 int get_free_all_memory_range(struct range **rangep, int nodeid);
 
-void memblock_x86_register_active_regions(int nid, unsigned long start_pfn,
-					 unsigned long last_pfn);
 u64 memblock_x86_hole_size(u64 start, u64 end);
 u64 memblock_x86_free_memory_in_range(u64 addr, u64 limit);
 u64 memblock_x86_memory_in_range(u64 addr, u64 limit);
diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c
index e4569f8..97fbc39 100644
--- a/arch/x86/mm/memblock.c
+++ b/arch/x86/mm/memblock.c
@@ -283,20 +283,6 @@ static int __init memblock_x86_find_active_region(const struct memblock_region *
 	return 1;
 }
 
-/* Walk the memblock.memory map and register active regions within a node */
-void __init memblock_x86_register_active_regions(int nid, unsigned long start_pfn,
-					 unsigned long last_pfn)
-{
-	unsigned long ei_startpfn;
-	unsigned long ei_endpfn;
-	struct memblock_region *r;
-
-	for_each_memblock(memory, r)
-		if (memblock_x86_find_active_region(r, start_pfn, last_pfn,
-					   &ei_startpfn, &ei_endpfn))
-			add_active_range(nid, ei_startpfn, ei_endpfn);
-}
-
 /*
  * Find the hole size (in bytes) in the memory range.
  * @start: starting address of the memory range to scan
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index 824efad..f4a40bd 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -498,13 +498,10 @@ static int __init numa_register_memblks(struct numa_meminfo *mi)
 	if (WARN_ON(nodes_empty(node_possible_map)))
 		return -EINVAL;
 
-	for (i = 0; i < mi->nr_blks; i++)
-		memblock_x86_register_active_regions(mi->blk[i].nid,
-					mi->blk[i].start >> PAGE_SHIFT,
-					mi->blk[i].end >> PAGE_SHIFT);
-
-	/* for out of order entries */
-	sort_node_map();
+	for (i = 0; i < mi->nr_blks; i++) {
+		struct numa_memblk *mb = &mi->blk[i];
+		memblock_set_node(mb->start, mb->end - mb->start, mb->nid);
+	}
 
 	/*
 	 * If sections array is gonna be used for pfn -> nid mapping, check
@@ -538,6 +535,8 @@ static int __init numa_register_memblks(struct numa_meminfo *mi)
 			setup_node_data(nid, start, end);
 	}
 
+	/* Dump memblock with node info and return. */
+	memblock_dump_all();
 	return 0;
 }
 
@@ -575,7 +574,7 @@ static int __init numa_init(int (*init_func)(void))
 	nodes_clear(node_possible_map);
 	nodes_clear(node_online_map);
 	memset(&numa_meminfo, 0, sizeof(numa_meminfo));
-	remove_all_active_ranges();
+	WARN_ON(memblock_set_node(0, ULLONG_MAX, MAX_NUMNODES));
 	numa_reset_distance();
 
 	ret = init_func();
-- 
1.7.6


^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH 05/13] x86: Use __memblock_alloc_base() in early_reserve_e820()
  2011-07-12  9:15 [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Tejun Heo
                   ` (3 preceding siblings ...)
  2011-07-12  9:15 ` [PATCH 04/13] x86: Use HAVE_MEMBLOCK_NODE_MAP Tejun Heo
@ 2011-07-12  9:15 ` Tejun Heo
  2011-07-14 21:33   ` [tip:x86/memblock] " tip-bot for Tejun Heo
  2011-07-12  9:15 ` [PATCH 06/13] memblock: Implement for_each_free_mem_range() Tejun Heo
                   ` (10 subsequent siblings)
  15 siblings, 1 reply; 54+ messages in thread
From: Tejun Heo @ 2011-07-12  9:15 UTC (permalink / raw)
  To: mingo, hpa, tglx, benh, yinghai, davem
  Cc: linux-kernel, linux-arch, x86, Tejun Heo

early_reserve_e820() implements its own ad-hoc early allocator using
memblock_x86_find_in_range_size().  Use __memblock_alloc_base()
instead and remove the unnecessary @startt parameter (it's top-down
allocation anyway).

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
 arch/x86/include/asm/e820.h |    2 +-
 arch/x86/kernel/e820.c      |   30 ++++++------------------------
 arch/x86/kernel/mpparse.c   |    6 ++----
 3 files changed, 9 insertions(+), 29 deletions(-)

diff --git a/arch/x86/include/asm/e820.h b/arch/x86/include/asm/e820.h
index 908b969..3778256 100644
--- a/arch/x86/include/asm/e820.h
+++ b/arch/x86/include/asm/e820.h
@@ -117,7 +117,7 @@ static inline void early_memtest(unsigned long start, unsigned long end)
 
 extern unsigned long e820_end_of_ram_pfn(void);
 extern unsigned long e820_end_of_low_ram_pfn(void);
-extern u64 early_reserve_e820(u64 startt, u64 sizet, u64 align);
+extern u64 early_reserve_e820(u64 sizet, u64 align);
 
 void memblock_x86_fill(void);
 void memblock_find_dma_reserve(void);
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 0f9ff58..b99d940 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -737,35 +737,17 @@ core_initcall(e820_mark_nvs_memory);
 /*
  * pre allocated 4k and reserved it in memblock and e820_saved
  */
-u64 __init early_reserve_e820(u64 startt, u64 sizet, u64 align)
+u64 __init early_reserve_e820(u64 size, u64 align)
 {
-	u64 size = 0;
 	u64 addr;
-	u64 start;
 
-	for (start = startt; ; start += size) {
-		start = memblock_x86_find_in_range_size(start, &size, align);
-		if (!start)
-			return 0;
-		if (size >= sizet)
-			break;
+	addr = __memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ACCESSIBLE);
+	if (addr) {
+		e820_update_range_saved(addr, size, E820_RAM, E820_RESERVED);
+		printk(KERN_INFO "update e820_saved for early_reserve_e820\n");
+		update_e820_saved();
 	}
 
-#ifdef CONFIG_X86_32
-	if (start >= MAXMEM)
-		return 0;
-	if (start + size > MAXMEM)
-		size = MAXMEM - start;
-#endif
-
-	addr = round_down(start + size - sizet, align);
-	if (addr < start)
-		return 0;
-	memblock_x86_reserve_range(addr, addr + sizet, "new next");
-	e820_update_range_saved(addr, sizet, E820_RAM, E820_RESERVED);
-	printk(KERN_INFO "update e820_saved for early_reserve_e820\n");
-	update_e820_saved();
-
 	return addr;
 }
 
diff --git a/arch/x86/kernel/mpparse.c b/arch/x86/kernel/mpparse.c
index 9103b89..8faeaa0 100644
--- a/arch/x86/kernel/mpparse.c
+++ b/arch/x86/kernel/mpparse.c
@@ -836,10 +836,8 @@ early_param("alloc_mptable", parse_alloc_mptable_opt);
 
 void __init early_reserve_e820_mpc_new(void)
 {
-	if (enable_update_mptable && alloc_mptable) {
-		u64 startt = 0;
-		mpc_new_phys = early_reserve_e820(startt, mpc_new_length, 4);
-	}
+	if (enable_update_mptable && alloc_mptable)
+		mpc_new_phys = early_reserve_e820(mpc_new_length, 4);
 }
 
 static int __init update_mp_table(void)
-- 
1.7.6


^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH 06/13] memblock: Implement for_each_free_mem_range()
  2011-07-12  9:15 [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Tejun Heo
                   ` (4 preceding siblings ...)
  2011-07-12  9:15 ` [PATCH 05/13] x86: Use __memblock_alloc_base() in early_reserve_e820() Tejun Heo
@ 2011-07-12  9:15 ` Tejun Heo
  2011-07-14 21:34   ` [tip:x86/memblock] " tip-bot for Tejun Heo
  2011-07-12  9:16 ` [PATCH 07/13] x86: Replace memblock_x86_find_in_range_size() with for_each_free_mem_range() Tejun Heo
                   ` (9 subsequent siblings)
  15 siblings, 1 reply; 54+ messages in thread
From: Tejun Heo @ 2011-07-12  9:15 UTC (permalink / raw)
  To: mingo, hpa, tglx, benh, yinghai, davem
  Cc: linux-kernel, linux-arch, x86, Tejun Heo

Implement for_each_free_mem_range() which iterates over free memory
areas according to memblock (memory && !reserved).  This will be used
to simplify memblock users.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 include/linux/memblock.h |   20 ++++++++++++
 mm/memblock.c            |   76 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 96 insertions(+), 0 deletions(-)

diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index e78a9ad..013dfe0 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -61,6 +61,26 @@ extern long memblock_remove(phys_addr_t base, phys_addr_t size);
 extern long memblock_free(phys_addr_t base, phys_addr_t size);
 extern long memblock_reserve(phys_addr_t base, phys_addr_t size);
 
+extern void __next_free_mem_range(u64 *idx, int nid, phys_addr_t *out_start,
+				  phys_addr_t *out_end, int *out_nid);
+
+/**
+ * for_each_free_mem_range - iterate through free memblock areas
+ * @i: u64 used as loop variable
+ * @nid: node selector, %MAX_NUMNODES for all nodes
+ * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL
+ * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL
+ * @p_nid: ptr to int for nid of the range, can be %NULL
+ *
+ * Walks over free (memory && !reserved) areas of memblock.  Available as
+ * soon as memblock is initialized.
+ */
+#define for_each_free_mem_range(i, nid, p_start, p_end, p_nid)		\
+	for (i = 0,							\
+	     __next_free_mem_range(&i, nid, p_start, p_end, p_nid);	\
+	     i != (u64)ULLONG_MAX;					\
+	     __next_free_mem_range(&i, nid, p_start, p_end, p_nid))
+
 #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
 extern int memblock_set_node(phys_addr_t base, phys_addr_t size, int nid);
 
diff --git a/mm/memblock.c b/mm/memblock.c
index 766adec..4d318bf 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -461,6 +461,82 @@ long __init_memblock memblock_reserve(phys_addr_t base, phys_addr_t size)
 	return memblock_add_region(_rgn, base, size);
 }
 
+/**
+ * __next_free_mem_range - next function for for_each_free_mem_range()
+ * @idx: pointer to u64 loop variable
+ * @nid: nid: node selector, %MAX_NUMNODES for all nodes
+ * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL
+ * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL
+ * @p_nid: ptr to int for nid of the range, can be %NULL
+ *
+ * Find the first free area from *@idx which matches @nid, fill the out
+ * parameters, and update *@idx for the next iteration.  The lower 32bit of
+ * *@idx contains index into memory region and the upper 32bit indexes the
+ * areas before each reserved region.  For example, if reserved regions
+ * look like the following,
+ *
+ *	0:[0-16), 1:[32-48), 2:[128-130)
+ *
+ * The upper 32bit indexes the following regions.
+ *
+ *	0:[0-0), 1:[16-32), 2:[48-128), 3:[130-MAX)
+ *
+ * As both region arrays are sorted, the function advances the two indices
+ * in lockstep and returns each intersection.
+ */
+void __init_memblock __next_free_mem_range(u64 *idx, int nid,
+					   phys_addr_t *out_start,
+					   phys_addr_t *out_end, int *out_nid)
+{
+	struct memblock_type *mem = &memblock.memory;
+	struct memblock_type *rsv = &memblock.reserved;
+	int mi = *idx & 0xffffffff;
+	int ri = *idx >> 32;
+
+	for ( ; mi < mem->cnt; mi++) {
+		struct memblock_region *m = &mem->regions[mi];
+		phys_addr_t m_start = m->base;
+		phys_addr_t m_end = m->base + m->size;
+
+		/* only memory regions are associated with nodes, check it */
+		if (nid != MAX_NUMNODES && nid != memblock_get_region_node(m))
+			continue;
+
+		/* scan areas before each reservation for intersection */
+		for ( ; ri < rsv->cnt + 1; ri++) {
+			struct memblock_region *r = &rsv->regions[ri];
+			phys_addr_t r_start = ri ? r[-1].base + r[-1].size : 0;
+			phys_addr_t r_end = ri < rsv->cnt ? r->base : ULLONG_MAX;
+
+			/* if ri advanced past mi, break out to advance mi */
+			if (r_start >= m_end)
+				break;
+			/* if the two regions intersect, we're done */
+			if (m_start < r_end) {
+				if (out_start)
+					*out_start = max(m_start, r_start);
+				if (out_end)
+					*out_end = min(m_end, r_end);
+				if (out_nid)
+					*out_nid = memblock_get_region_node(m);
+				/*
+				 * The region which ends first is advanced
+				 * for the next iteration.
+				 */
+				if (m_end <= r_end)
+					mi++;
+				else
+					ri++;
+				*idx = (u32)mi | (u64)ri << 32;
+				return;
+			}
+		}
+	}
+
+	/* signal end of iteration */
+	*idx = ULLONG_MAX;
+}
+
 #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
 /*
  * Common iterator interface used to define for_each_mem_range().
-- 
1.7.6


^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH 07/13] x86: Replace memblock_x86_find_in_range_size() with for_each_free_mem_range()
  2011-07-12  9:15 [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Tejun Heo
                   ` (5 preceding siblings ...)
  2011-07-12  9:15 ` [PATCH 06/13] memblock: Implement for_each_free_mem_range() Tejun Heo
@ 2011-07-12  9:16 ` Tejun Heo
  2011-07-14 21:34   ` [tip:x86/memblock] " tip-bot for Tejun Heo
  2011-07-12  9:16 ` [PATCH 08/13] memblock, x86: Make free_all_memory_core_early() explicitly free lowmem only Tejun Heo
                   ` (8 subsequent siblings)
  15 siblings, 1 reply; 54+ messages in thread
From: Tejun Heo @ 2011-07-12  9:16 UTC (permalink / raw)
  To: mingo, hpa, tglx, benh, yinghai, davem
  Cc: linux-kernel, linux-arch, x86, Tejun Heo

setup_bios_corruption_check() and memtest do_one_pass() open code
memblock free area iteration using memblock_x86_find_in_range_size().
Convert them to use for_each_free_mem_range() instead.

This leaves memblock_x86_find_in_range_size() and
memblock_x86_check_reserved_size() unused.  Kill them.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
 arch/x86/include/asm/memblock.h |    3 --
 arch/x86/kernel/check.c         |   34 +++++++++------------
 arch/x86/mm/memblock.c          |   62 ---------------------------------------
 arch/x86/mm/memtest.c           |   31 ++++++++-----------
 4 files changed, 28 insertions(+), 102 deletions(-)

diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h
index 1460db2..d2a5a59 100644
--- a/arch/x86/include/asm/memblock.h
+++ b/arch/x86/include/asm/memblock.h
@@ -3,8 +3,6 @@
 
 #define ARCH_DISCARD_MEMBLOCK
 
-u64 memblock_x86_find_in_range_size(u64 start, u64 *sizep, u64 align);
-
 void memblock_x86_reserve_range(u64 start, u64 end, char *name);
 void memblock_x86_free_range(u64 start, u64 end);
 struct range;
@@ -15,6 +13,5 @@ int get_free_all_memory_range(struct range **rangep, int nodeid);
 u64 memblock_x86_hole_size(u64 start, u64 end);
 u64 memblock_x86_free_memory_in_range(u64 addr, u64 limit);
 u64 memblock_x86_memory_in_range(u64 addr, u64 limit);
-bool memblock_x86_check_reserved_size(u64 *addrp, u64 *sizep, u64 align);
 
 #endif
diff --git a/arch/x86/kernel/check.c b/arch/x86/kernel/check.c
index 95680fc..621cd23 100644
--- a/arch/x86/kernel/check.c
+++ b/arch/x86/kernel/check.c
@@ -62,7 +62,8 @@ early_param("memory_corruption_check_size", set_corruption_check_size);
 
 void __init setup_bios_corruption_check(void)
 {
-	u64 addr = PAGE_SIZE;	/* assume first page is reserved anyway */
+	phys_addr_t start, end;
+	u64 i;
 
 	if (memory_corruption_check == -1) {
 		memory_corruption_check =
@@ -82,28 +83,23 @@ void __init setup_bios_corruption_check(void)
 
 	corruption_check_size = round_up(corruption_check_size, PAGE_SIZE);
 
-	while (addr < corruption_check_size && num_scan_areas < MAX_SCAN_AREAS) {
-		u64 size;
-		addr = memblock_x86_find_in_range_size(addr, &size, PAGE_SIZE);
+	for_each_free_mem_range(i, MAX_NUMNODES, &start, &end, NULL) {
+		start = clamp_t(phys_addr_t, round_up(start, PAGE_SIZE),
+				PAGE_SIZE, corruption_check_size);
+		end = clamp_t(phys_addr_t, round_down(end, PAGE_SIZE),
+			      PAGE_SIZE, corruption_check_size);
+		if (start >= end)
+			continue;
 
-		if (!addr)
-			break;
-
-		if (addr >= corruption_check_size)
-			break;
-
-		if ((addr + size) > corruption_check_size)
-			size = corruption_check_size - addr;
-
-		memblock_x86_reserve_range(addr, addr + size, "SCAN RAM");
-		scan_areas[num_scan_areas].addr = addr;
-		scan_areas[num_scan_areas].size = size;
-		num_scan_areas++;
+		memblock_x86_reserve_range(start, end, "SCAN RAM");
+		scan_areas[num_scan_areas].addr = start;
+		scan_areas[num_scan_areas].size = end - start;
 
 		/* Assume we've already mapped this early memory */
-		memset(__va(addr), 0, size);
+		memset(__va(start), 0, end - start);
 
-		addr += size;
+		if (++num_scan_areas >= MAX_SCAN_AREAS)
+			break;
 	}
 
 	if (num_scan_areas)
diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c
index 97fbc39..648d47d 100644
--- a/arch/x86/mm/memblock.c
+++ b/arch/x86/mm/memblock.c
@@ -7,68 +7,6 @@
 #include <linux/mm.h>
 #include <linux/range.h>
 
-/* Check for already reserved areas */
-bool __init memblock_x86_check_reserved_size(u64 *addrp, u64 *sizep, u64 align)
-{
-	struct memblock_region *r;
-	u64 addr = *addrp, last;
-	u64 size = *sizep;
-	bool changed = false;
-
-again:
-	last = addr + size;
-	for_each_memblock(reserved, r) {
-		if (last > r->base && addr < r->base) {
-			size = r->base - addr;
-			changed = true;
-			goto again;
-		}
-		if (last > (r->base + r->size) && addr < (r->base + r->size)) {
-			addr = round_up(r->base + r->size, align);
-			size = last - addr;
-			changed = true;
-			goto again;
-		}
-		if (last <= (r->base + r->size) && addr >= r->base) {
-			*sizep = 0;
-			return false;
-		}
-	}
-	if (changed) {
-		*addrp = addr;
-		*sizep = size;
-	}
-	return changed;
-}
-
-/*
- * Find next free range after start, and size is returned in *sizep
- */
-u64 __init memblock_x86_find_in_range_size(u64 start, u64 *sizep, u64 align)
-{
-	struct memblock_region *r;
-
-	for_each_memblock(memory, r) {
-		u64 ei_start = r->base;
-		u64 ei_last = ei_start + r->size;
-		u64 addr;
-
-		addr = round_up(ei_start, align);
-		if (addr < start)
-			addr = round_up(start, align);
-		if (addr >= ei_last)
-			continue;
-		*sizep = ei_last - addr;
-		while (memblock_x86_check_reserved_size(&addr, sizep, align))
-			;
-
-		if (*sizep)
-			return addr;
-	}
-
-	return 0;
-}
-
 static __init struct range *find_range_array(int count)
 {
 	u64 end, size, mem;
diff --git a/arch/x86/mm/memtest.c b/arch/x86/mm/memtest.c
index 92faf3a..46a5ff2 100644
--- a/arch/x86/mm/memtest.c
+++ b/arch/x86/mm/memtest.c
@@ -70,24 +70,19 @@ static void __init memtest(u64 pattern, u64 start_phys, u64 size)
 
 static void __init do_one_pass(u64 pattern, u64 start, u64 end)
 {
-	u64 size = 0;
-
-	while (start < end) {
-		start = memblock_x86_find_in_range_size(start, &size, 1);
-
-		/* done ? */
-		if (start >= end)
-			break;
-		if (start + size > end)
-			size = end - start;
-
-		printk(KERN_INFO "  %010llx - %010llx pattern %016llx\n",
-		       (unsigned long long) start,
-		       (unsigned long long) start + size,
-		       (unsigned long long) cpu_to_be64(pattern));
-		memtest(pattern, start, size);
-
-		start += size;
+	u64 i;
+	phys_addr_t this_start, this_end;
+
+	for_each_free_mem_range(i, MAX_NUMNODES, &this_start, &this_end, NULL) {
+		this_start = clamp_t(phys_addr_t, this_start, start, end);
+		this_end = clamp_t(phys_addr_t, this_end, start, end);
+		if (this_start < this_end) {
+			printk(KERN_INFO "  %010llx - %010llx pattern %016llx\n",
+			       (unsigned long long)this_start,
+			       (unsigned long long)this_end,
+			       (unsigned long long)cpu_to_be64(pattern));
+			memtest(pattern, this_start, this_end - this_start);
+		}
 	}
 }
 
-- 
1.7.6


^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH 08/13] memblock, x86: Make free_all_memory_core_early() explicitly free lowmem only
  2011-07-12  9:15 [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Tejun Heo
                   ` (6 preceding siblings ...)
  2011-07-12  9:16 ` [PATCH 07/13] x86: Replace memblock_x86_find_in_range_size() with for_each_free_mem_range() Tejun Heo
@ 2011-07-12  9:16 ` Tejun Heo
  2011-07-14 21:35   ` [tip:x86/memblock] " tip-bot for Tejun Heo
  2011-07-12  9:16 ` [PATCH 09/13] memblock, x86: Replace __get_free_all_memory_range() with for_each_free_mem_range() Tejun Heo
                   ` (7 subsequent siblings)
  15 siblings, 1 reply; 54+ messages in thread
From: Tejun Heo @ 2011-07-12  9:16 UTC (permalink / raw)
  To: mingo, hpa, tglx, benh, yinghai, davem
  Cc: linux-kernel, linux-arch, x86, Tejun Heo

nomemblock is currently used only by x86 and on x86_32
free_all_memory_core_early() silently freed only the low mem because
get_free_all_memory_range() in arch/x86/mm/memblock.c implicitly
limited range to max_low_pfn.

Rename free_all_memory_core_early() to free_low_memory_core_early()
and make it call __get_free_all_memory_range() and limit the range to
max_low_pfn explicitly.  This makes things clearer and also is
consistent with the bootmem behavior.

This leaves get_free_all_memory_range() without any user.  Kill it.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
 arch/x86/include/asm/memblock.h |    1 -
 arch/x86/mm/memblock.c          |   10 ----------
 arch/x86/mm/numa_64.c           |    2 +-
 include/linux/bootmem.h         |    2 +-
 mm/nobootmem.c                  |    8 ++++----
 5 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h
index d2a5a59..6c72eca 100644
--- a/arch/x86/include/asm/memblock.h
+++ b/arch/x86/include/asm/memblock.h
@@ -8,7 +8,6 @@ void memblock_x86_free_range(u64 start, u64 end);
 struct range;
 int __get_free_all_memory_range(struct range **range, int nodeid,
 			 unsigned long start_pfn, unsigned long end_pfn);
-int get_free_all_memory_range(struct range **rangep, int nodeid);
 
 u64 memblock_x86_hole_size(u64 start, u64 end);
 u64 memblock_x86_free_memory_in_range(u64 addr, u64 limit);
diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c
index 648d47d..0e8442a 100644
--- a/arch/x86/mm/memblock.c
+++ b/arch/x86/mm/memblock.c
@@ -89,16 +89,6 @@ int __init __get_free_all_memory_range(struct range **rangep, int nodeid,
 	return nr_range;
 }
 
-int __init get_free_all_memory_range(struct range **rangep, int nodeid)
-{
-	unsigned long end_pfn = -1UL;
-
-#ifdef CONFIG_X86_32
-	end_pfn = max_low_pfn;
-#endif
-	return __get_free_all_memory_range(rangep, nodeid, 0, end_pfn);
-}
-
 static u64 __init __memblock_x86_memory_in_range(u64 addr, u64 limit, bool get_free)
 {
 	int i, count;
diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c
index dd27f40..92e2711 100644
--- a/arch/x86/mm/numa_64.c
+++ b/arch/x86/mm/numa_64.c
@@ -19,7 +19,7 @@ unsigned long __init numa_free_all_bootmem(void)
 	for_each_online_node(i)
 		pages += free_all_bootmem_node(NODE_DATA(i));
 
-	pages += free_all_memory_core_early(MAX_NUMNODES);
+	pages += free_low_memory_core_early(MAX_NUMNODES);
 
 	return pages;
 }
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index ab344a5..66d3e95 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -44,7 +44,7 @@ extern unsigned long init_bootmem_node(pg_data_t *pgdat,
 				       unsigned long endpfn);
 extern unsigned long init_bootmem(unsigned long addr, unsigned long memend);
 
-unsigned long free_all_memory_core_early(int nodeid);
+extern unsigned long free_low_memory_core_early(int nodeid);
 extern unsigned long free_all_bootmem_node(pg_data_t *pgdat);
 extern unsigned long free_all_bootmem(void);
 
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index c781626..2037a8a 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -106,7 +106,7 @@ static void __init __free_pages_memory(unsigned long start, unsigned long end)
 		__free_pages_bootmem(pfn_to_page(i), 0);
 }
 
-unsigned long __init free_all_memory_core_early(int nodeid)
+unsigned long __init free_low_memory_core_early(int nodeid)
 {
 	int i;
 	u64 start, end;
@@ -114,7 +114,7 @@ unsigned long __init free_all_memory_core_early(int nodeid)
 	struct range *range = NULL;
 	int nr_range;
 
-	nr_range = get_free_all_memory_range(&range, nodeid);
+	nr_range = __get_free_all_memory_range(&range, nodeid, 0, max_low_pfn);
 
 	for (i = 0; i < nr_range; i++) {
 		start = range[i].start;
@@ -136,7 +136,7 @@ unsigned long __init free_all_bootmem_node(pg_data_t *pgdat)
 {
 	register_page_bootmem_info_node(pgdat);
 
-	/* free_all_memory_core_early(MAX_NUMNODES) will be called later */
+	/* free_low_memory_core_early(MAX_NUMNODES) will be called later */
 	return 0;
 }
 
@@ -154,7 +154,7 @@ unsigned long __init free_all_bootmem(void)
 	 * Use MAX_NUMNODES will make sure all ranges in early_node_map[]
 	 *  will be used instead of only Node0 related
 	 */
-	return free_all_memory_core_early(MAX_NUMNODES);
+	return free_low_memory_core_early(MAX_NUMNODES);
 }
 
 /**
-- 
1.7.6


^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH 09/13] memblock, x86: Replace __get_free_all_memory_range() with for_each_free_mem_range()
  2011-07-12  9:15 [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Tejun Heo
                   ` (7 preceding siblings ...)
  2011-07-12  9:16 ` [PATCH 08/13] memblock, x86: Make free_all_memory_core_early() explicitly free lowmem only Tejun Heo
@ 2011-07-12  9:16 ` Tejun Heo
  2011-07-14 21:35   ` [tip:x86/memblock] " tip-bot for Tejun Heo
  2011-07-12  9:16 ` [PATCH 10/13] memblock, x86: Reimplement memblock_find_dma_reserve() using iterators Tejun Heo
                   ` (6 subsequent siblings)
  15 siblings, 1 reply; 54+ messages in thread
From: Tejun Heo @ 2011-07-12  9:16 UTC (permalink / raw)
  To: mingo, hpa, tglx, benh, yinghai, davem
  Cc: linux-kernel, linux-arch, x86, Tejun Heo

__get_free_all_memory_range() walks memblock, calculates free memory
areas and fills in the specified range.  It can be easily replaced
with for_each_free_mem_range().

Convert free_low_memory_core_early() and
add_highpages_with_active_regions() to for_each_free_mem_range().
This leaves __get_free_all_memory_range() without any user.  Kill it
and related functions.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
 arch/x86/include/asm/memblock.h |    3 --
 arch/x86/mm/init_32.c           |   28 +++++++-----------
 arch/x86/mm/memblock.c          |   59 ---------------------------------------
 mm/nobootmem.c                  |   28 ++++++++++--------
 4 files changed, 27 insertions(+), 91 deletions(-)

diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h
index 6c72eca..bc9e44b 100644
--- a/arch/x86/include/asm/memblock.h
+++ b/arch/x86/include/asm/memblock.h
@@ -5,9 +5,6 @@
 
 void memblock_x86_reserve_range(u64 start, u64 end, char *name);
 void memblock_x86_free_range(u64 start, u64 end);
-struct range;
-int __get_free_all_memory_range(struct range **range, int nodeid,
-			 unsigned long start_pfn, unsigned long end_pfn);
 
 u64 memblock_x86_hole_size(u64 start, u64 end);
 u64 memblock_x86_free_memory_in_range(u64 addr, u64 limit);
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 29f7c6d..a631a57 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -427,23 +427,17 @@ static void __init add_one_highpage_init(struct page *page)
 void __init add_highpages_with_active_regions(int nid,
 			 unsigned long start_pfn, unsigned long end_pfn)
 {
-	struct range *range;
-	int nr_range;
-	int i;
-
-	nr_range = __get_free_all_memory_range(&range, nid, start_pfn, end_pfn);
-
-	for (i = 0; i < nr_range; i++) {
-		struct page *page;
-		int node_pfn;
-
-		for (node_pfn = range[i].start; node_pfn < range[i].end;
-		     node_pfn++) {
-			if (!pfn_valid(node_pfn))
-				continue;
-			page = pfn_to_page(node_pfn);
-			add_one_highpage_init(page);
-		}
+	phys_addr_t start, end;
+	u64 i;
+
+	for_each_free_mem_range(i, nid, &start, &end, NULL) {
+		unsigned long pfn = clamp_t(unsigned long, PFN_UP(start),
+					    start_pfn, end_pfn);
+		unsigned long e_pfn = clamp_t(unsigned long, PFN_DOWN(end),
+					      start_pfn, end_pfn);
+		for ( ; pfn < e_pfn; pfn++)
+			if (pfn_valid(pfn))
+				add_one_highpage_init(pfn_to_page(pfn));
 	}
 }
 #else
diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c
index 0e8442a..4107c1a 100644
--- a/arch/x86/mm/memblock.c
+++ b/arch/x86/mm/memblock.c
@@ -30,65 +30,6 @@ static __init struct range *find_range_array(int count)
 	return range;
 }
 
-static void __init memblock_x86_subtract_reserved(struct range *range, int az)
-{
-	u64 final_start, final_end;
-	struct memblock_region *r;
-
-	/* Take out region array itself at first*/
-	memblock_free_reserved_regions();
-
-	memblock_dbg("Subtract (%ld early reservations)\n", memblock.reserved.cnt);
-
-	for_each_memblock(reserved, r) {
-		memblock_dbg("  [%010llx-%010llx]\n", (u64)r->base, (u64)r->base + r->size - 1);
-		final_start = PFN_DOWN(r->base);
-		final_end = PFN_UP(r->base + r->size);
-		if (final_start >= final_end)
-			continue;
-		subtract_range(range, az, final_start, final_end);
-	}
-
-	/* Put region array back ? */
-	memblock_reserve_reserved_regions();
-}
-
-static int __init count_early_node_map(int nodeid)
-{
-	int i, cnt = 0;
-
-	for_each_mem_pfn_range(i, nodeid, NULL, NULL, NULL)
-		cnt++;
-	return cnt;
-}
-
-int __init __get_free_all_memory_range(struct range **rangep, int nodeid,
-			 unsigned long start_pfn, unsigned long end_pfn)
-{
-	int count;
-	struct range *range;
-	int nr_range;
-
-	count = (memblock.reserved.cnt + count_early_node_map(nodeid)) * 2;
-
-	range = find_range_array(count);
-	nr_range = 0;
-
-	/*
-	 * Use early_node_map[] and memblock.reserved.region to get range array
-	 * at first
-	 */
-	nr_range = add_from_early_node_map(range, count, nr_range, nodeid);
-	subtract_range(range, count, 0, start_pfn);
-	subtract_range(range, count, end_pfn, -1ULL);
-
-	memblock_x86_subtract_reserved(range, count);
-	nr_range = clean_sort_range(range, count);
-
-	*rangep = range;
-	return nr_range;
-}
-
 static u64 __init __memblock_x86_memory_in_range(u64 addr, u64 limit, bool get_free)
 {
 	int i, count;
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 2037a8a..7075bc0 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -108,21 +108,25 @@ static void __init __free_pages_memory(unsigned long start, unsigned long end)
 
 unsigned long __init free_low_memory_core_early(int nodeid)
 {
-	int i;
-	u64 start, end;
 	unsigned long count = 0;
-	struct range *range = NULL;
-	int nr_range;
-
-	nr_range = __get_free_all_memory_range(&range, nodeid, 0, max_low_pfn);
-
-	for (i = 0; i < nr_range; i++) {
-		start = range[i].start;
-		end = range[i].end;
-		count += end - start;
-		__free_pages_memory(start, end);
+	phys_addr_t start, end;
+	u64 i;
+
+	/* free reserved array temporarily so that it's treated as free area */
+	memblock_free_reserved_regions();
+
+	for_each_free_mem_range(i, MAX_NUMNODES, &start, &end, NULL) {
+		unsigned long start_pfn = PFN_UP(start);
+		unsigned long end_pfn = min_t(unsigned long,
+					      PFN_DOWN(end), max_low_pfn);
+		if (start_pfn < end_pfn) {
+			__free_pages_memory(start_pfn, end_pfn);
+			count += end_pfn - start_pfn;
+		}
 	}
 
+	/* put region array back? */
+	memblock_reserve_reserved_regions();
 	return count;
 }
 
-- 
1.7.6


^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH 10/13] memblock, x86: Reimplement memblock_find_dma_reserve() using iterators
  2011-07-12  9:15 [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Tejun Heo
                   ` (8 preceding siblings ...)
  2011-07-12  9:16 ` [PATCH 09/13] memblock, x86: Replace __get_free_all_memory_range() with for_each_free_mem_range() Tejun Heo
@ 2011-07-12  9:16 ` Tejun Heo
  2011-07-14 21:36   ` [tip:x86/memblock] " tip-bot for Tejun Heo
  2011-07-12  9:16 ` [PATCH 11/13] x86: Use absent_pages_in_range() instead of memblock_x86_hole_size() Tejun Heo
                   ` (5 subsequent siblings)
  15 siblings, 1 reply; 54+ messages in thread
From: Tejun Heo @ 2011-07-12  9:16 UTC (permalink / raw)
  To: mingo, hpa, tglx, benh, yinghai, davem
  Cc: linux-kernel, linux-arch, x86, Tejun Heo

memblock_find_dma_reserve() wants to find out how much memory is
reserved under MAX_DMA_PFN.  memblock_x86_memory_[free_]in_range() are
used to find out the amounts of all available and free memory in the
area, which are then subtracted to find out the amount of reservation.

memblock_x86_memblock_[free_]in_range() are implemented using
__memblock_x86_memory_in_range() which builds ranges from memblock and
then count them, which is rather unnecessarily complex.

This patch open codes the counting logic directly in
memblock_find_dma_reserve() using memblock iterators and removes now
unused __memblock_x86_memory_in_range() and find_range_array().

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
 arch/x86/include/asm/memblock.h |    2 -
 arch/x86/kernel/e820.c          |   25 +++++++++--
 arch/x86/mm/memblock.c          |   87 ---------------------------------------
 3 files changed, 20 insertions(+), 94 deletions(-)

diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h
index bc9e44b..a0cc7d6 100644
--- a/arch/x86/include/asm/memblock.h
+++ b/arch/x86/include/asm/memblock.h
@@ -7,7 +7,5 @@ void memblock_x86_reserve_range(u64 start, u64 end, char *name);
 void memblock_x86_free_range(u64 start, u64 end);
 
 u64 memblock_x86_hole_size(u64 start, u64 end);
-u64 memblock_x86_free_memory_in_range(u64 addr, u64 limit);
-u64 memblock_x86_memory_in_range(u64 addr, u64 limit);
 
 #endif
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index b99d940..84475f1 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -1093,15 +1093,30 @@ void __init memblock_x86_fill(void)
 void __init memblock_find_dma_reserve(void)
 {
 #ifdef CONFIG_X86_64
-	u64 free_size_pfn;
-	u64 mem_size_pfn;
+	u64 nr_pages = 0, nr_free_pages = 0;
+	unsigned long start_pfn, end_pfn;
+	phys_addr_t start, end;
+	int i;
+	u64 u;
+
 	/*
 	 * need to find out used area below MAX_DMA_PFN
 	 * need to use memblock to get free size in [0, MAX_DMA_PFN]
 	 * at first, and assume boot_mem will not take below MAX_DMA_PFN
 	 */
-	mem_size_pfn = memblock_x86_memory_in_range(0, MAX_DMA_PFN << PAGE_SHIFT) >> PAGE_SHIFT;
-	free_size_pfn = memblock_x86_free_memory_in_range(0, MAX_DMA_PFN << PAGE_SHIFT) >> PAGE_SHIFT;
-	set_dma_reserve(mem_size_pfn - free_size_pfn);
+	for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, NULL) {
+		start_pfn = min_t(unsigned long, start_pfn, MAX_DMA_PFN);
+		end_pfn = min_t(unsigned long, end_pfn, MAX_DMA_PFN);
+		nr_pages += end_pfn - start_pfn;
+	}
+
+	for_each_free_mem_range(u, MAX_NUMNODES, &start, &end, NULL) {
+		start_pfn = min_t(unsigned long, PFN_UP(start), MAX_DMA_PFN);
+		end_pfn = min_t(unsigned long, PFN_DOWN(end), MAX_DMA_PFN);
+		if (start_pfn < end_pfn)
+			nr_free_pages += end_pfn - start_pfn;
+	}
+
+	set_dma_reserve(nr_pages - nr_free_pages);
 #endif
 }
diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c
index 4107c1a..a9d0972 100644
--- a/arch/x86/mm/memblock.c
+++ b/arch/x86/mm/memblock.c
@@ -7,93 +7,6 @@
 #include <linux/mm.h>
 #include <linux/range.h>
 
-static __init struct range *find_range_array(int count)
-{
-	u64 end, size, mem;
-	struct range *range;
-
-	size = sizeof(struct range) * count;
-	end = memblock.current_limit;
-
-	mem = memblock_find_in_range(0, end, size, sizeof(struct range));
-	if (!mem)
-		panic("can not find more space for range array");
-
-	/*
-	 * This range is tempoaray, so don't reserve it, it will not be
-	 * overlapped because We will not alloccate new buffer before
-	 * We discard this one
-	 */
-	range = __va(mem);
-	memset(range, 0, size);
-
-	return range;
-}
-
-static u64 __init __memblock_x86_memory_in_range(u64 addr, u64 limit, bool get_free)
-{
-	int i, count;
-	struct range *range;
-	int nr_range;
-	u64 final_start, final_end;
-	u64 free_size;
-	struct memblock_region *r;
-
-	count = (memblock.reserved.cnt + memblock.memory.cnt) * 2;
-
-	range = find_range_array(count);
-	nr_range = 0;
-
-	addr = PFN_UP(addr);
-	limit = PFN_DOWN(limit);
-
-	for_each_memblock(memory, r) {
-		final_start = PFN_UP(r->base);
-		final_end = PFN_DOWN(r->base + r->size);
-		if (final_start >= final_end)
-			continue;
-		if (final_start >= limit || final_end <= addr)
-			continue;
-
-		nr_range = add_range(range, count, nr_range, final_start, final_end);
-	}
-	subtract_range(range, count, 0, addr);
-	subtract_range(range, count, limit, -1ULL);
-
-	/* Subtract memblock.reserved.region in range ? */
-	if (!get_free)
-		goto sort_and_count_them;
-	for_each_memblock(reserved, r) {
-		final_start = PFN_DOWN(r->base);
-		final_end = PFN_UP(r->base + r->size);
-		if (final_start >= final_end)
-			continue;
-		if (final_start >= limit || final_end <= addr)
-			continue;
-
-		subtract_range(range, count, final_start, final_end);
-	}
-
-sort_and_count_them:
-	nr_range = clean_sort_range(range, count);
-
-	free_size = 0;
-	for (i = 0; i < nr_range; i++)
-		free_size += range[i].end - range[i].start;
-
-	return free_size << PAGE_SHIFT;
-}
-
-u64 __init memblock_x86_free_memory_in_range(u64 addr, u64 limit)
-{
-	return __memblock_x86_memory_in_range(addr, limit, true);
-}
-
-u64 __init memblock_x86_memory_in_range(u64 addr, u64 limit)
-{
-	return __memblock_x86_memory_in_range(addr, limit, false);
-}
-
 void __init memblock_x86_reserve_range(u64 start, u64 end, char *name)
 {
 	if (start == end)
-- 
1.7.6


^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH 11/13] x86: Use absent_pages_in_range() instead of memblock_x86_hole_size()
  2011-07-12  9:15 [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Tejun Heo
                   ` (9 preceding siblings ...)
  2011-07-12  9:16 ` [PATCH 10/13] memblock, x86: Reimplement memblock_find_dma_reserve() using iterators Tejun Heo
@ 2011-07-12  9:16 ` Tejun Heo
  2011-07-14 21:36   ` [tip:x86/memblock] " tip-bot for Tejun Heo
  2011-07-12  9:16 ` [PATCH 12/13] memblock, x86: Make ARCH_DISCARD_MEMBLOCK a config option Tejun Heo
                   ` (4 subsequent siblings)
  15 siblings, 1 reply; 54+ messages in thread
From: Tejun Heo @ 2011-07-12  9:16 UTC (permalink / raw)
  To: mingo, hpa, tglx, benh, yinghai, davem
  Cc: linux-kernel, linux-arch, x86, Tejun Heo

memblock_x86_hole_size() calculates the total size of holes in a given
range according to memblock and is used by numa emulation code and
numa_meminfo_cover_memory().

Since conversion to MEMBLOCK_NODE_MAP, absent_pages_in_range() also
uses memblock and gives the same result.  This patch replaces
memblock_x86_hole_size() uses with absent_pages_in_range().  After the
conversion the x86 function doesn't have any user left and is killed.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
 arch/x86/include/asm/memblock.h |    2 -
 arch/x86/mm/memblock.c          |   52 ---------------------------------------
 arch/x86/mm/numa.c              |    4 +-
 arch/x86/mm/numa_emulation.c    |   30 +++++++++++++---------
 4 files changed, 20 insertions(+), 68 deletions(-)

diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h
index a0cc7d6..17a882e 100644
--- a/arch/x86/include/asm/memblock.h
+++ b/arch/x86/include/asm/memblock.h
@@ -6,6 +6,4 @@
 void memblock_x86_reserve_range(u64 start, u64 end, char *name);
 void memblock_x86_free_range(u64 start, u64 end);
 
-u64 memblock_x86_hole_size(u64 start, u64 end);
-
 #endif
diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c
index a9d0972..7325c5d 100644
--- a/arch/x86/mm/memblock.c
+++ b/arch/x86/mm/memblock.c
@@ -32,55 +32,3 @@ void __init memblock_x86_free_range(u64 start, u64 end)
 
 	memblock_free(start, end - start);
 }
-
-/*
- * Finds an active region in the address range from start_pfn to last_pfn and
- * returns its range in ei_startpfn and ei_endpfn for the memblock entry.
- */
-static int __init memblock_x86_find_active_region(const struct memblock_region *ei,
-				  unsigned long start_pfn,
-				  unsigned long last_pfn,
-				  unsigned long *ei_startpfn,
-				  unsigned long *ei_endpfn)
-{
-	u64 align = PAGE_SIZE;
-
-	*ei_startpfn = round_up(ei->base, align) >> PAGE_SHIFT;
-	*ei_endpfn = round_down(ei->base + ei->size, align) >> PAGE_SHIFT;
-
-	/* Skip map entries smaller than a page */
-	if (*ei_startpfn >= *ei_endpfn)
-		return 0;
-
-	/* Skip if map is outside the node */
-	if (*ei_endpfn <= start_pfn || *ei_startpfn >= last_pfn)
-		return 0;
-
-	/* Check for overlaps */
-	if (*ei_startpfn < start_pfn)
-		*ei_startpfn = start_pfn;
-	if (*ei_endpfn > last_pfn)
-		*ei_endpfn = last_pfn;
-
-	return 1;
-}
-
-/*
- * Find the hole size (in bytes) in the memory range.
- * @start: starting address of the memory range to scan
- * @end: ending address of the memory range to scan
- */
-u64 __init memblock_x86_hole_size(u64 start, u64 end)
-{
-	unsigned long start_pfn = start >> PAGE_SHIFT;
-	unsigned long last_pfn = end >> PAGE_SHIFT;
-	unsigned long ei_startpfn, ei_endpfn, ram = 0;
-	struct memblock_region *r;
-
-	for_each_memblock(memory, r)
-		if (memblock_x86_find_active_region(r, start_pfn, last_pfn,
-					   &ei_startpfn, &ei_endpfn))
-			ram += ei_endpfn - ei_startpfn;
-
-	return end - start - ((u64)ram << PAGE_SHIFT);
-}
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index f4a40bd..88e5627 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -475,8 +475,8 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
 			numaram = 0;
 	}
 
-	e820ram = max_pfn - (memblock_x86_hole_size(0,
-					PFN_PHYS(max_pfn)) >> PAGE_SHIFT);
+	e820ram = max_pfn - absent_pages_in_range(0, max_pfn);
+
 	/* We seem to lose 3 pages somewhere. Allow 1M of slack. */
 	if ((s64)(e820ram - numaram) >= (1 << (20 - PAGE_SHIFT))) {
 		printk(KERN_ERR "NUMA: nodes only cover %LuMB of your %LuMB e820 RAM. Not used.\n",
diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c
index e3d471c..971fe70 100644
--- a/arch/x86/mm/numa_emulation.c
+++ b/arch/x86/mm/numa_emulation.c
@@ -28,6 +28,16 @@ static int __init emu_find_memblk_by_nid(int nid, const struct numa_meminfo *mi)
 	return -ENOENT;
 }
 
+static u64 mem_hole_size(u64 start, u64 end)
+{
+	unsigned long start_pfn = PFN_UP(start);
+	unsigned long end_pfn = PFN_DOWN(end);
+
+	if (start_pfn < end_pfn)
+		return PFN_PHYS(absent_pages_in_range(start_pfn, end_pfn));
+	return 0;
+}
+
 /*
  * Sets up nid to range from @start to @end.  The return value is -errno if
  * something went wrong, 0 otherwise.
@@ -89,7 +99,7 @@ static int __init split_nodes_interleave(struct numa_meminfo *ei,
 	 * Calculate target node size.  x86_32 freaks on __udivdi3() so do
 	 * the division in ulong number of pages and convert back.
 	 */
-	size = max_addr - addr - memblock_x86_hole_size(addr, max_addr);
+	size = max_addr - addr - mem_hole_size(addr, max_addr);
 	size = PFN_PHYS((unsigned long)(size >> PAGE_SHIFT) / nr_nodes);
 
 	/*
@@ -135,8 +145,7 @@ static int __init split_nodes_interleave(struct numa_meminfo *ei,
 			 * Continue to add memory to this fake node if its
 			 * non-reserved memory is less than the per-node size.
 			 */
-			while (end - start -
-			       memblock_x86_hole_size(start, end) < size) {
+			while (end - start - mem_hole_size(start, end) < size) {
 				end += FAKE_NODE_MIN_SIZE;
 				if (end > limit) {
 					end = limit;
@@ -150,7 +159,7 @@ static int __init split_nodes_interleave(struct numa_meminfo *ei,
 			 * this one must extend to the boundary.
 			 */
 			if (end < dma32_end && dma32_end - end -
-			    memblock_x86_hole_size(end, dma32_end) < FAKE_NODE_MIN_SIZE)
+			    mem_hole_size(end, dma32_end) < FAKE_NODE_MIN_SIZE)
 				end = dma32_end;
 
 			/*
@@ -158,8 +167,7 @@ static int __init split_nodes_interleave(struct numa_meminfo *ei,
 			 * next node, this one must extend to the end of the
 			 * physical node.
 			 */
-			if (limit - end -
-			    memblock_x86_hole_size(end, limit) < size)
+			if (limit - end - mem_hole_size(end, limit) < size)
 				end = limit;
 
 			ret = emu_setup_memblk(ei, pi, nid++ % nr_nodes,
@@ -180,7 +188,7 @@ static u64 __init find_end_of_node(u64 start, u64 max_addr, u64 size)
 {
 	u64 end = start + size;
 
-	while (end - start - memblock_x86_hole_size(start, end) < size) {
+	while (end - start - mem_hole_size(start, end) < size) {
 		end += FAKE_NODE_MIN_SIZE;
 		if (end > max_addr) {
 			end = max_addr;
@@ -211,8 +219,7 @@ static int __init split_nodes_size_interleave(struct numa_meminfo *ei,
 	 * creates a uniform distribution of node sizes across the entire
 	 * machine (but not necessarily over physical nodes).
 	 */
-	min_size = (max_addr - addr - memblock_x86_hole_size(addr, max_addr)) /
-						MAX_NUMNODES;
+	min_size = (max_addr - addr - mem_hole_size(addr, max_addr)) / MAX_NUMNODES;
 	min_size = max(min_size, FAKE_NODE_MIN_SIZE);
 	if ((min_size & FAKE_NODE_MIN_HASH_MASK) < min_size)
 		min_size = (min_size + FAKE_NODE_MIN_SIZE) &
@@ -252,7 +259,7 @@ static int __init split_nodes_size_interleave(struct numa_meminfo *ei,
 			 * this one must extend to the boundary.
 			 */
 			if (end < dma32_end && dma32_end - end -
-			    memblock_x86_hole_size(end, dma32_end) < FAKE_NODE_MIN_SIZE)
+			    mem_hole_size(end, dma32_end) < FAKE_NODE_MIN_SIZE)
 				end = dma32_end;
 
 			/*
@@ -260,8 +267,7 @@ static int __init split_nodes_size_interleave(struct numa_meminfo *ei,
 			 * next node, this one must extend to the end of the
 			 * physical node.
 			 */
-			if (limit - end -
-			    memblock_x86_hole_size(end, limit) < size)
+			if (limit - end - mem_hole_size(end, limit) < size)
 				end = limit;
 
 			ret = emu_setup_memblk(ei, pi, nid++ % MAX_NUMNODES,
-- 
1.7.6


^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH 12/13] memblock, x86: Make ARCH_DISCARD_MEMBLOCK a config option
  2011-07-12  9:15 [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Tejun Heo
                   ` (10 preceding siblings ...)
  2011-07-12  9:16 ` [PATCH 11/13] x86: Use absent_pages_in_range() instead of memblock_x86_hole_size() Tejun Heo
@ 2011-07-12  9:16 ` Tejun Heo
  2011-07-14  9:46   ` [PATCH UPDATED " Tejun Heo
  2011-07-12  9:16 ` [PATCH 13/13] memblock, x86: Replace memblock_x86_reserve/free_range() with generic ones Tejun Heo
                   ` (3 subsequent siblings)
  15 siblings, 1 reply; 54+ messages in thread
From: Tejun Heo @ 2011-07-12  9:16 UTC (permalink / raw)
  To: mingo, hpa, tglx, benh, yinghai, davem
  Cc: linux-kernel, linux-arch, x86, Tejun Heo

Make ARCH_DISCARD_MEMBLOCK a config option so that it can be handled
together with other MEMBLOCK options.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
 arch/x86/Kconfig                |    1 +
 arch/x86/include/asm/memblock.h |    2 --
 include/linux/memblock.h        |    2 +-
 mm/Kconfig                      |    3 +++
 mm/memblock.c                   |    2 +-
 5 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 91aa1b4e..30f4571 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -26,6 +26,7 @@ config X86
 	select HAVE_KPROBES
 	select HAVE_MEMBLOCK
 	select HAVE_MEMBLOCK_NODE_MAP
+	select ARCH_DISCARD_MEMBLOCK
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	select ARCH_WANT_FRAME_POINTERS
 	select HAVE_DMA_ATTRS
diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h
index 17a882e..bc56670 100644
--- a/arch/x86/include/asm/memblock.h
+++ b/arch/x86/include/asm/memblock.h
@@ -1,8 +1,6 @@
 #ifndef _X86_MEMBLOCK_H
 #define _X86_MEMBLOCK_H
 
-#define ARCH_DISCARD_MEMBLOCK
-
 void memblock_x86_reserve_range(u64 start, u64 end, char *name);
 void memblock_x86_free_range(u64 start, u64 end);
 
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 013dfe0..f2611d7 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -197,7 +197,7 @@ static inline unsigned long memblock_region_reserved_end_pfn(const struct memblo
 	     region++)
 
 
-#ifdef ARCH_DISCARD_MEMBLOCK
+#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
 #define __init_memblock __init
 #define __initdata_memblock __initdata
 #else
diff --git a/mm/Kconfig b/mm/Kconfig
index 30a5d47..7c56971 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -134,6 +134,9 @@ config HAVE_MEMBLOCK
 config HAVE_MEMBLOCK_NODE_MAP
 	boolean
 
+config ARCH_DISCARD_MEMBLOCK
+	boolean
+
 # eventually, we can have this option just 'select SPARSEMEM'
 config MEMORY_HOTPLUG
 	bool "Allow for memory hot-add"
diff --git a/mm/memblock.c b/mm/memblock.c
index 4d318bf..8971d06 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -958,7 +958,7 @@ static int __init early_memblock(char *p)
 }
 early_param("memblock", early_memblock);
 
-#if defined(CONFIG_DEBUG_FS) && !defined(ARCH_DISCARD_MEMBLOCK)
+#if defined(CONFIG_DEBUG_FS) && !defined(CONFIG_ARCH_DISCARD_MEMBLOCK)
 
 static int memblock_debug_show(struct seq_file *m, void *private)
 {
-- 
1.7.6


^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH 13/13] memblock, x86: Replace memblock_x86_reserve/free_range() with generic ones
  2011-07-12  9:15 [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Tejun Heo
                   ` (11 preceding siblings ...)
  2011-07-12  9:16 ` [PATCH 12/13] memblock, x86: Make ARCH_DISCARD_MEMBLOCK a config option Tejun Heo
@ 2011-07-12  9:16 ` Tejun Heo
  2011-07-14 20:10   ` H. Peter Anvin
                     ` (2 more replies)
  2011-07-12 23:26 ` [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Yinghai Lu
                   ` (2 subsequent siblings)
  15 siblings, 3 replies; 54+ messages in thread
From: Tejun Heo @ 2011-07-12  9:16 UTC (permalink / raw)
  To: mingo, hpa, tglx, benh, yinghai, davem
  Cc: linux-kernel, linux-arch, x86, Tejun Heo

Other than sanity check and debug message, the x86 specific version of
memblock reserve/free functions are simple wrappers around the generic
versions - memblock_reserve/free().

This patch adds debug messages with caller identification to the
generic versions and replaces x86 specific ones and kills them.
arch/x86/include/asm/memblock.h and arch/x86/mm/memblock.c are empty
after this change and removed.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
 arch/x86/include/asm/memblock.h |    7 -------
 arch/x86/kernel/aperture_64.c   |    2 +-
 arch/x86/kernel/check.c         |    2 +-
 arch/x86/kernel/head.c          |    2 +-
 arch/x86/kernel/head32.c        |    5 +++--
 arch/x86/kernel/head64.c        |    5 +++--
 arch/x86/kernel/mpparse.c       |    6 ++----
 arch/x86/kernel/setup.c         |   17 ++++++++---------
 arch/x86/kernel/trampoline.c    |    2 +-
 arch/x86/mm/Makefile            |    2 --
 arch/x86/mm/init.c              |    6 +++---
 arch/x86/mm/memblock.c          |   34 ----------------------------------
 arch/x86/mm/memtest.c           |    2 +-
 arch/x86/mm/numa.c              |    5 ++---
 arch/x86/mm/numa_32.c           |    6 +++---
 arch/x86/mm/numa_emulation.c    |    4 ++--
 arch/x86/platform/efi/efi.c     |    6 ++----
 arch/x86/xen/mmu.c              |   12 ++++--------
 arch/x86/xen/setup.c            |    7 +++----
 include/linux/memblock.h        |    2 --
 mm/memblock.c                   |    5 +++++
 mm/nobootmem.c                  |    6 +++---
 22 files changed, 48 insertions(+), 97 deletions(-)
 delete mode 100644 arch/x86/include/asm/memblock.h
 delete mode 100644 arch/x86/mm/memblock.c

diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h
deleted file mode 100644
index bc56670..0000000
--- a/arch/x86/include/asm/memblock.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _X86_MEMBLOCK_H
-#define _X86_MEMBLOCK_H
-
-void memblock_x86_reserve_range(u64 start, u64 end, char *name);
-void memblock_x86_free_range(u64 start, u64 end);
-
-#endif
diff --git a/arch/x86/kernel/aperture_64.c b/arch/x86/kernel/aperture_64.c
index 5636308..6e76c19 100644
--- a/arch/x86/kernel/aperture_64.c
+++ b/arch/x86/kernel/aperture_64.c
@@ -94,7 +94,7 @@ static u32 __init allocate_aperture(void)
 				addr, aper_size>>10);
 		return 0;
 	}
-	memblock_x86_reserve_range(addr, addr + aper_size, "aperture64");
+	memblock_reserve(addr, aper_size);
 	/*
 	 * Kmemleak should not scan this block as it may not be mapped via the
 	 * kernel direct mapping.
diff --git a/arch/x86/kernel/check.c b/arch/x86/kernel/check.c
index 621cd23..5da1269 100644
--- a/arch/x86/kernel/check.c
+++ b/arch/x86/kernel/check.c
@@ -91,7 +91,7 @@ void __init setup_bios_corruption_check(void)
 		if (start >= end)
 			continue;
 
-		memblock_x86_reserve_range(start, end, "SCAN RAM");
+		memblock_reserve(start, end - start);
 		scan_areas[num_scan_areas].addr = start;
 		scan_areas[num_scan_areas].size = end - start;
 
diff --git a/arch/x86/kernel/head.c b/arch/x86/kernel/head.c
index af0699b..48d9d4e 100644
--- a/arch/x86/kernel/head.c
+++ b/arch/x86/kernel/head.c
@@ -52,5 +52,5 @@ void __init reserve_ebda_region(void)
 		lowmem = 0x9f000;
 
 	/* reserve all memory between lowmem and the 1MB mark */
-	memblock_x86_reserve_range(lowmem, 0x100000, "* BIOS reserved");
+	memblock_reserve(lowmem, 0x100000 - lowmem);
 }
diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c
index 3bb0850..be9282b 100644
--- a/arch/x86/kernel/head32.c
+++ b/arch/x86/kernel/head32.c
@@ -33,7 +33,8 @@ void __init i386_start_kernel(void)
 {
 	memblock_init();
 
-	memblock_x86_reserve_range(__pa_symbol(&_text), __pa_symbol(&__bss_stop), "TEXT DATA BSS");
+	memblock_reserve(__pa_symbol(&_text),
+			 __pa_symbol(&__bss_stop) - __pa_symbol(&_text));
 
 #ifdef CONFIG_BLK_DEV_INITRD
 	/* Reserve INITRD */
@@ -42,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_x86_reserve_range(ramdisk_image, ramdisk_end, "RAMDISK");
+		memblock_reserve(ramdisk_image, ramdisk_end - ramdisk_image);
 	}
 #endif
 
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index 5655c22..fd25b11 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -100,7 +100,8 @@ void __init x86_64_start_reservations(char *real_mode_data)
 
 	memblock_init();
 
-	memblock_x86_reserve_range(__pa_symbol(&_text), __pa_symbol(&__bss_stop), "TEXT DATA BSS");
+	memblock_reserve(__pa_symbol(&_text),
+			 __pa_symbol(&__bss_stop) - __pa_symbol(&_text));
 
 #ifdef CONFIG_BLK_DEV_INITRD
 	/* Reserve INITRD */
@@ -109,7 +110,7 @@ void __init x86_64_start_reservations(char *real_mode_data)
 		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_x86_reserve_range(ramdisk_image, ramdisk_end, "RAMDISK");
+		memblock_reserve(ramdisk_image, ramdisk_end - ramdisk_image);
 	}
 #endif
 
diff --git a/arch/x86/kernel/mpparse.c b/arch/x86/kernel/mpparse.c
index 8faeaa0..a6b79c1 100644
--- a/arch/x86/kernel/mpparse.c
+++ b/arch/x86/kernel/mpparse.c
@@ -564,9 +564,7 @@ void __init default_get_smp_config(unsigned int early)
 
 static void __init smp_reserve_memory(struct mpf_intel *mpf)
 {
-	unsigned long size = get_mpc_size(mpf->physptr);
-
-	memblock_x86_reserve_range(mpf->physptr, mpf->physptr+size, "* MP-table mpc");
+	memblock_reserve(mpf->physptr, get_mpc_size(mpf->physptr));
 }
 
 static int __init smp_scan_config(unsigned long base, unsigned long length)
@@ -595,7 +593,7 @@ static int __init smp_scan_config(unsigned long base, unsigned long length)
 			       mpf, (u64)virt_to_phys(mpf));
 
 			mem = virt_to_phys(mpf);
-			memblock_x86_reserve_range(mem, mem + sizeof(*mpf), "* MP-table mpf");
+			memblock_reserve(mem, sizeof(*mpf));
 			if (mpf->physptr)
 				smp_reserve_memory(mpf);
 
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 31ffe20..97d227e 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -306,7 +306,8 @@ static void __init cleanup_highmap(void)
 static void __init reserve_brk(void)
 {
 	if (_brk_end > _brk_start)
-		memblock_x86_reserve_range(__pa(_brk_start), __pa(_brk_end), "BRK");
+		memblock_reserve(__pa(_brk_start),
+				 __pa(_brk_end) - __pa(_brk_start));
 
 	/* Mark brk area as locked down and no longer taking any
 	   new allocations */
@@ -337,7 +338,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_x86_reserve_range(ramdisk_here, ramdisk_here + area_size, "NEW RAMDISK");
+	memblock_reserve(ramdisk_here, area_size);
 	initrd_start = ramdisk_here + PAGE_OFFSET;
 	initrd_end   = initrd_start + ramdisk_size;
 	printk(KERN_INFO "Allocated new RAMDISK: %08llx - %08llx\n",
@@ -393,7 +394,7 @@ static void __init reserve_initrd(void)
 	initrd_start = 0;
 
 	if (ramdisk_size >= (end_of_lowmem>>1)) {
-		memblock_x86_free_range(ramdisk_image, ramdisk_end);
+		memblock_free(ramdisk_image, ramdisk_end - ramdisk_image);
 		printk(KERN_ERR "initrd too large to handle, "
 		       "disabling initrd\n");
 		return;
@@ -416,7 +417,7 @@ static void __init reserve_initrd(void)
 
 	relocate_initrd();
 
-	memblock_x86_free_range(ramdisk_image, ramdisk_end);
+	memblock_free(ramdisk_image, ramdisk_end - ramdisk_image);
 }
 #else
 static void __init reserve_initrd(void)
@@ -490,15 +491,13 @@ static void __init memblock_x86_reserve_range_setup_data(void)
 {
 	struct setup_data *data;
 	u64 pa_data;
-	char buf[32];
 
 	if (boot_params.hdr.version < 0x0209)
 		return;
 	pa_data = boot_params.hdr.setup_data;
 	while (pa_data) {
 		data = early_memremap(pa_data, sizeof(*data));
-		sprintf(buf, "setup data %x", data->type);
-		memblock_x86_reserve_range(pa_data, pa_data+sizeof(*data)+data->len, buf);
+		memblock_reserve(pa_data, sizeof(*data) + data->len);
 		pa_data = data->next;
 		early_iounmap(data, sizeof(*data));
 	}
@@ -568,7 +567,7 @@ static void __init reserve_crashkernel(void)
 			return;
 		}
 	}
-	memblock_x86_reserve_range(crash_base, crash_base + crash_size, "CRASH KERNEL");
+	memblock_reserve(crash_base, crash_size);
 
 	printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
 			"for crashkernel (System RAM: %ldMB)\n",
@@ -626,7 +625,7 @@ static __init void reserve_ibft_region(void)
 	addr = find_ibft_region(&size);
 
 	if (size)
-		memblock_x86_reserve_range(addr, addr + size, "* ibft");
+		memblock_reserve(addr, size);
 }
 
 static unsigned reserve_low = CONFIG_X86_RESERVE_LOW << 10;
diff --git a/arch/x86/kernel/trampoline.c b/arch/x86/kernel/trampoline.c
index a1f13dd..a73b610 100644
--- a/arch/x86/kernel/trampoline.c
+++ b/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_x86_reserve_range(mem, mem + size, "TRAMPOLINE");
+	memblock_reserve(mem, size);
 
 	printk(KERN_DEBUG "Base memory trampoline at [%p] %llx size %zu\n",
 	       x86_trampoline_base, (unsigned long long)mem, size);
diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
index 3d11327..23d8e5f 100644
--- a/arch/x86/mm/Makefile
+++ b/arch/x86/mm/Makefile
@@ -27,6 +27,4 @@ obj-$(CONFIG_AMD_NUMA)		+= amdtopology.o
 obj-$(CONFIG_ACPI_NUMA)		+= srat.o
 obj-$(CONFIG_NUMA_EMU)		+= numa_emulation.o
 
-obj-$(CONFIG_HAVE_MEMBLOCK)		+= memblock.o
-
 obj-$(CONFIG_MEMTEST)		+= memtest.o
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 13cf05a..0b736b9 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -81,7 +81,7 @@ static void __init find_early_table_space(unsigned long end, int use_pse,
 
 void __init native_pagetable_reserve(u64 start, u64 end)
 {
-	memblock_x86_reserve_range(start, end, "PGTABLE");
+	memblock_reserve(start, end - start);
 }
 
 struct map_range {
@@ -280,8 +280,8 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
 	 * pgt_buf_end) and free the other ones (pgt_buf_end - pgt_buf_top)
 	 * so that they can be reused for other purposes.
 	 *
-	 * On native it just means calling memblock_x86_reserve_range, on Xen it
-	 * also means marking RW the pagetable pages that we allocated before
+	 * On native it just means calling memblock_reserve, on Xen it also
+	 * means marking RW the pagetable pages that we allocated before
 	 * but that haven't been used.
 	 *
 	 * In fact on xen we mark RO the whole range pgt_buf_start -
diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c
deleted file mode 100644
index 7325c5d..0000000
--- a/arch/x86/mm/memblock.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/init.h>
-#include <linux/bitops.h>
-#include <linux/memblock.h>
-#include <linux/bootmem.h>
-#include <linux/mm.h>
-#include <linux/range.h>
-
-void __init memblock_x86_reserve_range(u64 start, u64 end, char *name)
-{
-	if (start == end)
-		return;
-
-	if (WARN_ONCE(start > end, "memblock_x86_reserve_range: wrong range [%#llx, %#llx)\n", start, end))
-		return;
-
-	memblock_dbg("    memblock_x86_reserve_range: [%#010llx-%#010llx] %16s\n", start, end - 1, name);
-
-	memblock_reserve(start, end - start);
-}
-
-void __init memblock_x86_free_range(u64 start, u64 end)
-{
-	if (start == end)
-		return;
-
-	if (WARN_ONCE(start > end, "memblock_x86_free_range: wrong range [%#llx, %#llx)\n", start, end))
-		return;
-
-	memblock_dbg("       memblock_x86_free_range: [%#010llx-%#010llx]\n", start, end - 1);
-
-	memblock_free(start, end - start);
-}
diff --git a/arch/x86/mm/memtest.c b/arch/x86/mm/memtest.c
index 46a5ff2..c80b9fb 100644
--- a/arch/x86/mm/memtest.c
+++ b/arch/x86/mm/memtest.c
@@ -34,7 +34,7 @@ static void __init reserve_bad_mem(u64 pattern, u64 start_bad, u64 end_bad)
 	       (unsigned long long) pattern,
 	       (unsigned long long) start_bad,
 	       (unsigned long long) end_bad);
-	memblock_x86_reserve_range(start_bad, end_bad, "BAD RAM");
+	memblock_reserve(start_bad, end_bad - start_bad);
 }
 
 static void __init memtest(u64 pattern, u64 start_phys, u64 size)
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index 88e5627..496f494 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -364,8 +364,7 @@ void __init numa_reset_distance(void)
 
 	/* numa_distance could be 1LU marking allocation failure, test cnt */
 	if (numa_distance_cnt)
-		memblock_x86_free_range(__pa(numa_distance),
-					__pa(numa_distance) + size);
+		memblock_free(__pa(numa_distance), size);
 	numa_distance_cnt = 0;
 	numa_distance = NULL;	/* enable table creation */
 }
@@ -394,7 +393,7 @@ static int __init numa_alloc_distance(void)
 		numa_distance = (void *)1LU;
 		return -ENOMEM;
 	}
-	memblock_x86_reserve_range(phys, phys + size, "NUMA DIST");
+	memblock_reserve(phys, size);
 
 	numa_distance = __va(phys);
 	numa_distance_cnt = cnt;
diff --git a/arch/x86/mm/numa_32.c b/arch/x86/mm/numa_32.c
index 58878b5..534255a 100644
--- a/arch/x86/mm/numa_32.c
+++ b/arch/x86/mm/numa_32.c
@@ -204,7 +204,7 @@ void __init init_alloc_remap(int nid, u64 start, u64 end)
 			   size, nid);
 		return;
 	}
-	memblock_x86_reserve_range(node_pa, node_pa + size, "KVA RAM");
+	memblock_reserve(node_pa, size);
 
 	remap_pa = memblock_find_in_range(min_low_pfn << PAGE_SHIFT,
 					  max_low_pfn << PAGE_SHIFT,
@@ -212,10 +212,10 @@ void __init init_alloc_remap(int nid, u64 start, u64 end)
 	if (!remap_pa) {
 		pr_warning("remap_alloc: failed to allocate %lu bytes remap area for node %d\n",
 			   size, nid);
-		memblock_x86_free_range(node_pa, node_pa + size);
+		memblock_free(node_pa, size);
 		return;
 	}
-	memblock_x86_reserve_range(remap_pa, remap_pa + size, "KVA PG");
+	memblock_reserve(remap_pa, size);
 	remap_va = phys_to_virt(remap_pa);
 
 	/* perform actual remap */
diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c
index 971fe70..46db568 100644
--- a/arch/x86/mm/numa_emulation.c
+++ b/arch/x86/mm/numa_emulation.c
@@ -361,7 +361,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)
 			pr_warning("NUMA: Warning: can't allocate copy of distance table, disabling emulation\n");
 			goto no_emu;
 		}
-		memblock_x86_reserve_range(phys, phys + phys_size, "TMP NUMA DIST");
+		memblock_reserve(phys, phys_size);
 		phys_dist = __va(phys);
 
 		for (i = 0; i < numa_dist_cnt; i++)
@@ -430,7 +430,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)
 
 	/* free the copied physical distance table */
 	if (phys_dist)
-		memblock_x86_free_range(__pa(phys_dist), __pa(phys_dist) + phys_size);
+		memblock_free(__pa(phys_dist), phys_size);
 	return;
 
 no_emu:
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index a4c322c..3b4e86b 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -280,8 +280,7 @@ void __init efi_memblock_x86_reserve_range(void)
 		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_x86_reserve_range(pmap, pmap + memmap.nr_map * memmap.desc_size,
-		      "EFI memmap");
+	memblock_reserve(pmap, memmap.nr_map * memmap.desc_size);
 }
 
 #if EFI_DEBUG
@@ -332,8 +331,7 @@ void __init efi_reserve_boot_services(void)
 					"[0x%010llx-0x%010llx]\n",
 						start, start+size-1);
 		} else
-			memblock_x86_reserve_range(start, start+size,
-							"EFI Boot");
+			memblock_reserve(start, size);
 	}
 }
 
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 0ccccb6..ad54fa1 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -1720,10 +1720,8 @@ pgd_t * __init xen_setup_kernel_pagetable(pgd_t *pgd,
 	__xen_write_cr3(true, __pa(pgd));
 	xen_mc_issue(PARAVIRT_LAZY_CPU);
 
-	memblock_x86_reserve_range(__pa(xen_start_info->pt_base),
-		      __pa(xen_start_info->pt_base +
-			   xen_start_info->nr_pt_frames * PAGE_SIZE),
-		      "XEN PAGETABLES");
+	memblock_reserve(__pa(xen_start_info->pt_base),
+			 xen_start_info->nr_pt_frames * PAGE_SIZE);
 
 	return pgd;
 }
@@ -1799,10 +1797,8 @@ pgd_t * __init xen_setup_kernel_pagetable(pgd_t *pgd,
 			  PFN_DOWN(__pa(initial_page_table)));
 	xen_write_cr3(__pa(initial_page_table));
 
-	memblock_x86_reserve_range(__pa(xen_start_info->pt_base),
-		      __pa(xen_start_info->pt_base +
-			   xen_start_info->nr_pt_frames * PAGE_SIZE),
-		      "XEN PAGETABLES");
+	memblock_reserve(__pa(xen_start_info->pt_base),
+			 xen_start_info->nr_pt_frames * PAGE_SIZE));
 
 	return initial_page_table;
 }
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 60aeeb5..73daaf7 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -63,7 +63,7 @@ static void __init xen_add_extra_mem(unsigned long pages)
 	e820_add_region(extra_start, size, E820_RAM);
 	sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
 
-	memblock_x86_reserve_range(extra_start, extra_start + size, "XEN EXTRA");
+	memblock_reserve(extra_start, size);
 
 	xen_extra_mem_size += size;
 
@@ -287,9 +287,8 @@ char * __init xen_memory_setup(void)
 	 *  - xen_start_info
 	 * See comment above "struct start_info" in <xen/interface/xen.h>
 	 */
-	memblock_x86_reserve_range(__pa(xen_start_info->mfn_list),
-		      __pa(xen_start_info->pt_base),
-			"XEN START INFO");
+	memblock_reserve(__pa(xen_start_info->mfn_list),
+			 xen_start_info->pt_base - xen_start_info->mfn_list);
 
 	sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
 
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index f2611d7..86805f9 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -17,8 +17,6 @@
 #include <linux/init.h>
 #include <linux/mm.h>
 
-#include <asm/memblock.h>
-
 #define INIT_MEMBLOCK_REGIONS	128
 
 struct memblock_region {
diff --git a/mm/memblock.c b/mm/memblock.c
index 8971d06..1896c06 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -449,6 +449,9 @@ long __init_memblock memblock_remove(phys_addr_t base, phys_addr_t size)
 
 long __init_memblock memblock_free(phys_addr_t base, phys_addr_t size)
 {
+	memblock_dbg("   memblock_free: [%#016llx-%#016llx] %pF\n",
+		     base, base + size, (void *)_RET_IP_);
+
 	return __memblock_remove(&memblock.reserved, base, size);
 }
 
@@ -456,6 +459,8 @@ long __init_memblock memblock_reserve(phys_addr_t base, phys_addr_t size)
 {
 	struct memblock_type *_rgn = &memblock.reserved;
 
+	memblock_dbg("memblock_reserve: [%#016llx-%#016llx] %pF\n",
+		     base, base + size, (void *)_RET_IP_);
 	BUG_ON(0 == size);
 
 	return memblock_add_region(_rgn, base, size);
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 7075bc0..29d948c 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -47,7 +47,7 @@ static void * __init __alloc_memory_core_early(int nid, u64 size, u64 align,
 
 	ptr = phys_to_virt(addr);
 	memset(ptr, 0, size);
-	memblock_x86_reserve_range(addr, addr + size, "BOOTMEM");
+	memblock_reserve(addr, size);
 	/*
 	 * The min_count is set to 0 so that bootmem allocated blocks
 	 * are never reported as leaks.
@@ -175,7 +175,7 @@ void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,
 			      unsigned long size)
 {
 	kmemleak_free_part(__va(physaddr), size);
-	memblock_x86_free_range(physaddr, physaddr + size);
+	memblock_free(physaddr, size);
 }
 
 /**
@@ -190,7 +190,7 @@ void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,
 void __init free_bootmem(unsigned long addr, unsigned long size)
 {
 	kmemleak_free_part(__va(addr), size);
-	memblock_x86_free_range(addr, addr + size);
+	memblock_free(addr, size);
 }
 
 static void * __init ___alloc_bootmem_nopanic(unsigned long size,
-- 
1.7.6


^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code
  2011-07-12  9:15 [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Tejun Heo
                   ` (12 preceding siblings ...)
  2011-07-12  9:16 ` [PATCH 13/13] memblock, x86: Replace memblock_x86_reserve/free_range() with generic ones Tejun Heo
@ 2011-07-12 23:26 ` Yinghai Lu
  2011-07-13  3:21   ` H. Peter Anvin
  2011-07-13  9:11   ` Tejun Heo
  2011-07-14  9:42 ` [PATCH 2.5/13] memblock: Use __meminit[data] instead of __init[data] Tejun Heo
  2011-07-14  9:49 ` [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Tejun Heo
  15 siblings, 2 replies; 54+ messages in thread
From: Yinghai Lu @ 2011-07-12 23:26 UTC (permalink / raw)
  To: Tejun Heo; +Cc: mingo, hpa, tglx, benh, davem, linux-kernel, linux-arch, x86

On Tue, Jul 12, 2011 at 2:15 AM, Tejun Heo <tj@kernel.org> wrote:
> Hello,
>
> There are multiple ways to represent memory configuration during boot.
> Even with the latest incarnation - nobootmem, the configuration isn't
> centralized or easy to use.  NUMA information lives in
> early_node_map[] while memory config and alloc/reservation live in
> memblock.  This leads to ugly code pieces which try to combine the two
> separate information sources both in generic and arch specfic parts.
>
> This patchset extends memblock such that it can also host node
> information and allows an arch to do away with early_node_map[] and
> use memblock as the sole early memory config / allocation mechanism.
>
> For short term, this adds yet another config option -
> HAVE_MEMBLOCK_NODE_MAP in this area.  Longer term goal is removing
> early_node_map[] completely and convert everyone over to memblock.  As
> early_node_map[] usage is limited only to NUMA archs, this should be
> easiser than bootmem allocator conversion.  In the end, memblock will
> be the only early mem mechanism.
>
> Note that this patchset still leaves good amount of code which can be
> removed / cleaned up in not too distant future.  For example, memblock
> non-NUMA alloc code can simply be degenerate case of NUMA aware alloc,
> which can also be implemented in simpler and more efficient way with
> reverse free area iterator.
>
> This patchset first extends memblock so that it can contain node
> information and then replaces x86 specific memblock code with the
> generic one.
>
>  0001-memblock-Remove-memblock_memory_can_coalesce.patch
>  0002-memblock-Reimplement-memblock_add_region.patch
>  0003-memblock-Add-optional-region-nid.patch
>  0004-x86-Use-HAVE_MEMBLOCK_NODE_MAP.patch
>  0005-x86-Use-__memblock_alloc_base-in-early_reserve_e820.patch
>  0006-memblock-Implement-for_each_free_mem_range.patch
>  0007-x86-Replace-memblock_x86_find_in_range_size-with-for.patch
>  0008-memblock-x86-Make-free_all_memory_core_early-explici.patch
>  0009-memblock-x86-Replace-__get_free_all_memory_range-wit.patch
>  0010-memblock-x86-Reimplement-memblock_find_dma_reserve-u.patch
>  0011-x86-Use-absent_pages_in_range-instead-of-memblock_x8.patch
>  0012-memblock-x86-Make-ARCH_DISCARD_MEMBLOCK-a-config-opt.patch
>  0013-memblock-x86-Replace-memblock_x86_reserve-free_range.patch
>
> 0001-0004 implement HAVE_MEMBLOCK_NODE_MAP and use it in x86.
>
> 0005-0013 adds generic memblock free area iterator and gradually
> replaces x86 specific memblock mechanism with generic one.

that is great, merge early_node_map into memblock array.

looks it comes with some mismatch section warning...

WARNING: vmlinux.o(.text+0x120ba5): Section mismatch in reference from
the function memblock_set_node() to the variable .init.data:memblock
The function memblock_set_node() references
the variable __initdata memblock.
This is often because memblock_set_node lacks a __initdata
annotation or the annotation of memblock is wrong.

WARNING: vmlinux.o(.text+0x120baa): Section mismatch in reference from
the function memblock_set_node() to the function
.init.text:memblock_double_array()
The function memblock_set_node() references
the function __init memblock_double_array().
This is often because memblock_set_node lacks a __init
annotation or the annotation of memblock_double_array is wrong.

WARNING: vmlinux.o(.text+0x120bb9): Section mismatch in reference from
the function memblock_set_node() to the variable .init.data:memblock
The function memblock_set_node() references
the variable __initdata memblock.
This is often because memblock_set_node lacks a __initdata
annotation or the annotation of memblock is wrong.

WARNING: vmlinux.o(.text+0x120bc4): Section mismatch in reference from
the function memblock_set_node() to the variable .init.data:memblock
The function memblock_set_node() references
the variable __initdata memblock.
This is often because memblock_set_node lacks a __initdata
annotation or the annotation of memblock is wrong.

WARNING: vmlinux.o(.text+0x120bd9): Section mismatch in reference from
the function memblock_set_node() to the variable .init.data:memblock
The function memblock_set_node() references
the variable __initdata memblock.
This is often because memblock_set_node lacks a __initdata
annotation or the annotation of memblock is wrong.

WARNING: vmlinux.o(.text+0x120c10): Section mismatch in reference from
the function memblock_set_node() to the variable .init.data:memblock
The function memblock_set_node() references
the variable __initdata memblock.
This is often because memblock_set_node lacks a __initdata
annotation or the annotation of memblock is wrong.

WARNING: vmlinux.o(.text+0x120c15): Section mismatch in reference from
the function memblock_set_node() to the function
.init.text:memblock_insert_region()
The function memblock_set_node() references
the function __init memblock_insert_region().
This is often because memblock_set_node lacks a __init
annotation or the annotation of memblock_insert_region is wrong.

WARNING: vmlinux.o(.text+0x120c3e): Section mismatch in reference from
the function memblock_set_node() to the variable .init.data:memblock
The function memblock_set_node() references
the variable __initdata memblock.
This is often because memblock_set_node lacks a __initdata
annotation or the annotation of memblock is wrong.

WARNING: vmlinux.o(.text+0x120c43): Section mismatch in reference from
the function memblock_set_node() to the function
.init.text:memblock_insert_region()
The function memblock_set_node() references
the function __init memblock_insert_region().
This is often because memblock_set_node lacks a __init
annotation or the annotation of memblock_insert_region is wrong.

WARNING: vmlinux.o(.text+0x120c59): Section mismatch in reference from
the function memblock_set_node() to the variable .init.data:memblock
The function memblock_set_node() references
the variable __initdata memblock.
This is often because memblock_set_node lacks a __initdata
annotation or the annotation of memblock is wrong.

WARNING: vmlinux.o(.text+0x120c66): Section mismatch in reference from
the function memblock_set_node() to the variable .init.data:memblock
The function memblock_set_node() references
the variable __initdata memblock.
This is often because memblock_set_node lacks a __initdata
annotation or the annotation of memblock is wrong.

WARNING: vmlinux.o(.text+0x120c6b): Section mismatch in reference from
the function memblock_set_node() to the function
.init.text:memblock_merge_regions()
The function memblock_set_node() references
the function __init memblock_merge_regions().
This is often because memblock_set_node lacks a __init
annotation or the annotation of memblock_merge_regions is wrong.

WARNING: vmlinux.o(.meminit.text+0xacc): Section mismatch in reference
from the function __early_pfn_to_nid() to the function
.init.text:__next_mem_pfn_range()
The function __meminit __early_pfn_to_nid() references
a function __init __next_mem_pfn_range().
If __next_mem_pfn_range is only used by __early_pfn_to_nid then
annotate __next_mem_pfn_range with a matching annotation.

WARNING: vmlinux.o(.meminit.text+0xb70): Section mismatch in reference
from the function get_pfn_range_for_nid() to the function
.init.text:__next_mem_pfn_range()
The function __meminit get_pfn_range_for_nid() references
a function __init __next_mem_pfn_range().
If __next_mem_pfn_range is only used by get_pfn_range_for_nid then
annotate __next_mem_pfn_range with a matching annotation.

WARNING: vmlinux.o(.meminit.text+0xbad): Section mismatch in reference
from the function get_pfn_range_for_nid() to the function
.init.text:__next_mem_pfn_range()
The function __meminit get_pfn_range_for_nid() references
a function __init __next_mem_pfn_range().
If __next_mem_pfn_range is only used by get_pfn_range_for_nid then
annotate __next_mem_pfn_range with a matching annotation.

WARNING: vmlinux.o(.meminit.text+0xcc9): Section mismatch in reference
from the function __absent_pages_in_range() to the function
.init.text:__next_mem_pfn_range()
The function __meminit __absent_pages_in_range() references
a function __init __next_mem_pfn_range().
If __next_mem_pfn_range is only used by __absent_pages_in_range then
annotate __next_mem_pfn_range with a matching annotation.

WARNING: vmlinux.o(.meminit.text+0xd1a): Section mismatch in reference
from the function __absent_pages_in_range() to the function
.init.text:__next_mem_pfn_range()
The function __meminit __absent_pages_in_range() references
a function __init __next_mem_pfn_range().
If __next_mem_pfn_range is only used by __absent_pages_in_range then
annotate __next_mem_pfn_range with a matching annotation.

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code
  2011-07-12 23:26 ` [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Yinghai Lu
@ 2011-07-13  3:21   ` H. Peter Anvin
  2011-07-13  9:16     ` Tejun Heo
  2011-07-13  9:11   ` Tejun Heo
  1 sibling, 1 reply; 54+ messages in thread
From: H. Peter Anvin @ 2011-07-13  3:21 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Tejun Heo, mingo, tglx, benh, davem, linux-kernel, linux-arch, x86

On 07/12/2011 04:26 PM, Yinghai Lu wrote:
> 
> that is great, merge early_node_map into memblock array.
> 
> looks it comes with some mismatch section warning...
> 

I'm also confused about the baseline of the patchset...

	-hpa

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code
  2011-07-12 23:26 ` [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Yinghai Lu
  2011-07-13  3:21   ` H. Peter Anvin
@ 2011-07-13  9:11   ` Tejun Heo
  2011-07-13 19:06     ` Yinghai Lu
  1 sibling, 1 reply; 54+ messages in thread
From: Tejun Heo @ 2011-07-13  9:11 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: mingo, hpa, tglx, benh, davem, linux-kernel, linux-arch, x86

Hello, Yinghai.

On Tue, Jul 12, 2011 at 04:26:57PM -0700, Yinghai Lu wrote:
> On Tue, Jul 12, 2011 at 2:15 AM, Tejun Heo <tj@kernel.org> wrote:
> > 0005-0013 adds generic memblock free area iterator and gradually
> > replaces x86 specific memblock mechanism with generic one.
> 
> that is great, merge early_node_map into memblock array.

Yeah and with proper top down allocator and iterator, we should be
able to add back the early per-node allocaiton thing.

> looks it comes with some mismatch section warning...
> 
> WARNING: vmlinux.o(.text+0x120ba5): Section mismatch in reference from
> the function memblock_set_node() to the variable .init.data:memblock
> The function memblock_set_node() references
> the variable __initdata memblock.
> This is often because memblock_set_node lacks a __initdata
> annotation or the annotation of memblock is wrong.

Oh, the __memblock_init thing.  Can you please attach .config you
used?

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code
  2011-07-13  3:21   ` H. Peter Anvin
@ 2011-07-13  9:16     ` Tejun Heo
  0 siblings, 0 replies; 54+ messages in thread
From: Tejun Heo @ 2011-07-13  9:16 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Yinghai Lu, mingo, tglx, benh, davem, linux-kernel, linux-arch, x86

Hello,

On Tue, Jul 12, 2011 at 08:21:23PM -0700, H. Peter Anvin wrote:
> On 07/12/2011 04:26 PM, Yinghai Lu wrote:
> > 
> > that is great, merge early_node_map into memblock array.
> > 
> > looks it comes with some mismatch section warning...
> > 
> 
> I'm also confused about the baseline of the patchset...

The whole thing is on top of x86/urgent for the commit which disabled
AMD NUMA on 32bit, so it's like the following.

  x86/urgent (5da0ef9a8 "x86: Disable AMD_NUMA for 32bit for now")

+ Two patches for pfn->nid mapping granularity check (applied now)

    http://thread.gmane.org/gmane.linux.kernel/1166521

+ memblock, x86: Misc cleanups

    http://thread.gmane.org/gmane.linux.kernel.cross-arch/10338

+ memblock, x86: Implement for_each_mem_pfn_range() and use it to improve memblock allocator

    http://thread.gmane.org/gmane.linux.kernel.cross-arch/10345

+ memblock, x86: Allow node info in memblock and remove x86 specific memblock code

    http://thread.gmane.org/gmane.linux.kernel.cross-arch/10354

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code
  2011-07-13  9:11   ` Tejun Heo
@ 2011-07-13 19:06     ` Yinghai Lu
  0 siblings, 0 replies; 54+ messages in thread
From: Yinghai Lu @ 2011-07-13 19:06 UTC (permalink / raw)
  To: Tejun Heo; +Cc: mingo, hpa, tglx, benh, davem, linux-kernel, linux-arch, x86

[-- Attachment #1: Type: text/plain, Size: 605 bytes --]

On Wed, Jul 13, 2011 at 2:11 AM, Tejun Heo <tj@kernel.org> wrote:
>> looks it comes with some mismatch section warning...
>>
>> WARNING: vmlinux.o(.text+0x120ba5): Section mismatch in reference from
>> the function memblock_set_node() to the variable .init.data:memblock
>> The function memblock_set_node() references
>> the variable __initdata memblock.
>> This is often because memblock_set_node lacks a __initdata
>> annotation or the annotation of memblock is wrong.
>
> Oh, the __memblock_init thing.  Can you please attach .config you
> used?

please check attached config.

Yinghai

[-- Attachment #2: config.full.999999 --]
[-- Type: application/octet-stream, Size: 86958 bytes --]

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH 04/13] x86: Use HAVE_MEMBLOCK_NODE_MAP
  2011-07-12  9:15 ` [PATCH 04/13] x86: Use HAVE_MEMBLOCK_NODE_MAP Tejun Heo
@ 2011-07-14  1:35   ` H. Peter Anvin
  2011-07-14  9:44   ` [PATCH UPDATED " Tejun Heo
  1 sibling, 0 replies; 54+ messages in thread
From: H. Peter Anvin @ 2011-07-14  1:35 UTC (permalink / raw)
  To: Tejun Heo
  Cc: mingo, tglx, benh, yinghai, davem, linux-kernel, linux-arch, x86

On 07/12/2011 02:15 AM, Tejun Heo wrote:
> Convert x86 to HAVE_MEMBLOCK_NODE_MAP.  The only difference in memory
> handling is that allocations can't no longer cross node boundaries
> whether they're node affine or not, which shouldn't matter at all.
> 
> This conversion will enable further simplification of boot memory
> handling.
> 
> Signed-off-by: Tejun Heo <tj@kernel.org>
> Cc: Yinghai Lu <yinghai@kernel.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: "H. Peter Anvin" <hpa@zytor.com>

Hi Tejun,

This patch causes a build error on i386 allnoconfig:

/home/hpa/kernel/linux-2.6-tip.memblock/arch/x86/mm/init_32.c: In
function ‘initmem_init’:
/home/hpa/kernel/linux-2.6-tip.memblock/arch/x86/mm/init_32.c:653:2:
error: implicit declaration of function
‘memblock_x86_register_active_regions’
[-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors

	-hpa

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH 2.5/13] memblock: Use __meminit[data] instead of __init[data]
  2011-07-12  9:15 [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Tejun Heo
                   ` (13 preceding siblings ...)
  2011-07-12 23:26 ` [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Yinghai Lu
@ 2011-07-14  9:42 ` Tejun Heo
  2011-07-14 21:00   ` Yinghai Lu
  2011-07-14 21:32   ` [tip:x86/memblock] " tip-bot for Tejun Heo
  2011-07-14  9:49 ` [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Tejun Heo
  15 siblings, 2 replies; 54+ messages in thread
From: Tejun Heo @ 2011-07-14  9:42 UTC (permalink / raw)
  To: mingo, hpa, tglx, benh, yinghai, davem; +Cc: linux-kernel, linux-arch, x86

>From 19ab281ed67b87a6623d725237a7333ca79f1e75 Mon Sep 17 00:00:00 2001
From: Tejun Heo <tj@kernel.org>
Date: Thu, 14 Jul 2011 11:22:16 +0200

memblock will be extended to include early_node_map[], which is also
used during memory hotplug.  Make memblock use __meminit[data] instead
of __init[data] so that memory hotplug code can safely reference it.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 include/linux/memblock.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index aa5df9e..434b958 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -152,8 +152,8 @@ static inline unsigned long memblock_region_reserved_end_pfn(const struct memblo
 
 
 #ifdef ARCH_DISCARD_MEMBLOCK
-#define __init_memblock __init
-#define __initdata_memblock __initdata
+#define __init_memblock __meminit
+#define __initdata_memblock __meminitdata
 #else
 #define __init_memblock
 #define __initdata_memblock
-- 
1.7.6


^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH UPDATED 03/13] memblock: Add optional region->nid
  2011-07-12  9:15 ` [PATCH 03/13] memblock: Add optional region->nid Tejun Heo
@ 2011-07-14  9:43   ` " Tejun Heo
  2011-07-14 21:32     ` [tip:x86/memblock] " tip-bot for Tejun Heo
  0 siblings, 1 reply; 54+ messages in thread
From: Tejun Heo @ 2011-07-14  9:43 UTC (permalink / raw)
  To: mingo, hpa, tglx, benh, yinghai, davem; +Cc: linux-kernel, linux-arch, x86

>From 83103b92f3234ec830852bbc5c45911bd6cbdb20 Mon Sep 17 00:00:00 2001
From: Tejun Heo <tj@kernel.org>
Date: Thu, 14 Jul 2011 11:22:16 +0200

Add optional region->nid which can be enabled by arch using
CONFIG_HAVE_MEMBLOCK_NODE_MAP.  When enabled, memblock also carries
NUMA node information and replaces early_node_map[].

Newly added memblocks have MAX_NUMNODES as nid.  Arch can then call
memblock_set_node() to set node information.  memblock takes care of
merging and node affine allocations w.r.t. node information.

When MEMBLOCK_NODE_MAP is enabled, early_node_map[], related data
structures and functions to manipulate and iterate it are disabled.
memblock version of __next_mem_pfn_range() is provided such that
for_each_mem_pfn_range() behaves the same and its users don't have to
be updated.

-v2: Yinghai spotted section mismatch caused by missing
     __init_memblock in memblock_set_node().  Fixed.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 include/linux/memblock.h |   26 ++++++++
 include/linux/mm.h       |    2 +
 mm/Kconfig               |    3 +
 mm/memblock.c            |  142 ++++++++++++++++++++++++++++++++++++++++------
 mm/page_alloc.c          |   47 +++++++++------
 5 files changed, 183 insertions(+), 37 deletions(-)

diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 434b958..c36a55d 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -24,6 +24,9 @@
 struct memblock_region {
 	phys_addr_t base;
 	phys_addr_t size;
+#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
+	int nid;
+#endif
 };
 
 struct memblock_type {
@@ -58,6 +61,29 @@ extern long memblock_remove(phys_addr_t base, phys_addr_t size);
 extern long memblock_free(phys_addr_t base, phys_addr_t size);
 extern long memblock_reserve(phys_addr_t base, phys_addr_t size);
 
+#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
+extern int memblock_set_node(phys_addr_t base, phys_addr_t size, int nid);
+
+static inline void memblock_set_region_node(struct memblock_region *r, int nid)
+{
+	r->nid = nid;
+}
+
+static inline int memblock_get_region_node(const struct memblock_region *r)
+{
+	return r->nid;
+}
+#else
+static inline void memblock_set_region_node(struct memblock_region *r, int nid)
+{
+}
+
+static inline int memblock_get_region_node(const struct memblock_region *r)
+{
+	return 0;
+}
+#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
+
 /* The numa aware allocator is only available if
  * CONFIG_ARCH_POPULATES_NODE_MAP is set
  */
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 9ebc65a..ceb1e4a 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1307,12 +1307,14 @@ extern void free_area_init_node(int nid, unsigned long * zones_size,
  * CONFIG_ARCH_POPULATES_NODE_MAP
  */
 extern void free_area_init_nodes(unsigned long *max_zone_pfn);
+#ifndef CONFIG_HAVE_MEMBLOCK_NODE_MAP
 extern void add_active_range(unsigned int nid, unsigned long start_pfn,
 					unsigned long end_pfn);
 extern void remove_active_range(unsigned int nid, unsigned long start_pfn,
 					unsigned long end_pfn);
 extern void remove_all_active_ranges(void);
 void sort_node_map(void);
+#endif
 unsigned long node_map_pfn_alignment(void);
 unsigned long __absent_pages_in_range(int nid, unsigned long start_pfn,
 						unsigned long end_pfn);
diff --git a/mm/Kconfig b/mm/Kconfig
index 8ca47a5..30a5d47 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -131,6 +131,9 @@ config SPARSEMEM_VMEMMAP
 config HAVE_MEMBLOCK
 	boolean
 
+config HAVE_MEMBLOCK_NODE_MAP
+	boolean
+
 # eventually, we can have this option just 'select SPARSEMEM'
 config MEMORY_HOTPLUG
 	bool "Allow for memory hot-add"
diff --git a/mm/memblock.c b/mm/memblock.c
index 992aa18..e815f4b 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -161,12 +161,8 @@ int __init_memblock memblock_reserve_reserved_regions(void)
 
 static void __init_memblock memblock_remove_region(struct memblock_type *type, unsigned long r)
 {
-	unsigned long i;
-
-	for (i = r; i < type->cnt - 1; i++) {
-		type->regions[i].base = type->regions[i + 1].base;
-		type->regions[i].size = type->regions[i + 1].size;
-	}
+	memmove(&type->regions[r], &type->regions[r + 1],
+		(type->cnt - (r + 1)) * sizeof(type->regions[r]));
 	type->cnt--;
 
 	/* Special case for empty arrays */
@@ -174,6 +170,7 @@ static void __init_memblock memblock_remove_region(struct memblock_type *type, u
 		type->cnt = 1;
 		type->regions[0].base = 0;
 		type->regions[0].size = 0;
+		memblock_set_region_node(&type->regions[0], MAX_NUMNODES);
 	}
 }
 
@@ -266,7 +263,9 @@ static void __init_memblock memblock_merge_regions(struct memblock_type *type)
 		struct memblock_region *this = &type->regions[i];
 		struct memblock_region *next = &type->regions[i + 1];
 
-		if (this->base + this->size != next->base) {
+		if (this->base + this->size != next->base ||
+		    memblock_get_region_node(this) !=
+		    memblock_get_region_node(next)) {
 			BUG_ON(this->base + this->size > next->base);
 			i++;
 			continue;
@@ -290,7 +289,7 @@ static void __init_memblock memblock_merge_regions(struct memblock_type *type)
  */
 static void __init_memblock memblock_insert_region(struct memblock_type *type,
 						   int idx, phys_addr_t base,
-						   phys_addr_t size)
+						   phys_addr_t size, int nid)
 {
 	struct memblock_region *rgn = &type->regions[idx];
 
@@ -298,6 +297,7 @@ static void __init_memblock memblock_insert_region(struct memblock_type *type,
 	memmove(rgn + 1, rgn, (type->cnt - idx) * sizeof(*rgn));
 	rgn->base = base;
 	rgn->size = size;
+	memblock_set_region_node(rgn, nid);
 	type->cnt++;
 }
 
@@ -327,6 +327,7 @@ static long __init_memblock memblock_add_region(struct memblock_type *type,
 		WARN_ON(type->cnt != 1);
 		type->regions[0].base = base;
 		type->regions[0].size = size;
+		memblock_set_region_node(&type->regions[0], MAX_NUMNODES);
 		return 0;
 	}
 repeat:
@@ -355,7 +356,7 @@ repeat:
 			nr_new++;
 			if (insert)
 				memblock_insert_region(type, i++, base,
-						       rbase - base);
+						rbase - base, MAX_NUMNODES);
 		}
 		/* area below @rend is dealt with, forget about it */
 		base = min(rend, end);
@@ -365,7 +366,8 @@ repeat:
 	if (base < end) {
 		nr_new++;
 		if (insert)
-			memblock_insert_region(type, i, base, end - base);
+			memblock_insert_region(type, i, base, end - base,
+					       MAX_NUMNODES);
 	}
 
 	/*
@@ -459,6 +461,101 @@ long __init_memblock memblock_reserve(phys_addr_t base, phys_addr_t size)
 	return memblock_add_region(_rgn, base, size);
 }
 
+#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
+/*
+ * Common iterator interface used to define for_each_mem_range().
+ */
+void __init_memblock __next_mem_pfn_range(int *idx, int nid,
+				unsigned long *out_start_pfn,
+				unsigned long *out_end_pfn, int *out_nid)
+{
+	struct memblock_type *type = &memblock.memory;
+	struct memblock_region *r;
+
+	while (++*idx < type->cnt) {
+		r = &type->regions[*idx];
+
+		if (PFN_UP(r->base) >= PFN_DOWN(r->base + r->size))
+			continue;
+		if (nid == MAX_NUMNODES || nid == r->nid)
+			break;
+	}
+	if (*idx >= type->cnt) {
+		*idx = -1;
+		return;
+	}
+
+	if (out_start_pfn)
+		*out_start_pfn = PFN_UP(r->base);
+	if (out_end_pfn)
+		*out_end_pfn = PFN_DOWN(r->base + r->size);
+	if (out_nid)
+		*out_nid = r->nid;
+}
+
+/**
+ * memblock_set_node - set node ID on memblock regions
+ * @base: base of area to set node ID for
+ * @size: size of area to set node ID for
+ * @nid: node ID to set
+ *
+ * Set the nid of memblock memory regions in [@base,@base+@size) to @nid.
+ * Regions which cross the area boundaries are split as necessary.
+ *
+ * RETURNS:
+ * 0 on success, -errno on failure.
+ */
+int __init_memblock memblock_set_node(phys_addr_t base, phys_addr_t size,
+				      int nid)
+{
+	struct memblock_type *type = &memblock.memory;
+	phys_addr_t end = base + size;
+	int i;
+
+	/* we'll create at most two more regions */
+	while (type->cnt + 2 > type->max)
+		if (memblock_double_array(type) < 0)
+			return -ENOMEM;
+
+	for (i = 0; i < type->cnt; i++) {
+		struct memblock_region *rgn = &type->regions[i];
+		phys_addr_t rbase = rgn->base;
+		phys_addr_t rend = rbase + rgn->size;
+
+		if (rbase >= end)
+			break;
+		if (rend <= base)
+			continue;
+
+		if (rbase < base) {
+			/*
+			 * @rgn intersects from below.  Split and continue
+			 * to process the next region - the new top half.
+			 */
+			rgn->base = base;
+			rgn->size = rend - rgn->base;
+			memblock_insert_region(type, i, rbase, base - rbase,
+					       rgn->nid);
+		} else if (rend > end) {
+			/*
+			 * @rgn intersects from above.  Split and redo the
+			 * current region - the new bottom half.
+			 */
+			rgn->base = end;
+			rgn->size = rend - rgn->base;
+			memblock_insert_region(type, i--, rbase, end - rbase,
+					       rgn->nid);
+		} else {
+			/* @rgn is fully contained, set ->nid */
+			rgn->nid = nid;
+		}
+	}
+
+	memblock_merge_regions(type);
+	return 0;
+}
+#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
+
 phys_addr_t __init __memblock_alloc_base(phys_addr_t size, phys_addr_t align, phys_addr_t max_addr)
 {
 	phys_addr_t found;
@@ -689,19 +786,26 @@ void __init_memblock memblock_set_current_limit(phys_addr_t limit)
 	memblock.current_limit = limit;
 }
 
-static void __init_memblock memblock_dump(struct memblock_type *region, char *name)
+static void __init_memblock memblock_dump(struct memblock_type *type, char *name)
 {
 	unsigned long long base, size;
 	int i;
 
-	pr_info(" %s.cnt  = 0x%lx\n", name, region->cnt);
-
-	for (i = 0; i < region->cnt; i++) {
-		base = region->regions[i].base;
-		size = region->regions[i].size;
+	pr_info(" %s.cnt  = 0x%lx\n", name, type->cnt);
 
-		pr_info(" %s[%#x]\t[%#016llx-%#016llx], %#llx bytes\n",
-		    name, i, base, base + size - 1, size);
+	for (i = 0; i < type->cnt; i++) {
+		struct memblock_region *rgn = &type->regions[i];
+		char nid_buf[32] = "";
+
+		base = rgn->base;
+		size = rgn->size;
+#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
+		if (memblock_get_region_node(rgn) != MAX_NUMNODES)
+			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",
+			name, i, base, base + size - 1, size, nid_buf);
 	}
 }
 
@@ -759,11 +863,13 @@ void __init memblock_init(void)
 	 */
 	memblock.memory.regions[0].base = 0;
 	memblock.memory.regions[0].size = 0;
+	memblock_set_region_node(&memblock.memory.regions[0], MAX_NUMNODES);
 	memblock.memory.cnt = 1;
 
 	/* Ditto. */
 	memblock.reserved.regions[0].base = 0;
 	memblock.reserved.regions[0].size = 0;
+	memblock_set_region_node(&memblock.reserved.regions[0], MAX_NUMNODES);
 	memblock.reserved.cnt = 1;
 
 	memblock.current_limit = MEMBLOCK_ALLOC_ANYWHERE;
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 8ab5e5e..3c7ea45 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -182,28 +182,31 @@ static unsigned long __meminitdata nr_all_pages;
 static unsigned long __meminitdata dma_reserve;
 
 #ifdef CONFIG_ARCH_POPULATES_NODE_MAP
-  /*
-   * MAX_ACTIVE_REGIONS determines the maximum number of distinct
-   * ranges of memory (RAM) that may be registered with add_active_range().
-   * Ranges passed to add_active_range() will be merged if possible
-   * so the number of times add_active_range() can be called is
-   * related to the number of nodes and the number of holes
-   */
-  #ifdef CONFIG_MAX_ACTIVE_REGIONS
-    /* Allow an architecture to set MAX_ACTIVE_REGIONS to save memory */
-    #define MAX_ACTIVE_REGIONS CONFIG_MAX_ACTIVE_REGIONS
-  #else
-    #if MAX_NUMNODES >= 32
-      /* If there can be many nodes, allow up to 50 holes per node */
-      #define MAX_ACTIVE_REGIONS (MAX_NUMNODES*50)
+  #ifndef CONFIG_HAVE_MEMBLOCK_NODE_MAP
+    /*
+     * MAX_ACTIVE_REGIONS determines the maximum number of distinct ranges
+     * of memory (RAM) that may be registered with add_active_range().
+     * Ranges passed to add_active_range() will be merged if possible so
+     * the number of times add_active_range() can be called is related to
+     * the number of nodes and the number of holes
+     */
+    #ifdef CONFIG_MAX_ACTIVE_REGIONS
+      /* Allow an architecture to set MAX_ACTIVE_REGIONS to save memory */
+      #define MAX_ACTIVE_REGIONS CONFIG_MAX_ACTIVE_REGIONS
     #else
-      /* By default, allow up to 256 distinct regions */
-      #define MAX_ACTIVE_REGIONS 256
+      #if MAX_NUMNODES >= 32
+        /* If there can be many nodes, allow up to 50 holes per node */
+        #define MAX_ACTIVE_REGIONS (MAX_NUMNODES*50)
+      #else
+        /* By default, allow up to 256 distinct regions */
+        #define MAX_ACTIVE_REGIONS 256
+      #endif
     #endif
-  #endif
 
-  static struct node_active_region __meminitdata early_node_map[MAX_ACTIVE_REGIONS];
-  static int __meminitdata nr_nodemap_entries;
+    static struct node_active_region __meminitdata early_node_map[MAX_ACTIVE_REGIONS];
+    static int __meminitdata nr_nodemap_entries;
+#endif /* !CONFIG_HAVE_MEMBLOCK_NODE_MAP */
+
   static unsigned long __meminitdata arch_zone_lowest_possible_pfn[MAX_NR_ZONES];
   static unsigned long __meminitdata arch_zone_highest_possible_pfn[MAX_NR_ZONES];
   static unsigned long __initdata required_kernelcore;
@@ -4268,6 +4271,7 @@ static inline void setup_nr_node_ids(void)
 }
 #endif
 
+#ifndef CONFIG_HAVE_MEMBLOCK_NODE_MAP
 /*
  * Common iterator interface used to define for_each_mem_pfn_range().
  */
@@ -4456,6 +4460,11 @@ void __init sort_node_map(void)
 			sizeof(struct node_active_region),
 			cmp_node_active_region, NULL);
 }
+#else /* !CONFIG_HAVE_MEMBLOCK_NODE_MAP */
+static inline void sort_node_map(void)
+{
+}
+#endif
 
 /**
  * node_map_pfn_alignment - determine the maximum internode alignment
-- 
1.7.6


^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH UPDATED 04/13] x86: Use HAVE_MEMBLOCK_NODE_MAP
  2011-07-12  9:15 ` [PATCH 04/13] x86: Use HAVE_MEMBLOCK_NODE_MAP Tejun Heo
  2011-07-14  1:35   ` H. Peter Anvin
@ 2011-07-14  9:44   ` " Tejun Heo
  2011-07-14 21:33     ` [tip:x86/memblock] " tip-bot for Tejun Heo
  1 sibling, 1 reply; 54+ messages in thread
From: Tejun Heo @ 2011-07-14  9:44 UTC (permalink / raw)
  To: mingo, hpa, tglx, benh, yinghai, davem; +Cc: linux-kernel, linux-arch, x86

>From 5732e1247898d67cbf837585150fe9f68974671d Mon Sep 17 00:00:00 2001
From: Tejun Heo <tj@kernel.org>
Date: Thu, 14 Jul 2011 11:22:16 +0200

Convert x86 to HAVE_MEMBLOCK_NODE_MAP.  The only difference in memory
handling is that allocations can't no longer cross node boundaries
whether they're node affine or not, which shouldn't matter at all.

This conversion will enable further simplification of boot memory
handling.

-v2: Fix build failure on !NUMA configurations discovered by hpa.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
 arch/x86/Kconfig                |    1 +
 arch/x86/include/asm/memblock.h |    2 --
 arch/x86/mm/init_32.c           |    8 ++++----
 arch/x86/mm/init_64.c           |    2 +-
 arch/x86/mm/memblock.c          |   14 --------------
 arch/x86/mm/numa.c              |   15 +++++++--------
 6 files changed, 13 insertions(+), 29 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index da34972..97f0894 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -25,6 +25,7 @@ config X86
 	select HAVE_IOREMAP_PROT
 	select HAVE_KPROBES
 	select HAVE_MEMBLOCK
+	select HAVE_MEMBLOCK_NODE_MAP
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	select ARCH_WANT_FRAME_POINTERS
 	select HAVE_DMA_ATTRS
diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h
index 161792e..1460db2 100644
--- a/arch/x86/include/asm/memblock.h
+++ b/arch/x86/include/asm/memblock.h
@@ -12,8 +12,6 @@ int __get_free_all_memory_range(struct range **range, int nodeid,
 			 unsigned long start_pfn, unsigned long end_pfn);
 int get_free_all_memory_range(struct range **rangep, int nodeid);
 
-void memblock_x86_register_active_regions(int nid, unsigned long start_pfn,
-					 unsigned long last_pfn);
 u64 memblock_x86_hole_size(u64 start, u64 end);
 u64 memblock_x86_free_memory_in_range(u64 addr, u64 limit);
 u64 memblock_x86_memory_in_range(u64 addr, u64 limit);
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 29f7c6d..5d173db 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -650,18 +650,18 @@ void __init initmem_init(void)
 	highstart_pfn = highend_pfn = max_pfn;
 	if (max_pfn > max_low_pfn)
 		highstart_pfn = max_low_pfn;
-	memblock_x86_register_active_regions(0, 0, highend_pfn);
-	sparse_memory_present_with_active_regions(0);
 	printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
 		pages_to_mb(highend_pfn - highstart_pfn));
 	num_physpages = highend_pfn;
 	high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
 #else
-	memblock_x86_register_active_regions(0, 0, max_low_pfn);
-	sparse_memory_present_with_active_regions(0);
 	num_physpages = max_low_pfn;
 	high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
 #endif
+
+	memblock_set_node(0, (phys_addr_t)ULLONG_MAX, 0);
+	sparse_memory_present_with_active_regions(0);
+
 #ifdef CONFIG_FLATMEM
 	max_mapnr = num_physpages;
 #endif
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index d865c4a..7fb064c 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -607,7 +607,7 @@ kernel_physical_mapping_init(unsigned long start,
 #ifndef CONFIG_NUMA
 void __init initmem_init(void)
 {
-	memblock_x86_register_active_regions(0, 0, max_pfn);
+	memblock_set_node(0, (phys_addr_t)ULLONG_MAX, 0);
 }
 #endif
 
diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c
index e4569f8..97fbc39 100644
--- a/arch/x86/mm/memblock.c
+++ b/arch/x86/mm/memblock.c
@@ -283,20 +283,6 @@ static int __init memblock_x86_find_active_region(const struct memblock_region *
 	return 1;
 }
 
-/* Walk the memblock.memory map and register active regions within a node */
-void __init memblock_x86_register_active_regions(int nid, unsigned long start_pfn,
-					 unsigned long last_pfn)
-{
-	unsigned long ei_startpfn;
-	unsigned long ei_endpfn;
-	struct memblock_region *r;
-
-	for_each_memblock(memory, r)
-		if (memblock_x86_find_active_region(r, start_pfn, last_pfn,
-					   &ei_startpfn, &ei_endpfn))
-			add_active_range(nid, ei_startpfn, ei_endpfn);
-}
-
 /*
  * Find the hole size (in bytes) in the memory range.
  * @start: starting address of the memory range to scan
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index 824efad..f4a40bd 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -498,13 +498,10 @@ static int __init numa_register_memblks(struct numa_meminfo *mi)
 	if (WARN_ON(nodes_empty(node_possible_map)))
 		return -EINVAL;
 
-	for (i = 0; i < mi->nr_blks; i++)
-		memblock_x86_register_active_regions(mi->blk[i].nid,
-					mi->blk[i].start >> PAGE_SHIFT,
-					mi->blk[i].end >> PAGE_SHIFT);
-
-	/* for out of order entries */
-	sort_node_map();
+	for (i = 0; i < mi->nr_blks; i++) {
+		struct numa_memblk *mb = &mi->blk[i];
+		memblock_set_node(mb->start, mb->end - mb->start, mb->nid);
+	}
 
 	/*
 	 * If sections array is gonna be used for pfn -> nid mapping, check
@@ -538,6 +535,8 @@ static int __init numa_register_memblks(struct numa_meminfo *mi)
 			setup_node_data(nid, start, end);
 	}
 
+	/* Dump memblock with node info and return. */
+	memblock_dump_all();
 	return 0;
 }
 
@@ -575,7 +574,7 @@ static int __init numa_init(int (*init_func)(void))
 	nodes_clear(node_possible_map);
 	nodes_clear(node_online_map);
 	memset(&numa_meminfo, 0, sizeof(numa_meminfo));
-	remove_all_active_ranges();
+	WARN_ON(memblock_set_node(0, ULLONG_MAX, MAX_NUMNODES));
 	numa_reset_distance();
 
 	ret = init_func();
-- 
1.7.6


^ permalink raw reply	[flat|nested] 54+ messages in thread

* [PATCH UPDATED 12/13] memblock, x86: Make ARCH_DISCARD_MEMBLOCK a config option
  2011-07-12  9:16 ` [PATCH 12/13] memblock, x86: Make ARCH_DISCARD_MEMBLOCK a config option Tejun Heo
@ 2011-07-14  9:46   ` " Tejun Heo
  2011-07-14 21:37     ` [tip:x86/memblock] " tip-bot for Tejun Heo
  0 siblings, 1 reply; 54+ messages in thread
From: Tejun Heo @ 2011-07-14  9:46 UTC (permalink / raw)
  To: mingo, hpa, tglx, benh, yinghai, davem; +Cc: linux-kernel, linux-arch, x86

>From 6839454ae63f1eb21e515c10229ca95c22955fec Mon Sep 17 00:00:00 2001
From: Tejun Heo <tj@kernel.org>
Date: Thu, 14 Jul 2011 11:22:17 +0200

Make ARCH_DISCARD_MEMBLOCK a config option so that it can be handled
together with other MEMBLOCK options.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
Nothing really changed.  Just patch context update to resolve conflict
from updates earlier in the series.

Thanks.

 arch/x86/Kconfig                |    1 +
 arch/x86/include/asm/memblock.h |    2 --
 include/linux/memblock.h        |    2 +-
 mm/Kconfig                      |    3 +++
 mm/memblock.c                   |    2 +-
 5 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 97f0894..28116d4 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -26,6 +26,7 @@ config X86
 	select HAVE_KPROBES
 	select HAVE_MEMBLOCK
 	select HAVE_MEMBLOCK_NODE_MAP
+	select ARCH_DISCARD_MEMBLOCK
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	select ARCH_WANT_FRAME_POINTERS
 	select HAVE_DMA_ATTRS
diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h
index 17a882e..bc56670 100644
--- a/arch/x86/include/asm/memblock.h
+++ b/arch/x86/include/asm/memblock.h
@@ -1,8 +1,6 @@
 #ifndef _X86_MEMBLOCK_H
 #define _X86_MEMBLOCK_H
 
-#define ARCH_DISCARD_MEMBLOCK
-
 void memblock_x86_reserve_range(u64 start, u64 end, char *name);
 void memblock_x86_free_range(u64 start, u64 end);
 
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 31def58..2491355 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -197,7 +197,7 @@ static inline unsigned long memblock_region_reserved_end_pfn(const struct memblo
 	     region++)
 
 
-#ifdef ARCH_DISCARD_MEMBLOCK
+#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
 #define __init_memblock __meminit
 #define __initdata_memblock __meminitdata
 #else
diff --git a/mm/Kconfig b/mm/Kconfig
index 30a5d47..7c56971 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -134,6 +134,9 @@ config HAVE_MEMBLOCK
 config HAVE_MEMBLOCK_NODE_MAP
 	boolean
 
+config ARCH_DISCARD_MEMBLOCK
+	boolean
+
 # eventually, we can have this option just 'select SPARSEMEM'
 config MEMORY_HOTPLUG
 	bool "Allow for memory hot-add"
diff --git a/mm/memblock.c b/mm/memblock.c
index c4a8750..ebc6119 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -959,7 +959,7 @@ static int __init early_memblock(char *p)
 }
 early_param("memblock", early_memblock);
 
-#if defined(CONFIG_DEBUG_FS) && !defined(ARCH_DISCARD_MEMBLOCK)
+#if defined(CONFIG_DEBUG_FS) && !defined(CONFIG_ARCH_DISCARD_MEMBLOCK)
 
 static int memblock_debug_show(struct seq_file *m, void *private)
 {
-- 
1.7.6


^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code
  2011-07-12  9:15 [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Tejun Heo
                   ` (14 preceding siblings ...)
  2011-07-14  9:42 ` [PATCH 2.5/13] memblock: Use __meminit[data] instead of __init[data] Tejun Heo
@ 2011-07-14  9:49 ` Tejun Heo
  15 siblings, 0 replies; 54+ messages in thread
From: Tejun Heo @ 2011-07-14  9:49 UTC (permalink / raw)
  To: mingo, hpa, tglx, benh, yinghai, davem; +Cc: linux-kernel, linux-arch, x86

Hello,

I just posted one extra patch and several updated patches.  All the
updates were minor so I didn't want to resend the whole thing (yet).
It would probably be easiest to check the updated git branches.

 git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.git review-x86-mm-iter
 git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.git review-x86-mm-memblock

git.korg is still synching.  The first one should be
8168136c0d47b53b7964385990710516c1199124 and the second
fb514c91dd44d9d88f29b20dddeeb8882bd89066.

Thank you.

-- 
tejun

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH 13/13] memblock, x86: Replace memblock_x86_reserve/free_range() with generic ones
  2011-07-12  9:16 ` [PATCH 13/13] memblock, x86: Replace memblock_x86_reserve/free_range() with generic ones Tejun Heo
@ 2011-07-14 20:10   ` H. Peter Anvin
  2011-07-14 20:20     ` Tejun Heo
  2011-07-14 21:38     ` [tip:x86/memblock] memblock: Cast phys_addr_t to unsigned long long for printf use tip-bot for H. Peter Anvin
  2011-07-14 21:37   ` [tip:x86/memblock] memblock, x86: Replace memblock_x86_reserve/free_range() with generic ones tip-bot for Tejun Heo
  2011-07-26 21:06   ` [PATCH 13/13] " Yinghai Lu
  2 siblings, 2 replies; 54+ messages in thread
From: H. Peter Anvin @ 2011-07-14 20:10 UTC (permalink / raw)
  To: Tejun Heo
  Cc: mingo, tglx, benh, yinghai, davem, linux-kernel, linux-arch, x86

On 07/12/2011 02:16 AM, Tejun Heo wrote:
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -449,6 +449,9 @@ long __init_memblock memblock_remove(phys_addr_t base, phys_addr_t size)
>  
>  long __init_memblock memblock_free(phys_addr_t base, phys_addr_t size)
>  {
> +	memblock_dbg("   memblock_free: [%#016llx-%#016llx] %pF\n",
> +		     base, base + size, (void *)_RET_IP_);
> +
>  	return __memblock_remove(&memblock.reserved, base, size);
>  }
>  
> @@ -456,6 +459,8 @@ long __init_memblock memblock_reserve(phys_addr_t base, phys_addr_t size)
>  {
>  	struct memblock_type *_rgn = &memblock.reserved;
>  
> +	memblock_dbg("memblock_reserve: [%#016llx-%#016llx] %pF\n",
> +		     base, base + size, (void *)_RET_IP_);
>  	BUG_ON(0 == size);
>  
>  	return memblock_add_region(_rgn, base, size);

This assumes phys_addr_t == unsigned long long, which is just plain
wrong.  I will fix it up, but please take more care with that in the
future.  This triggers a warning when building for i386 non-PAE, which
is a good thing because it is a real error.

Also, don't we usually display resources as an *inclusive* range,
meaning that the last one should be base + size - 1?

	-hpa

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH 13/13] memblock, x86: Replace memblock_x86_reserve/free_range() with generic ones
  2011-07-14 20:10   ` H. Peter Anvin
@ 2011-07-14 20:20     ` Tejun Heo
  2011-07-14 20:23       ` H. Peter Anvin
  2011-07-14 21:38     ` [tip:x86/memblock] memblock: Cast phys_addr_t to unsigned long long for printf use tip-bot for H. Peter Anvin
  1 sibling, 1 reply; 54+ messages in thread
From: Tejun Heo @ 2011-07-14 20:20 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: mingo, tglx, benh, yinghai, davem, linux-kernel, linux-arch, x86

Hello,

On Thu, Jul 14, 2011 at 10:10 PM, H. Peter Anvin <hpa@zytor.com> wrote:
> On 07/12/2011 02:16 AM, Tejun Heo wrote:
>> +     memblock_dbg("memblock_reserve: [%#016llx-%#016llx] %pF\n",
>> +                  base, base + size, (void *)_RET_IP_);
>>       BUG_ON(0 == size);
>>
>>       return memblock_add_region(_rgn, base, size);
>
> This assumes phys_addr_t == unsigned long long, which is just plain
> wrong.  I will fix it up, but please take more care with that in the
> future.  This triggers a warning when building for i386 non-PAE, which
> is a good thing because it is a real error.

Oh, right, I got confused w/ u64.

> Also, don't we usually display resources as an *inclusive* range,
> meaning that the last one should be base + size - 1?

Hmm... looking at the boot log, not really. [ ) ranges are more
common. memblock code is one of notable exceptions and I actually was
thinking about converting it. [ ) ranges are easier to recognize and
most of code we have can't deal with the full range (and it shouldn't
need to - chopping off one top and bottom is much saner approach
anyway).

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH 13/13] memblock, x86: Replace memblock_x86_reserve/free_range() with generic ones
  2011-07-14 20:20     ` Tejun Heo
@ 2011-07-14 20:23       ` H. Peter Anvin
  2011-07-14 20:32         ` Tejun Heo
  0 siblings, 1 reply; 54+ messages in thread
From: H. Peter Anvin @ 2011-07-14 20:23 UTC (permalink / raw)
  To: Tejun Heo
  Cc: mingo, tglx, benh, yinghai, davem, linux-kernel, linux-arch, x86

On 07/14/2011 01:20 PM, Tejun Heo wrote:
> 
> Hmm... looking at the boot log, not really. [ ) ranges are more
> common. memblock code is one of notable exceptions and I actually was
> thinking about converting it. [ ) ranges are easier to recognize and
> most of code we have can't deal with the full range (and it shouldn't
> need to - chopping off one top and bottom is much saner approach
> anyway).
> 

Sorry I don't follow.  We display resources as [...] ranges, and in
particular when there are those kinds of brackets they tend to be
inclusive ranges.

For the internal representation, of course, [ ) ranges or (base, length)
are the only sensible options.

	-hpa

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH 13/13] memblock, x86: Replace memblock_x86_reserve/free_range() with generic ones
  2011-07-14 20:23       ` H. Peter Anvin
@ 2011-07-14 20:32         ` Tejun Heo
  2011-07-14 20:38           ` H. Peter Anvin
  0 siblings, 1 reply; 54+ messages in thread
From: Tejun Heo @ 2011-07-14 20:32 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: mingo, tglx, benh, yinghai, davem, linux-kernel, linux-arch, x86

Hello,

On Thu, Jul 14, 2011 at 10:23 PM, H. Peter Anvin <hpa@zytor.com> wrote:
> On 07/14/2011 01:20 PM, Tejun Heo wrote:
> Sorry I don't follow.  We display resources as [...] ranges, and in
> particular when there are those kinds of brackets they tend to be
> inclusive ranges.
>
> For the internal representation, of course, [ ) ranges or (base, length)
> are the only sensible options.

[ ) ranges: e820, init_memory_mapping, NUMA nodes, Zone PFN ranges, PM
nosave memory

[ ] ranges: MTRR, NODE_DATA, early_node_map, [mm]io ranges

Hmm... I was only looking at the early boot messages which didn't
include the io ranges.  It ultimately is a cosmetic issue so my
opinions aren't very strong but I think we can leave [mm]io ranges
alone and converge the rest into [ ) ranges sans the brackets?

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH 13/13] memblock, x86: Replace memblock_x86_reserve/free_range() with generic ones
  2011-07-14 20:32         ` Tejun Heo
@ 2011-07-14 20:38           ` H. Peter Anvin
  2011-07-14 20:41             ` Tejun Heo
  0 siblings, 1 reply; 54+ messages in thread
From: H. Peter Anvin @ 2011-07-14 20:38 UTC (permalink / raw)
  To: Tejun Heo
  Cc: mingo, tglx, benh, yinghai, davem, linux-kernel, linux-arch, x86

On 07/14/2011 01:32 PM, Tejun Heo wrote:
> Hello,
> 
> On Thu, Jul 14, 2011 at 10:23 PM, H. Peter Anvin <hpa@zytor.com> wrote:
>> On 07/14/2011 01:20 PM, Tejun Heo wrote:
>> Sorry I don't follow.  We display resources as [...] ranges, and in
>> particular when there are those kinds of brackets they tend to be
>> inclusive ranges.
>>
>> For the internal representation, of course, [ ) ranges or (base, length)
>> are the only sensible options.
> 
> [ ) ranges: e820, init_memory_mapping, NUMA nodes, Zone PFN ranges, PM
> nosave memory
> 
> [ ] ranges: MTRR, NODE_DATA, early_node_map, [mm]io ranges
> 
> Hmm... I was only looking at the early boot messages which didn't
> include the io ranges.  It ultimately is a cosmetic issue so my
> opinions aren't very strong but I think we can leave [mm]io ranges
> alone and converge the rest into [ ) ranges sans the brackets?
> 

Agreed it's a cosmetic issue... this discussion has already been had,
though, and the consensus is to move the kernel to the standardized
resource format.

	-hpa

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH 13/13] memblock, x86: Replace memblock_x86_reserve/free_range() with generic ones
  2011-07-14 20:38           ` H. Peter Anvin
@ 2011-07-14 20:41             ` Tejun Heo
  2011-07-14 20:43               ` H. Peter Anvin
  0 siblings, 1 reply; 54+ messages in thread
From: Tejun Heo @ 2011-07-14 20:41 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: mingo, tglx, benh, yinghai, davem, linux-kernel, linux-arch, x86

Hello,

On Thu, Jul 14, 2011 at 10:38 PM, H. Peter Anvin <hpa@zytor.com> wrote:
>> Hmm... I was only looking at the early boot messages which didn't
>> include the io ranges.  It ultimately is a cosmetic issue so my
>> opinions aren't very strong but I think we can leave [mm]io ranges
>> alone and converge the rest into [ ) ranges sans the brackets?
>
> Agreed it's a cosmetic issue... this discussion has already been had,
> though, and the consensus is to move the kernel to the standardized
> resource format.

OIC, in that case, please go ahead and change it.  It seems that we
haven't been too successful at applying the decision tho. :(

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH 13/13] memblock, x86: Replace memblock_x86_reserve/free_range() with generic ones
  2011-07-14 20:41             ` Tejun Heo
@ 2011-07-14 20:43               ` H. Peter Anvin
  0 siblings, 0 replies; 54+ messages in thread
From: H. Peter Anvin @ 2011-07-14 20:43 UTC (permalink / raw)
  To: Tejun Heo
  Cc: mingo, tglx, benh, yinghai, davem, linux-kernel, linux-arch, x86

On 07/14/2011 01:41 PM, Tejun Heo wrote:
> Hello,
> 
> On Thu, Jul 14, 2011 at 10:38 PM, H. Peter Anvin <hpa@zytor.com> wrote:
>>> Hmm... I was only looking at the early boot messages which didn't
>>> include the io ranges.  It ultimately is a cosmetic issue so my
>>> opinions aren't very strong but I think we can leave [mm]io ranges
>>> alone and converge the rest into [ ) ranges sans the brackets?
>>
>> Agreed it's a cosmetic issue... this discussion has already been had,
>> though, and the consensus is to move the kernel to the standardized
>> resource format.
> 
> OIC, in that case, please go ahead and change it.  It seems that we
> haven't been too successful at applying the decision tho. :(
> 

It's a work in progress.

	-hpa

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH 2.5/13] memblock: Use __meminit[data] instead of __init[data]
  2011-07-14  9:42 ` [PATCH 2.5/13] memblock: Use __meminit[data] instead of __init[data] Tejun Heo
@ 2011-07-14 21:00   ` Yinghai Lu
  2011-07-14 21:24     ` H. Peter Anvin
  2011-07-15  5:45     ` Tejun Heo
  2011-07-14 21:32   ` [tip:x86/memblock] " tip-bot for Tejun Heo
  1 sibling, 2 replies; 54+ messages in thread
From: Yinghai Lu @ 2011-07-14 21:00 UTC (permalink / raw)
  To: Tejun Heo; +Cc: mingo, hpa, tglx, benh, davem, linux-kernel, linux-arch, x86

On Thu, Jul 14, 2011 at 2:42 AM, Tejun Heo <tj@kernel.org> wrote:
> From 19ab281ed67b87a6623d725237a7333ca79f1e75 Mon Sep 17 00:00:00 2001
> From: Tejun Heo <tj@kernel.org>
> Date: Thu, 14 Jul 2011 11:22:16 +0200
>
> memblock will be extended to include early_node_map[], which is also
> used during memory hotplug.  Make memblock use __meminit[data] instead
> of __init[data] so that memory hotplug code can safely reference it.
>
> Signed-off-by: Tejun Heo <tj@kernel.org>
> Reported-by: Yinghai Lu <yinghai@kernel.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
>  include/linux/memblock.h |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/memblock.h b/include/linux/memblock.h
> index aa5df9e..434b958 100644
> --- a/include/linux/memblock.h
> +++ b/include/linux/memblock.h
> @@ -152,8 +152,8 @@ static inline unsigned long memblock_region_reserved_end_pfn(const struct memblo
>
>
>  #ifdef ARCH_DISCARD_MEMBLOCK
> -#define __init_memblock __init
> -#define __initdata_memblock __initdata
> +#define __init_memblock __meminit
> +#define __initdata_memblock __meminitdata
>  #else
>  #define __init_memblock
>  #define __initdata_memblock

that is not good. It will keep memblock.reserved related data and
functions after boot.
and those data/func are not used after slab is ready.

Thanks

Yinghai

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH 2.5/13] memblock: Use __meminit[data] instead of __init[data]
  2011-07-14 21:00   ` Yinghai Lu
@ 2011-07-14 21:24     ` H. Peter Anvin
  2011-07-15  5:45     ` Tejun Heo
  1 sibling, 0 replies; 54+ messages in thread
From: H. Peter Anvin @ 2011-07-14 21:24 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Tejun Heo, mingo, tglx, benh, davem, linux-kernel, linux-arch, x86

On 07/14/2011 02:00 PM, Yinghai Lu wrote:
>>
>> diff --git a/include/linux/memblock.h b/include/linux/memblock.h
>> index aa5df9e..434b958 100644
>> --- a/include/linux/memblock.h
>> +++ b/include/linux/memblock.h
>> @@ -152,8 +152,8 @@ static inline unsigned long memblock_region_reserved_end_pfn(const struct memblo
>>
>>
>>  #ifdef ARCH_DISCARD_MEMBLOCK
>> -#define __init_memblock __init
>> -#define __initdata_memblock __initdata
>> +#define __init_memblock __meminit
>> +#define __initdata_memblock __meminitdata
>>  #else
>>  #define __init_memblock
>>  #define __initdata_memblock
> 
> that is not good. It will keep memblock.reserved related data and
> functions after boot.
> and those data/func are not used after slab is ready.
> 

>From the look of it this ranges from about 7-19K, so I'm going to take
this and we can optimize this later.

	-hpa

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [tip:x86/memblock] memblock: Remove memblock_memory_can_coalesce()
  2011-07-12  9:15 ` [PATCH 01/13] memblock: Remove memblock_memory_can_coalesce() Tejun Heo
@ 2011-07-14 21:31   ` " tip-bot for Tejun Heo
  0 siblings, 0 replies; 54+ messages in thread
From: tip-bot for Tejun Heo @ 2011-07-14 21:31 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, benh, yinghai, tj, tglx, hpa

Commit-ID:  ed7b56a799cade11f458cd83e1150af54a66b7e8
Gitweb:     http://git.kernel.org/tip/ed7b56a799cade11f458cd83e1150af54a66b7e8
Author:     Tejun Heo <tj@kernel.org>
AuthorDate: Tue, 12 Jul 2011 11:15:54 +0200
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Thu, 14 Jul 2011 11:47:40 -0700

memblock: Remove memblock_memory_can_coalesce()

Arch could implement memblock_memor_can_coalesce() to veto merging of
adjacent or overlapping memblock regions; however, no arch did and any
vetoing would trigger WARN_ON().  Memblock regions are supposed to
deal with proper memory anyway.  Remove the unused hook.

Signed-off-by: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/1310462166-31469-2-git-send-email-tj@kernel.org
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 include/linux/memblock.h |    4 ----
 mm/memblock.c            |   29 -----------------------------
 2 files changed, 0 insertions(+), 33 deletions(-)

diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 7400d02..aa5df9e 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -92,10 +92,6 @@ extern int memblock_is_region_reserved(phys_addr_t base, phys_addr_t size);
 
 extern void memblock_dump_all(void);
 
-/* Provided by the architecture */
-extern int memblock_memory_can_coalesce(phys_addr_t addr1, phys_addr_t size1,
-				   phys_addr_t addr2, phys_addr_t size2);
-
 /**
  * memblock_set_current_limit - Set the current allocation limit to allow
  *                         limiting allocations to what is currently
diff --git a/mm/memblock.c b/mm/memblock.c
index a8edb42..bd3a3a9 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -251,12 +251,6 @@ static int __init_memblock memblock_double_array(struct memblock_type *type)
 	return 0;
 }
 
-extern int __init_memblock __weak memblock_memory_can_coalesce(phys_addr_t addr1, phys_addr_t size1,
-					  phys_addr_t addr2, phys_addr_t size2)
-{
-	return 1;
-}
-
 static long __init_memblock memblock_add_region(struct memblock_type *type,
 						phys_addr_t base, phys_addr_t size)
 {
@@ -282,17 +276,6 @@ static long __init_memblock memblock_add_region(struct memblock_type *type,
 		 * of a block.
 		 */
 		if (base < rgn->base && end >= rgn->base) {
-			/* If we can't coalesce, create a new block */
-			if (!memblock_memory_can_coalesce(base, size,
-							  rgn->base,
-							  rgn->size)) {
-				/* Overlap & can't coalesce are mutually
-				 * exclusive, if you do that, be prepared
-				 * for trouble
-				 */
-				WARN_ON(end != rgn->base);
-				goto new_block;
-			}
 			/* We extend the bottom of the block down to our
 			 * base
 			 */
@@ -316,17 +299,6 @@ static long __init_memblock memblock_add_region(struct memblock_type *type,
 		 * top of a block
 		 */
 		if (base <= rend && end >= rend) {
-			/* If we can't coalesce, create a new block */
-			if (!memblock_memory_can_coalesce(rgn->base,
-							  rgn->size,
-							  base, size)) {
-				/* Overlap & can't coalesce are mutually
-				 * exclusive, if you do that, be prepared
-				 * for trouble
-				 */
-				WARN_ON(rend != base);
-				goto new_block;
-			}
 			/* We adjust our base down to enclose the
 			 * original block and destroy it. It will be
 			 * part of our new allocation. Since we've
@@ -349,7 +321,6 @@ static long __init_memblock memblock_add_region(struct memblock_type *type,
 		return 0;
 	}
 
- new_block:
 	/* If we are out of space, we fail. It's too late to resize the array
 	 * but then this shouldn't have happened in the first place.
 	 */

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [tip:x86/memblock] memblock: Reimplement memblock_add_region()
  2011-07-12  9:15 ` [PATCH 02/13] memblock: Reimplement memblock_add_region() Tejun Heo
@ 2011-07-14 21:32   ` " tip-bot for Tejun Heo
  0 siblings, 0 replies; 54+ messages in thread
From: tip-bot for Tejun Heo @ 2011-07-14 21:32 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, benh, yinghai, tj, tglx, hpa

Commit-ID:  784656f9c680d334e7b4cdb6951c5c913e5a26bf
Gitweb:     http://git.kernel.org/tip/784656f9c680d334e7b4cdb6951c5c913e5a26bf
Author:     Tejun Heo <tj@kernel.org>
AuthorDate: Tue, 12 Jul 2011 11:15:55 +0200
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Thu, 14 Jul 2011 11:47:41 -0700

memblock: Reimplement memblock_add_region()

memblock_add_region() carefully checked for merge and overlap
conditions while adding a new region, which is complicated and makes
it difficult to allow arbitrary overlaps or add more merge conditions
(e.g. node ID).

This re-implements memblock_add_region() such that insertion is done
in two steps - all non-overlapping portions of new area are inserted
as separate regions first and then memblock_merge_regions() scan and
merge all neighbouring compatible regions.

This makes addition logic simpler and more versatile and enables
adding node information to memblock.

Signed-off-by: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/1310462166-31469-3-git-send-email-tj@kernel.org
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 mm/memblock.c |  197 ++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 111 insertions(+), 86 deletions(-)

diff --git a/mm/memblock.c b/mm/memblock.c
index bd3a3a9..992aa18 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -251,117 +251,142 @@ static int __init_memblock memblock_double_array(struct memblock_type *type)
 	return 0;
 }
 
-static long __init_memblock memblock_add_region(struct memblock_type *type,
-						phys_addr_t base, phys_addr_t size)
+/**
+ * memblock_merge_regions - merge neighboring compatible regions
+ * @type: memblock type to scan
+ *
+ * Scan @type and merge neighboring compatible regions.
+ */
+static void __init_memblock memblock_merge_regions(struct memblock_type *type)
 {
-	phys_addr_t end = base + size;
-	int i, slot = -1;
+	int i = 0;
 
-	/* First try and coalesce this MEMBLOCK with others */
-	for (i = 0; i < type->cnt; i++) {
-		struct memblock_region *rgn = &type->regions[i];
-		phys_addr_t rend = rgn->base + rgn->size;
+	/* cnt never goes below 1 */
+	while (i < type->cnt - 1) {
+		struct memblock_region *this = &type->regions[i];
+		struct memblock_region *next = &type->regions[i + 1];
 
-		/* Exit if there's no possible hits */
-		if (rgn->base > end || rgn->size == 0)
-			break;
-
-		/* Check if we are fully enclosed within an existing
-		 * block
-		 */
-		if (rgn->base <= base && rend >= end)
-			return 0;
+		if (this->base + this->size != next->base) {
+			BUG_ON(this->base + this->size > next->base);
+			i++;
+			continue;
+		}
 
-		/* Check if we overlap or are adjacent with the bottom
-		 * of a block.
-		 */
-		if (base < rgn->base && end >= rgn->base) {
-			/* We extend the bottom of the block down to our
-			 * base
-			 */
-			rgn->base = base;
-			rgn->size = rend - base;
+		this->size += next->size;
+		memmove(next, next + 1, (type->cnt - (i + 1)) * sizeof(*next));
+		type->cnt--;
+	}
+}
 
-			/* Return if we have nothing else to allocate
-			 * (fully coalesced)
-			 */
-			if (rend >= end)
-				return 0;
+/**
+ * memblock_insert_region - insert new memblock region
+ * @type: memblock type to insert into
+ * @idx: index for the insertion point
+ * @base: base address of the new region
+ * @size: size of the new region
+ *
+ * Insert new memblock region [@base,@base+@size) into @type at @idx.
+ * @type must already have extra room to accomodate the new region.
+ */
+static void __init_memblock memblock_insert_region(struct memblock_type *type,
+						   int idx, phys_addr_t base,
+						   phys_addr_t size)
+{
+	struct memblock_region *rgn = &type->regions[idx];
 
-			/* We continue processing from the end of the
-			 * coalesced block.
-			 */
-			base = rend;
-			size = end - base;
-		}
+	BUG_ON(type->cnt >= type->max);
+	memmove(rgn + 1, rgn, (type->cnt - idx) * sizeof(*rgn));
+	rgn->base = base;
+	rgn->size = size;
+	type->cnt++;
+}
 
-		/* Now check if we overlap or are adjacent with the
-		 * top of a block
-		 */
-		if (base <= rend && end >= rend) {
-			/* We adjust our base down to enclose the
-			 * original block and destroy it. It will be
-			 * part of our new allocation. Since we've
-			 * freed an entry, we know we won't fail
-			 * to allocate one later, so we won't risk
-			 * losing the original block allocation.
-			 */
-			size += (base - rgn->base);
-			base = rgn->base;
-			memblock_remove_region(type, i--);
-		}
-	}
+/**
+ * memblock_add_region - add new memblock region
+ * @type: memblock type to add new region into
+ * @base: base address of the new region
+ * @size: size of the new region
+ *
+ * Add new memblock region [@base,@base+@size) into @type.  The new region
+ * is allowed to overlap with existing ones - overlaps don't affect already
+ * existing regions.  @type is guaranteed to be minimal (all neighbouring
+ * compatible regions are merged) after the addition.
+ *
+ * RETURNS:
+ * 0 on success, -errno on failure.
+ */
+static long __init_memblock memblock_add_region(struct memblock_type *type,
+						phys_addr_t base, phys_addr_t size)
+{
+	bool insert = false;
+	phys_addr_t obase = base, end = base + size;
+	int i, nr_new;
 
-	/* If the array is empty, special case, replace the fake
-	 * filler region and return
-	 */
-	if ((type->cnt == 1) && (type->regions[0].size == 0)) {
+	/* special case for empty array */
+	if (type->regions[0].size == 0) {
+		WARN_ON(type->cnt != 1);
 		type->regions[0].base = base;
 		type->regions[0].size = size;
 		return 0;
 	}
-
-	/* If we are out of space, we fail. It's too late to resize the array
-	 * but then this shouldn't have happened in the first place.
+repeat:
+	/*
+	 * The following is executed twice.  Once with %false @insert and
+	 * then with %true.  The first counts the number of regions needed
+	 * to accomodate the new area.  The second actually inserts them.
 	 */
-	if (WARN_ON(type->cnt >= type->max))
-		return -1;
+	base = obase;
+	nr_new = 0;
+
+	for (i = 0; i < type->cnt; i++) {
+		struct memblock_region *rgn = &type->regions[i];
+		phys_addr_t rbase = rgn->base;
+		phys_addr_t rend = rbase + rgn->size;
 
-	/* Couldn't coalesce the MEMBLOCK, so add it to the sorted table. */
-	for (i = type->cnt - 1; i >= 0; i--) {
-		if (base < type->regions[i].base) {
-			type->regions[i+1].base = type->regions[i].base;
-			type->regions[i+1].size = type->regions[i].size;
-		} else {
-			type->regions[i+1].base = base;
-			type->regions[i+1].size = size;
-			slot = i + 1;
+		if (rbase >= end)
 			break;
+		if (rend <= base)
+			continue;
+		/*
+		 * @rgn overlaps.  If it separates the lower part of new
+		 * area, insert that portion.
+		 */
+		if (rbase > base) {
+			nr_new++;
+			if (insert)
+				memblock_insert_region(type, i++, base,
+						       rbase - base);
 		}
+		/* area below @rend is dealt with, forget about it */
+		base = min(rend, end);
 	}
-	if (base < type->regions[0].base) {
-		type->regions[0].base = base;
-		type->regions[0].size = size;
-		slot = 0;
+
+	/* insert the remaining portion */
+	if (base < end) {
+		nr_new++;
+		if (insert)
+			memblock_insert_region(type, i, base, end - base);
 	}
-	type->cnt++;
 
-	/* The array is full ? Try to resize it. If that fails, we undo
-	 * our allocation and return an error
+	/*
+	 * If this was the first round, resize array and repeat for actual
+	 * insertions; otherwise, merge and return.
 	 */
-	if (type->cnt == type->max && memblock_double_array(type)) {
-		BUG_ON(slot < 0);
-		memblock_remove_region(type, slot);
-		return -1;
+	if (!insert) {
+		while (type->cnt + nr_new > type->max)
+			if (memblock_double_array(type) < 0)
+				return -ENOMEM;
+		insert = true;
+		goto repeat;
+	} else {
+		memblock_merge_regions(type);
+		return 0;
 	}
-
-	return 0;
 }
 
 long __init_memblock memblock_add(phys_addr_t base, phys_addr_t size)
 {
 	return memblock_add_region(&memblock.memory, base, size);
-
 }
 
 static long __init_memblock __memblock_remove(struct memblock_type *type,

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [tip:x86/memblock] memblock: Use __meminit[data] instead of __init[data]
  2011-07-14  9:42 ` [PATCH 2.5/13] memblock: Use __meminit[data] instead of __init[data] Tejun Heo
  2011-07-14 21:00   ` Yinghai Lu
@ 2011-07-14 21:32   ` " tip-bot for Tejun Heo
  1 sibling, 0 replies; 54+ messages in thread
From: tip-bot for Tejun Heo @ 2011-07-14 21:32 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, benh, yinghai, tj, tglx, hpa

Commit-ID:  67e24bcb725cabd15ef577bf301275d03d6086d7
Gitweb:     http://git.kernel.org/tip/67e24bcb725cabd15ef577bf301275d03d6086d7
Author:     Tejun Heo <tj@kernel.org>
AuthorDate: Thu, 14 Jul 2011 11:42:03 +0200
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Thu, 14 Jul 2011 11:47:42 -0700

memblock: Use __meminit[data] instead of __init[data]

>From 19ab281ed67b87a6623d725237a7333ca79f1e75 Mon Sep 17 00:00:00 2001
From: Tejun Heo <tj@kernel.org>
Date: Thu, 14 Jul 2011 11:22:16 +0200

memblock will be extended to include early_node_map[], which is also
used during memory hotplug.  Make memblock use __meminit[data] instead
of __init[data] so that memory hotplug code can safely reference it.

Signed-off-by: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/20110714094203.GE3455@htj.dyndns.org
Reported-by: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 include/linux/memblock.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index aa5df9e..434b958 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -152,8 +152,8 @@ static inline unsigned long memblock_region_reserved_end_pfn(const struct memblo
 
 
 #ifdef ARCH_DISCARD_MEMBLOCK
-#define __init_memblock __init
-#define __initdata_memblock __initdata
+#define __init_memblock __meminit
+#define __initdata_memblock __meminitdata
 #else
 #define __init_memblock
 #define __initdata_memblock

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [tip:x86/memblock] memblock: Add optional region->nid
  2011-07-14  9:43   ` [PATCH UPDATED " Tejun Heo
@ 2011-07-14 21:32     ` " tip-bot for Tejun Heo
  0 siblings, 0 replies; 54+ messages in thread
From: tip-bot for Tejun Heo @ 2011-07-14 21:32 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, benh, yinghai, tj, tglx, hpa

Commit-ID:  7c0caeb866b0f648d91bb75b8bc6f86af95bb033
Gitweb:     http://git.kernel.org/tip/7c0caeb866b0f648d91bb75b8bc6f86af95bb033
Author:     Tejun Heo <tj@kernel.org>
AuthorDate: Thu, 14 Jul 2011 11:43:42 +0200
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Thu, 14 Jul 2011 11:47:43 -0700

memblock: Add optional region->nid

>From 83103b92f3234ec830852bbc5c45911bd6cbdb20 Mon Sep 17 00:00:00 2001
From: Tejun Heo <tj@kernel.org>
Date: Thu, 14 Jul 2011 11:22:16 +0200

Add optional region->nid which can be enabled by arch using
CONFIG_HAVE_MEMBLOCK_NODE_MAP.  When enabled, memblock also carries
NUMA node information and replaces early_node_map[].

Newly added memblocks have MAX_NUMNODES as nid.  Arch can then call
memblock_set_node() to set node information.  memblock takes care of
merging and node affine allocations w.r.t. node information.

When MEMBLOCK_NODE_MAP is enabled, early_node_map[], related data
structures and functions to manipulate and iterate it are disabled.
memblock version of __next_mem_pfn_range() is provided such that
for_each_mem_pfn_range() behaves the same and its users don't have to
be updated.

-v2: Yinghai spotted section mismatch caused by missing
     __init_memblock in memblock_set_node().  Fixed.

Signed-off-by: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/20110714094342.GF3455@htj.dyndns.org
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 include/linux/memblock.h |   26 ++++++++
 include/linux/mm.h       |    2 +
 mm/Kconfig               |    3 +
 mm/memblock.c            |  142 ++++++++++++++++++++++++++++++++++++++++------
 mm/page_alloc.c          |   47 +++++++++------
 5 files changed, 183 insertions(+), 37 deletions(-)

diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 434b958..c36a55d 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -24,6 +24,9 @@
 struct memblock_region {
 	phys_addr_t base;
 	phys_addr_t size;
+#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
+	int nid;
+#endif
 };
 
 struct memblock_type {
@@ -58,6 +61,29 @@ extern long memblock_remove(phys_addr_t base, phys_addr_t size);
 extern long memblock_free(phys_addr_t base, phys_addr_t size);
 extern long memblock_reserve(phys_addr_t base, phys_addr_t size);
 
+#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
+extern int memblock_set_node(phys_addr_t base, phys_addr_t size, int nid);
+
+static inline void memblock_set_region_node(struct memblock_region *r, int nid)
+{
+	r->nid = nid;
+}
+
+static inline int memblock_get_region_node(const struct memblock_region *r)
+{
+	return r->nid;
+}
+#else
+static inline void memblock_set_region_node(struct memblock_region *r, int nid)
+{
+}
+
+static inline int memblock_get_region_node(const struct memblock_region *r)
+{
+	return 0;
+}
+#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
+
 /* The numa aware allocator is only available if
  * CONFIG_ARCH_POPULATES_NODE_MAP is set
  */
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 9ebc65a..ceb1e4a 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1307,12 +1307,14 @@ extern void free_area_init_node(int nid, unsigned long * zones_size,
  * CONFIG_ARCH_POPULATES_NODE_MAP
  */
 extern void free_area_init_nodes(unsigned long *max_zone_pfn);
+#ifndef CONFIG_HAVE_MEMBLOCK_NODE_MAP
 extern void add_active_range(unsigned int nid, unsigned long start_pfn,
 					unsigned long end_pfn);
 extern void remove_active_range(unsigned int nid, unsigned long start_pfn,
 					unsigned long end_pfn);
 extern void remove_all_active_ranges(void);
 void sort_node_map(void);
+#endif
 unsigned long node_map_pfn_alignment(void);
 unsigned long __absent_pages_in_range(int nid, unsigned long start_pfn,
 						unsigned long end_pfn);
diff --git a/mm/Kconfig b/mm/Kconfig
index 8ca47a5..30a5d47 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -131,6 +131,9 @@ config SPARSEMEM_VMEMMAP
 config HAVE_MEMBLOCK
 	boolean
 
+config HAVE_MEMBLOCK_NODE_MAP
+	boolean
+
 # eventually, we can have this option just 'select SPARSEMEM'
 config MEMORY_HOTPLUG
 	bool "Allow for memory hot-add"
diff --git a/mm/memblock.c b/mm/memblock.c
index 992aa18..e815f4b 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -161,12 +161,8 @@ int __init_memblock memblock_reserve_reserved_regions(void)
 
 static void __init_memblock memblock_remove_region(struct memblock_type *type, unsigned long r)
 {
-	unsigned long i;
-
-	for (i = r; i < type->cnt - 1; i++) {
-		type->regions[i].base = type->regions[i + 1].base;
-		type->regions[i].size = type->regions[i + 1].size;
-	}
+	memmove(&type->regions[r], &type->regions[r + 1],
+		(type->cnt - (r + 1)) * sizeof(type->regions[r]));
 	type->cnt--;
 
 	/* Special case for empty arrays */
@@ -174,6 +170,7 @@ static void __init_memblock memblock_remove_region(struct memblock_type *type, u
 		type->cnt = 1;
 		type->regions[0].base = 0;
 		type->regions[0].size = 0;
+		memblock_set_region_node(&type->regions[0], MAX_NUMNODES);
 	}
 }
 
@@ -266,7 +263,9 @@ static void __init_memblock memblock_merge_regions(struct memblock_type *type)
 		struct memblock_region *this = &type->regions[i];
 		struct memblock_region *next = &type->regions[i + 1];
 
-		if (this->base + this->size != next->base) {
+		if (this->base + this->size != next->base ||
+		    memblock_get_region_node(this) !=
+		    memblock_get_region_node(next)) {
 			BUG_ON(this->base + this->size > next->base);
 			i++;
 			continue;
@@ -290,7 +289,7 @@ static void __init_memblock memblock_merge_regions(struct memblock_type *type)
  */
 static void __init_memblock memblock_insert_region(struct memblock_type *type,
 						   int idx, phys_addr_t base,
-						   phys_addr_t size)
+						   phys_addr_t size, int nid)
 {
 	struct memblock_region *rgn = &type->regions[idx];
 
@@ -298,6 +297,7 @@ static void __init_memblock memblock_insert_region(struct memblock_type *type,
 	memmove(rgn + 1, rgn, (type->cnt - idx) * sizeof(*rgn));
 	rgn->base = base;
 	rgn->size = size;
+	memblock_set_region_node(rgn, nid);
 	type->cnt++;
 }
 
@@ -327,6 +327,7 @@ static long __init_memblock memblock_add_region(struct memblock_type *type,
 		WARN_ON(type->cnt != 1);
 		type->regions[0].base = base;
 		type->regions[0].size = size;
+		memblock_set_region_node(&type->regions[0], MAX_NUMNODES);
 		return 0;
 	}
 repeat:
@@ -355,7 +356,7 @@ repeat:
 			nr_new++;
 			if (insert)
 				memblock_insert_region(type, i++, base,
-						       rbase - base);
+						rbase - base, MAX_NUMNODES);
 		}
 		/* area below @rend is dealt with, forget about it */
 		base = min(rend, end);
@@ -365,7 +366,8 @@ repeat:
 	if (base < end) {
 		nr_new++;
 		if (insert)
-			memblock_insert_region(type, i, base, end - base);
+			memblock_insert_region(type, i, base, end - base,
+					       MAX_NUMNODES);
 	}
 
 	/*
@@ -459,6 +461,101 @@ long __init_memblock memblock_reserve(phys_addr_t base, phys_addr_t size)
 	return memblock_add_region(_rgn, base, size);
 }
 
+#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
+/*
+ * Common iterator interface used to define for_each_mem_range().
+ */
+void __init_memblock __next_mem_pfn_range(int *idx, int nid,
+				unsigned long *out_start_pfn,
+				unsigned long *out_end_pfn, int *out_nid)
+{
+	struct memblock_type *type = &memblock.memory;
+	struct memblock_region *r;
+
+	while (++*idx < type->cnt) {
+		r = &type->regions[*idx];
+
+		if (PFN_UP(r->base) >= PFN_DOWN(r->base + r->size))
+			continue;
+		if (nid == MAX_NUMNODES || nid == r->nid)
+			break;
+	}
+	if (*idx >= type->cnt) {
+		*idx = -1;
+		return;
+	}
+
+	if (out_start_pfn)
+		*out_start_pfn = PFN_UP(r->base);
+	if (out_end_pfn)
+		*out_end_pfn = PFN_DOWN(r->base + r->size);
+	if (out_nid)
+		*out_nid = r->nid;
+}
+
+/**
+ * memblock_set_node - set node ID on memblock regions
+ * @base: base of area to set node ID for
+ * @size: size of area to set node ID for
+ * @nid: node ID to set
+ *
+ * Set the nid of memblock memory regions in [@base,@base+@size) to @nid.
+ * Regions which cross the area boundaries are split as necessary.
+ *
+ * RETURNS:
+ * 0 on success, -errno on failure.
+ */
+int __init_memblock memblock_set_node(phys_addr_t base, phys_addr_t size,
+				      int nid)
+{
+	struct memblock_type *type = &memblock.memory;
+	phys_addr_t end = base + size;
+	int i;
+
+	/* we'll create at most two more regions */
+	while (type->cnt + 2 > type->max)
+		if (memblock_double_array(type) < 0)
+			return -ENOMEM;
+
+	for (i = 0; i < type->cnt; i++) {
+		struct memblock_region *rgn = &type->regions[i];
+		phys_addr_t rbase = rgn->base;
+		phys_addr_t rend = rbase + rgn->size;
+
+		if (rbase >= end)
+			break;
+		if (rend <= base)
+			continue;
+
+		if (rbase < base) {
+			/*
+			 * @rgn intersects from below.  Split and continue
+			 * to process the next region - the new top half.
+			 */
+			rgn->base = base;
+			rgn->size = rend - rgn->base;
+			memblock_insert_region(type, i, rbase, base - rbase,
+					       rgn->nid);
+		} else if (rend > end) {
+			/*
+			 * @rgn intersects from above.  Split and redo the
+			 * current region - the new bottom half.
+			 */
+			rgn->base = end;
+			rgn->size = rend - rgn->base;
+			memblock_insert_region(type, i--, rbase, end - rbase,
+					       rgn->nid);
+		} else {
+			/* @rgn is fully contained, set ->nid */
+			rgn->nid = nid;
+		}
+	}
+
+	memblock_merge_regions(type);
+	return 0;
+}
+#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
+
 phys_addr_t __init __memblock_alloc_base(phys_addr_t size, phys_addr_t align, phys_addr_t max_addr)
 {
 	phys_addr_t found;
@@ -689,19 +786,26 @@ void __init_memblock memblock_set_current_limit(phys_addr_t limit)
 	memblock.current_limit = limit;
 }
 
-static void __init_memblock memblock_dump(struct memblock_type *region, char *name)
+static void __init_memblock memblock_dump(struct memblock_type *type, char *name)
 {
 	unsigned long long base, size;
 	int i;
 
-	pr_info(" %s.cnt  = 0x%lx\n", name, region->cnt);
-
-	for (i = 0; i < region->cnt; i++) {
-		base = region->regions[i].base;
-		size = region->regions[i].size;
+	pr_info(" %s.cnt  = 0x%lx\n", name, type->cnt);
 
-		pr_info(" %s[%#x]\t[%#016llx-%#016llx], %#llx bytes\n",
-		    name, i, base, base + size - 1, size);
+	for (i = 0; i < type->cnt; i++) {
+		struct memblock_region *rgn = &type->regions[i];
+		char nid_buf[32] = "";
+
+		base = rgn->base;
+		size = rgn->size;
+#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
+		if (memblock_get_region_node(rgn) != MAX_NUMNODES)
+			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",
+			name, i, base, base + size - 1, size, nid_buf);
 	}
 }
 
@@ -759,11 +863,13 @@ void __init memblock_init(void)
 	 */
 	memblock.memory.regions[0].base = 0;
 	memblock.memory.regions[0].size = 0;
+	memblock_set_region_node(&memblock.memory.regions[0], MAX_NUMNODES);
 	memblock.memory.cnt = 1;
 
 	/* Ditto. */
 	memblock.reserved.regions[0].base = 0;
 	memblock.reserved.regions[0].size = 0;
+	memblock_set_region_node(&memblock.reserved.regions[0], MAX_NUMNODES);
 	memblock.reserved.cnt = 1;
 
 	memblock.current_limit = MEMBLOCK_ALLOC_ANYWHERE;
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 8ab5e5e..3c7ea45 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -182,28 +182,31 @@ static unsigned long __meminitdata nr_all_pages;
 static unsigned long __meminitdata dma_reserve;
 
 #ifdef CONFIG_ARCH_POPULATES_NODE_MAP
-  /*
-   * MAX_ACTIVE_REGIONS determines the maximum number of distinct
-   * ranges of memory (RAM) that may be registered with add_active_range().
-   * Ranges passed to add_active_range() will be merged if possible
-   * so the number of times add_active_range() can be called is
-   * related to the number of nodes and the number of holes
-   */
-  #ifdef CONFIG_MAX_ACTIVE_REGIONS
-    /* Allow an architecture to set MAX_ACTIVE_REGIONS to save memory */
-    #define MAX_ACTIVE_REGIONS CONFIG_MAX_ACTIVE_REGIONS
-  #else
-    #if MAX_NUMNODES >= 32
-      /* If there can be many nodes, allow up to 50 holes per node */
-      #define MAX_ACTIVE_REGIONS (MAX_NUMNODES*50)
+  #ifndef CONFIG_HAVE_MEMBLOCK_NODE_MAP
+    /*
+     * MAX_ACTIVE_REGIONS determines the maximum number of distinct ranges
+     * of memory (RAM) that may be registered with add_active_range().
+     * Ranges passed to add_active_range() will be merged if possible so
+     * the number of times add_active_range() can be called is related to
+     * the number of nodes and the number of holes
+     */
+    #ifdef CONFIG_MAX_ACTIVE_REGIONS
+      /* Allow an architecture to set MAX_ACTIVE_REGIONS to save memory */
+      #define MAX_ACTIVE_REGIONS CONFIG_MAX_ACTIVE_REGIONS
     #else
-      /* By default, allow up to 256 distinct regions */
-      #define MAX_ACTIVE_REGIONS 256
+      #if MAX_NUMNODES >= 32
+        /* If there can be many nodes, allow up to 50 holes per node */
+        #define MAX_ACTIVE_REGIONS (MAX_NUMNODES*50)
+      #else
+        /* By default, allow up to 256 distinct regions */
+        #define MAX_ACTIVE_REGIONS 256
+      #endif
     #endif
-  #endif
 
-  static struct node_active_region __meminitdata early_node_map[MAX_ACTIVE_REGIONS];
-  static int __meminitdata nr_nodemap_entries;
+    static struct node_active_region __meminitdata early_node_map[MAX_ACTIVE_REGIONS];
+    static int __meminitdata nr_nodemap_entries;
+#endif /* !CONFIG_HAVE_MEMBLOCK_NODE_MAP */
+
   static unsigned long __meminitdata arch_zone_lowest_possible_pfn[MAX_NR_ZONES];
   static unsigned long __meminitdata arch_zone_highest_possible_pfn[MAX_NR_ZONES];
   static unsigned long __initdata required_kernelcore;
@@ -4268,6 +4271,7 @@ static inline void setup_nr_node_ids(void)
 }
 #endif
 
+#ifndef CONFIG_HAVE_MEMBLOCK_NODE_MAP
 /*
  * Common iterator interface used to define for_each_mem_pfn_range().
  */
@@ -4456,6 +4460,11 @@ void __init sort_node_map(void)
 			sizeof(struct node_active_region),
 			cmp_node_active_region, NULL);
 }
+#else /* !CONFIG_HAVE_MEMBLOCK_NODE_MAP */
+static inline void sort_node_map(void)
+{
+}
+#endif
 
 /**
  * node_map_pfn_alignment - determine the maximum internode alignment

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [tip:x86/memblock] x86: Use HAVE_MEMBLOCK_NODE_MAP
  2011-07-14  9:44   ` [PATCH UPDATED " Tejun Heo
@ 2011-07-14 21:33     ` " tip-bot for Tejun Heo
  0 siblings, 0 replies; 54+ messages in thread
From: tip-bot for Tejun Heo @ 2011-07-14 21:33 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, benh, yinghai, tj, tglx, hpa

Commit-ID:  0608f70c78a384c2f225f2de226ca057a196f108
Gitweb:     http://git.kernel.org/tip/0608f70c78a384c2f225f2de226ca057a196f108
Author:     Tejun Heo <tj@kernel.org>
AuthorDate: Thu, 14 Jul 2011 11:44:23 +0200
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Thu, 14 Jul 2011 11:47:43 -0700

x86: Use HAVE_MEMBLOCK_NODE_MAP

>From 5732e1247898d67cbf837585150fe9f68974671d Mon Sep 17 00:00:00 2001
From: Tejun Heo <tj@kernel.org>
Date: Thu, 14 Jul 2011 11:22:16 +0200

Convert x86 to HAVE_MEMBLOCK_NODE_MAP.  The only difference in memory
handling is that allocations can't no longer cross node boundaries
whether they're node affine or not, which shouldn't matter at all.

This conversion will enable further simplification of boot memory
handling.

-v2: Fix build failure on !NUMA configurations discovered by hpa.

Signed-off-by: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/20110714094423.GG3455@htj.dyndns.org
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/Kconfig                |    1 +
 arch/x86/include/asm/memblock.h |    2 --
 arch/x86/mm/init_32.c           |    8 ++++----
 arch/x86/mm/init_64.c           |    2 +-
 arch/x86/mm/memblock.c          |   14 --------------
 arch/x86/mm/numa.c              |   15 +++++++--------
 6 files changed, 13 insertions(+), 29 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index da34972..97f0894 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -25,6 +25,7 @@ config X86
 	select HAVE_IOREMAP_PROT
 	select HAVE_KPROBES
 	select HAVE_MEMBLOCK
+	select HAVE_MEMBLOCK_NODE_MAP
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	select ARCH_WANT_FRAME_POINTERS
 	select HAVE_DMA_ATTRS
diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h
index 161792e..1460db2 100644
--- a/arch/x86/include/asm/memblock.h
+++ b/arch/x86/include/asm/memblock.h
@@ -12,8 +12,6 @@ int __get_free_all_memory_range(struct range **range, int nodeid,
 			 unsigned long start_pfn, unsigned long end_pfn);
 int get_free_all_memory_range(struct range **rangep, int nodeid);
 
-void memblock_x86_register_active_regions(int nid, unsigned long start_pfn,
-					 unsigned long last_pfn);
 u64 memblock_x86_hole_size(u64 start, u64 end);
 u64 memblock_x86_free_memory_in_range(u64 addr, u64 limit);
 u64 memblock_x86_memory_in_range(u64 addr, u64 limit);
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 29f7c6d..5d173db 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -650,18 +650,18 @@ void __init initmem_init(void)
 	highstart_pfn = highend_pfn = max_pfn;
 	if (max_pfn > max_low_pfn)
 		highstart_pfn = max_low_pfn;
-	memblock_x86_register_active_regions(0, 0, highend_pfn);
-	sparse_memory_present_with_active_regions(0);
 	printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
 		pages_to_mb(highend_pfn - highstart_pfn));
 	num_physpages = highend_pfn;
 	high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
 #else
-	memblock_x86_register_active_regions(0, 0, max_low_pfn);
-	sparse_memory_present_with_active_regions(0);
 	num_physpages = max_low_pfn;
 	high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
 #endif
+
+	memblock_set_node(0, (phys_addr_t)ULLONG_MAX, 0);
+	sparse_memory_present_with_active_regions(0);
+
 #ifdef CONFIG_FLATMEM
 	max_mapnr = num_physpages;
 #endif
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index d865c4a..7fb064c 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -607,7 +607,7 @@ kernel_physical_mapping_init(unsigned long start,
 #ifndef CONFIG_NUMA
 void __init initmem_init(void)
 {
-	memblock_x86_register_active_regions(0, 0, max_pfn);
+	memblock_set_node(0, (phys_addr_t)ULLONG_MAX, 0);
 }
 #endif
 
diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c
index e4569f8..97fbc39 100644
--- a/arch/x86/mm/memblock.c
+++ b/arch/x86/mm/memblock.c
@@ -283,20 +283,6 @@ static int __init memblock_x86_find_active_region(const struct memblock_region *
 	return 1;
 }
 
-/* Walk the memblock.memory map and register active regions within a node */
-void __init memblock_x86_register_active_regions(int nid, unsigned long start_pfn,
-					 unsigned long last_pfn)
-{
-	unsigned long ei_startpfn;
-	unsigned long ei_endpfn;
-	struct memblock_region *r;
-
-	for_each_memblock(memory, r)
-		if (memblock_x86_find_active_region(r, start_pfn, last_pfn,
-					   &ei_startpfn, &ei_endpfn))
-			add_active_range(nid, ei_startpfn, ei_endpfn);
-}
-
 /*
  * Find the hole size (in bytes) in the memory range.
  * @start: starting address of the memory range to scan
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index 824efad..f4a40bd 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -498,13 +498,10 @@ static int __init numa_register_memblks(struct numa_meminfo *mi)
 	if (WARN_ON(nodes_empty(node_possible_map)))
 		return -EINVAL;
 
-	for (i = 0; i < mi->nr_blks; i++)
-		memblock_x86_register_active_regions(mi->blk[i].nid,
-					mi->blk[i].start >> PAGE_SHIFT,
-					mi->blk[i].end >> PAGE_SHIFT);
-
-	/* for out of order entries */
-	sort_node_map();
+	for (i = 0; i < mi->nr_blks; i++) {
+		struct numa_memblk *mb = &mi->blk[i];
+		memblock_set_node(mb->start, mb->end - mb->start, mb->nid);
+	}
 
 	/*
 	 * If sections array is gonna be used for pfn -> nid mapping, check
@@ -538,6 +535,8 @@ static int __init numa_register_memblks(struct numa_meminfo *mi)
 			setup_node_data(nid, start, end);
 	}
 
+	/* Dump memblock with node info and return. */
+	memblock_dump_all();
 	return 0;
 }
 
@@ -575,7 +574,7 @@ static int __init numa_init(int (*init_func)(void))
 	nodes_clear(node_possible_map);
 	nodes_clear(node_online_map);
 	memset(&numa_meminfo, 0, sizeof(numa_meminfo));
-	remove_all_active_ranges();
+	WARN_ON(memblock_set_node(0, ULLONG_MAX, MAX_NUMNODES));
 	numa_reset_distance();
 
 	ret = init_func();

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [tip:x86/memblock] x86: Use __memblock_alloc_base() in early_reserve_e820()
  2011-07-12  9:15 ` [PATCH 05/13] x86: Use __memblock_alloc_base() in early_reserve_e820() Tejun Heo
@ 2011-07-14 21:33   ` " tip-bot for Tejun Heo
  0 siblings, 0 replies; 54+ messages in thread
From: tip-bot for Tejun Heo @ 2011-07-14 21:33 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, benh, yinghai, tj, tglx, hpa

Commit-ID:  ab5d140b9eafae402aa3e673a63c5ef6164a9dd2
Gitweb:     http://git.kernel.org/tip/ab5d140b9eafae402aa3e673a63c5ef6164a9dd2
Author:     Tejun Heo <tj@kernel.org>
AuthorDate: Tue, 12 Jul 2011 11:15:58 +0200
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Thu, 14 Jul 2011 11:47:47 -0700

x86: Use __memblock_alloc_base() in early_reserve_e820()

early_reserve_e820() implements its own ad-hoc early allocator using
memblock_x86_find_in_range_size().  Use __memblock_alloc_base()
instead and remove the unnecessary @startt parameter (it's top-down
allocation anyway).

Signed-off-by: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/1310462166-31469-6-git-send-email-tj@kernel.org
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/include/asm/e820.h |    2 +-
 arch/x86/kernel/e820.c      |   30 ++++++------------------------
 arch/x86/kernel/mpparse.c   |    6 ++----
 3 files changed, 9 insertions(+), 29 deletions(-)

diff --git a/arch/x86/include/asm/e820.h b/arch/x86/include/asm/e820.h
index 908b969..3778256 100644
--- a/arch/x86/include/asm/e820.h
+++ b/arch/x86/include/asm/e820.h
@@ -117,7 +117,7 @@ static inline void early_memtest(unsigned long start, unsigned long end)
 
 extern unsigned long e820_end_of_ram_pfn(void);
 extern unsigned long e820_end_of_low_ram_pfn(void);
-extern u64 early_reserve_e820(u64 startt, u64 sizet, u64 align);
+extern u64 early_reserve_e820(u64 sizet, u64 align);
 
 void memblock_x86_fill(void);
 void memblock_find_dma_reserve(void);
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 0f9ff58..b99d940 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -737,35 +737,17 @@ core_initcall(e820_mark_nvs_memory);
 /*
  * pre allocated 4k and reserved it in memblock and e820_saved
  */
-u64 __init early_reserve_e820(u64 startt, u64 sizet, u64 align)
+u64 __init early_reserve_e820(u64 size, u64 align)
 {
-	u64 size = 0;
 	u64 addr;
-	u64 start;
 
-	for (start = startt; ; start += size) {
-		start = memblock_x86_find_in_range_size(start, &size, align);
-		if (!start)
-			return 0;
-		if (size >= sizet)
-			break;
+	addr = __memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ACCESSIBLE);
+	if (addr) {
+		e820_update_range_saved(addr, size, E820_RAM, E820_RESERVED);
+		printk(KERN_INFO "update e820_saved for early_reserve_e820\n");
+		update_e820_saved();
 	}
 
-#ifdef CONFIG_X86_32
-	if (start >= MAXMEM)
-		return 0;
-	if (start + size > MAXMEM)
-		size = MAXMEM - start;
-#endif
-
-	addr = round_down(start + size - sizet, align);
-	if (addr < start)
-		return 0;
-	memblock_x86_reserve_range(addr, addr + sizet, "new next");
-	e820_update_range_saved(addr, sizet, E820_RAM, E820_RESERVED);
-	printk(KERN_INFO "update e820_saved for early_reserve_e820\n");
-	update_e820_saved();
-
 	return addr;
 }
 
diff --git a/arch/x86/kernel/mpparse.c b/arch/x86/kernel/mpparse.c
index 9103b89..8faeaa0 100644
--- a/arch/x86/kernel/mpparse.c
+++ b/arch/x86/kernel/mpparse.c
@@ -836,10 +836,8 @@ early_param("alloc_mptable", parse_alloc_mptable_opt);
 
 void __init early_reserve_e820_mpc_new(void)
 {
-	if (enable_update_mptable && alloc_mptable) {
-		u64 startt = 0;
-		mpc_new_phys = early_reserve_e820(startt, mpc_new_length, 4);
-	}
+	if (enable_update_mptable && alloc_mptable)
+		mpc_new_phys = early_reserve_e820(mpc_new_length, 4);
 }
 
 static int __init update_mp_table(void)

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [tip:x86/memblock] memblock: Implement for_each_free_mem_range()
  2011-07-12  9:15 ` [PATCH 06/13] memblock: Implement for_each_free_mem_range() Tejun Heo
@ 2011-07-14 21:34   ` " tip-bot for Tejun Heo
  0 siblings, 0 replies; 54+ messages in thread
From: tip-bot for Tejun Heo @ 2011-07-14 21:34 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, benh, yinghai, tj, tglx, hpa

Commit-ID:  35fd0808d7d8d001cd72f112e3bca84664b596a3
Gitweb:     http://git.kernel.org/tip/35fd0808d7d8d001cd72f112e3bca84664b596a3
Author:     Tejun Heo <tj@kernel.org>
AuthorDate: Tue, 12 Jul 2011 11:15:59 +0200
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Thu, 14 Jul 2011 11:47:47 -0700

memblock: Implement for_each_free_mem_range()

Implement for_each_free_mem_range() which iterates over free memory
areas according to memblock (memory && !reserved).  This will be used
to simplify memblock users.

Signed-off-by: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/1310462166-31469-7-git-send-email-tj@kernel.org
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 include/linux/memblock.h |   20 ++++++++++++
 mm/memblock.c            |   76 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 96 insertions(+), 0 deletions(-)

diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index c36a55d..31def58 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -61,6 +61,26 @@ extern long memblock_remove(phys_addr_t base, phys_addr_t size);
 extern long memblock_free(phys_addr_t base, phys_addr_t size);
 extern long memblock_reserve(phys_addr_t base, phys_addr_t size);
 
+extern void __next_free_mem_range(u64 *idx, int nid, phys_addr_t *out_start,
+				  phys_addr_t *out_end, int *out_nid);
+
+/**
+ * for_each_free_mem_range - iterate through free memblock areas
+ * @i: u64 used as loop variable
+ * @nid: node selector, %MAX_NUMNODES for all nodes
+ * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL
+ * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL
+ * @p_nid: ptr to int for nid of the range, can be %NULL
+ *
+ * Walks over free (memory && !reserved) areas of memblock.  Available as
+ * soon as memblock is initialized.
+ */
+#define for_each_free_mem_range(i, nid, p_start, p_end, p_nid)		\
+	for (i = 0,							\
+	     __next_free_mem_range(&i, nid, p_start, p_end, p_nid);	\
+	     i != (u64)ULLONG_MAX;					\
+	     __next_free_mem_range(&i, nid, p_start, p_end, p_nid))
+
 #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
 extern int memblock_set_node(phys_addr_t base, phys_addr_t size, int nid);
 
diff --git a/mm/memblock.c b/mm/memblock.c
index e815f4b..c4a8750 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -461,6 +461,82 @@ long __init_memblock memblock_reserve(phys_addr_t base, phys_addr_t size)
 	return memblock_add_region(_rgn, base, size);
 }
 
+/**
+ * __next_free_mem_range - next function for for_each_free_mem_range()
+ * @idx: pointer to u64 loop variable
+ * @nid: nid: node selector, %MAX_NUMNODES for all nodes
+ * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL
+ * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL
+ * @p_nid: ptr to int for nid of the range, can be %NULL
+ *
+ * Find the first free area from *@idx which matches @nid, fill the out
+ * parameters, and update *@idx for the next iteration.  The lower 32bit of
+ * *@idx contains index into memory region and the upper 32bit indexes the
+ * areas before each reserved region.  For example, if reserved regions
+ * look like the following,
+ *
+ *	0:[0-16), 1:[32-48), 2:[128-130)
+ *
+ * The upper 32bit indexes the following regions.
+ *
+ *	0:[0-0), 1:[16-32), 2:[48-128), 3:[130-MAX)
+ *
+ * As both region arrays are sorted, the function advances the two indices
+ * in lockstep and returns each intersection.
+ */
+void __init_memblock __next_free_mem_range(u64 *idx, int nid,
+					   phys_addr_t *out_start,
+					   phys_addr_t *out_end, int *out_nid)
+{
+	struct memblock_type *mem = &memblock.memory;
+	struct memblock_type *rsv = &memblock.reserved;
+	int mi = *idx & 0xffffffff;
+	int ri = *idx >> 32;
+
+	for ( ; mi < mem->cnt; mi++) {
+		struct memblock_region *m = &mem->regions[mi];
+		phys_addr_t m_start = m->base;
+		phys_addr_t m_end = m->base + m->size;
+
+		/* only memory regions are associated with nodes, check it */
+		if (nid != MAX_NUMNODES && nid != memblock_get_region_node(m))
+			continue;
+
+		/* scan areas before each reservation for intersection */
+		for ( ; ri < rsv->cnt + 1; ri++) {
+			struct memblock_region *r = &rsv->regions[ri];
+			phys_addr_t r_start = ri ? r[-1].base + r[-1].size : 0;
+			phys_addr_t r_end = ri < rsv->cnt ? r->base : ULLONG_MAX;
+
+			/* if ri advanced past mi, break out to advance mi */
+			if (r_start >= m_end)
+				break;
+			/* if the two regions intersect, we're done */
+			if (m_start < r_end) {
+				if (out_start)
+					*out_start = max(m_start, r_start);
+				if (out_end)
+					*out_end = min(m_end, r_end);
+				if (out_nid)
+					*out_nid = memblock_get_region_node(m);
+				/*
+				 * The region which ends first is advanced
+				 * for the next iteration.
+				 */
+				if (m_end <= r_end)
+					mi++;
+				else
+					ri++;
+				*idx = (u32)mi | (u64)ri << 32;
+				return;
+			}
+		}
+	}
+
+	/* signal end of iteration */
+	*idx = ULLONG_MAX;
+}
+
 #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
 /*
  * Common iterator interface used to define for_each_mem_range().

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [tip:x86/memblock] x86: Replace memblock_x86_find_in_range_size() with for_each_free_mem_range()
  2011-07-12  9:16 ` [PATCH 07/13] x86: Replace memblock_x86_find_in_range_size() with for_each_free_mem_range() Tejun Heo
@ 2011-07-14 21:34   ` " tip-bot for Tejun Heo
  0 siblings, 0 replies; 54+ messages in thread
From: tip-bot for Tejun Heo @ 2011-07-14 21:34 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, benh, yinghai, tj, tglx, hpa

Commit-ID:  8d89ac808417e92a33fb5fa3c86352016643775a
Gitweb:     http://git.kernel.org/tip/8d89ac808417e92a33fb5fa3c86352016643775a
Author:     Tejun Heo <tj@kernel.org>
AuthorDate: Tue, 12 Jul 2011 11:16:00 +0200
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Thu, 14 Jul 2011 11:47:48 -0700

x86: Replace memblock_x86_find_in_range_size() with for_each_free_mem_range()

setup_bios_corruption_check() and memtest do_one_pass() open code
memblock free area iteration using memblock_x86_find_in_range_size().
Convert them to use for_each_free_mem_range() instead.

This leaves memblock_x86_find_in_range_size() and
memblock_x86_check_reserved_size() unused.  Kill them.

Signed-off-by: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/1310462166-31469-8-git-send-email-tj@kernel.org
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/include/asm/memblock.h |    3 --
 arch/x86/kernel/check.c         |   34 +++++++++------------
 arch/x86/mm/memblock.c          |   62 ---------------------------------------
 arch/x86/mm/memtest.c           |   31 ++++++++-----------
 4 files changed, 28 insertions(+), 102 deletions(-)

diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h
index 1460db2..d2a5a59 100644
--- a/arch/x86/include/asm/memblock.h
+++ b/arch/x86/include/asm/memblock.h
@@ -3,8 +3,6 @@
 
 #define ARCH_DISCARD_MEMBLOCK
 
-u64 memblock_x86_find_in_range_size(u64 start, u64 *sizep, u64 align);
-
 void memblock_x86_reserve_range(u64 start, u64 end, char *name);
 void memblock_x86_free_range(u64 start, u64 end);
 struct range;
@@ -15,6 +13,5 @@ int get_free_all_memory_range(struct range **rangep, int nodeid);
 u64 memblock_x86_hole_size(u64 start, u64 end);
 u64 memblock_x86_free_memory_in_range(u64 addr, u64 limit);
 u64 memblock_x86_memory_in_range(u64 addr, u64 limit);
-bool memblock_x86_check_reserved_size(u64 *addrp, u64 *sizep, u64 align);
 
 #endif
diff --git a/arch/x86/kernel/check.c b/arch/x86/kernel/check.c
index 95680fc..621cd23 100644
--- a/arch/x86/kernel/check.c
+++ b/arch/x86/kernel/check.c
@@ -62,7 +62,8 @@ early_param("memory_corruption_check_size", set_corruption_check_size);
 
 void __init setup_bios_corruption_check(void)
 {
-	u64 addr = PAGE_SIZE;	/* assume first page is reserved anyway */
+	phys_addr_t start, end;
+	u64 i;
 
 	if (memory_corruption_check == -1) {
 		memory_corruption_check =
@@ -82,28 +83,23 @@ void __init setup_bios_corruption_check(void)
 
 	corruption_check_size = round_up(corruption_check_size, PAGE_SIZE);
 
-	while (addr < corruption_check_size && num_scan_areas < MAX_SCAN_AREAS) {
-		u64 size;
-		addr = memblock_x86_find_in_range_size(addr, &size, PAGE_SIZE);
+	for_each_free_mem_range(i, MAX_NUMNODES, &start, &end, NULL) {
+		start = clamp_t(phys_addr_t, round_up(start, PAGE_SIZE),
+				PAGE_SIZE, corruption_check_size);
+		end = clamp_t(phys_addr_t, round_down(end, PAGE_SIZE),
+			      PAGE_SIZE, corruption_check_size);
+		if (start >= end)
+			continue;
 
-		if (!addr)
-			break;
-
-		if (addr >= corruption_check_size)
-			break;
-
-		if ((addr + size) > corruption_check_size)
-			size = corruption_check_size - addr;
-
-		memblock_x86_reserve_range(addr, addr + size, "SCAN RAM");
-		scan_areas[num_scan_areas].addr = addr;
-		scan_areas[num_scan_areas].size = size;
-		num_scan_areas++;
+		memblock_x86_reserve_range(start, end, "SCAN RAM");
+		scan_areas[num_scan_areas].addr = start;
+		scan_areas[num_scan_areas].size = end - start;
 
 		/* Assume we've already mapped this early memory */
-		memset(__va(addr), 0, size);
+		memset(__va(start), 0, end - start);
 
-		addr += size;
+		if (++num_scan_areas >= MAX_SCAN_AREAS)
+			break;
 	}
 
 	if (num_scan_areas)
diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c
index 97fbc39..648d47d 100644
--- a/arch/x86/mm/memblock.c
+++ b/arch/x86/mm/memblock.c
@@ -7,68 +7,6 @@
 #include <linux/mm.h>
 #include <linux/range.h>
 
-/* Check for already reserved areas */
-bool __init memblock_x86_check_reserved_size(u64 *addrp, u64 *sizep, u64 align)
-{
-	struct memblock_region *r;
-	u64 addr = *addrp, last;
-	u64 size = *sizep;
-	bool changed = false;
-
-again:
-	last = addr + size;
-	for_each_memblock(reserved, r) {
-		if (last > r->base && addr < r->base) {
-			size = r->base - addr;
-			changed = true;
-			goto again;
-		}
-		if (last > (r->base + r->size) && addr < (r->base + r->size)) {
-			addr = round_up(r->base + r->size, align);
-			size = last - addr;
-			changed = true;
-			goto again;
-		}
-		if (last <= (r->base + r->size) && addr >= r->base) {
-			*sizep = 0;
-			return false;
-		}
-	}
-	if (changed) {
-		*addrp = addr;
-		*sizep = size;
-	}
-	return changed;
-}
-
-/*
- * Find next free range after start, and size is returned in *sizep
- */
-u64 __init memblock_x86_find_in_range_size(u64 start, u64 *sizep, u64 align)
-{
-	struct memblock_region *r;
-
-	for_each_memblock(memory, r) {
-		u64 ei_start = r->base;
-		u64 ei_last = ei_start + r->size;
-		u64 addr;
-
-		addr = round_up(ei_start, align);
-		if (addr < start)
-			addr = round_up(start, align);
-		if (addr >= ei_last)
-			continue;
-		*sizep = ei_last - addr;
-		while (memblock_x86_check_reserved_size(&addr, sizep, align))
-			;
-
-		if (*sizep)
-			return addr;
-	}
-
-	return 0;
-}
-
 static __init struct range *find_range_array(int count)
 {
 	u64 end, size, mem;
diff --git a/arch/x86/mm/memtest.c b/arch/x86/mm/memtest.c
index 92faf3a..46a5ff2 100644
--- a/arch/x86/mm/memtest.c
+++ b/arch/x86/mm/memtest.c
@@ -70,24 +70,19 @@ static void __init memtest(u64 pattern, u64 start_phys, u64 size)
 
 static void __init do_one_pass(u64 pattern, u64 start, u64 end)
 {
-	u64 size = 0;
-
-	while (start < end) {
-		start = memblock_x86_find_in_range_size(start, &size, 1);
-
-		/* done ? */
-		if (start >= end)
-			break;
-		if (start + size > end)
-			size = end - start;
-
-		printk(KERN_INFO "  %010llx - %010llx pattern %016llx\n",
-		       (unsigned long long) start,
-		       (unsigned long long) start + size,
-		       (unsigned long long) cpu_to_be64(pattern));
-		memtest(pattern, start, size);
-
-		start += size;
+	u64 i;
+	phys_addr_t this_start, this_end;
+
+	for_each_free_mem_range(i, MAX_NUMNODES, &this_start, &this_end, NULL) {
+		this_start = clamp_t(phys_addr_t, this_start, start, end);
+		this_end = clamp_t(phys_addr_t, this_end, start, end);
+		if (this_start < this_end) {
+			printk(KERN_INFO "  %010llx - %010llx pattern %016llx\n",
+			       (unsigned long long)this_start,
+			       (unsigned long long)this_end,
+			       (unsigned long long)cpu_to_be64(pattern));
+			memtest(pattern, this_start, this_end - this_start);
+		}
 	}
 }
 

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [tip:x86/memblock] memblock, x86: Make free_all_memory_core_early() explicitly free lowmem only
  2011-07-12  9:16 ` [PATCH 08/13] memblock, x86: Make free_all_memory_core_early() explicitly free lowmem only Tejun Heo
@ 2011-07-14 21:35   ` " tip-bot for Tejun Heo
  0 siblings, 0 replies; 54+ messages in thread
From: tip-bot for Tejun Heo @ 2011-07-14 21:35 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, benh, yinghai, tj, tglx, hpa

Commit-ID:  64a02daacbc880bac1d6b3aeefbcd226a9341fa7
Gitweb:     http://git.kernel.org/tip/64a02daacbc880bac1d6b3aeefbcd226a9341fa7
Author:     Tejun Heo <tj@kernel.org>
AuthorDate: Tue, 12 Jul 2011 11:16:01 +0200
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Thu, 14 Jul 2011 11:47:49 -0700

memblock, x86: Make free_all_memory_core_early() explicitly free lowmem only

nomemblock is currently used only by x86 and on x86_32
free_all_memory_core_early() silently freed only the low mem because
get_free_all_memory_range() in arch/x86/mm/memblock.c implicitly
limited range to max_low_pfn.

Rename free_all_memory_core_early() to free_low_memory_core_early()
and make it call __get_free_all_memory_range() and limit the range to
max_low_pfn explicitly.  This makes things clearer and also is
consistent with the bootmem behavior.

This leaves get_free_all_memory_range() without any user.  Kill it.

Signed-off-by: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/1310462166-31469-9-git-send-email-tj@kernel.org
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/include/asm/memblock.h |    1 -
 arch/x86/mm/memblock.c          |   10 ----------
 arch/x86/mm/numa_64.c           |    2 +-
 include/linux/bootmem.h         |    2 +-
 mm/nobootmem.c                  |    8 ++++----
 5 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h
index d2a5a59..6c72eca 100644
--- a/arch/x86/include/asm/memblock.h
+++ b/arch/x86/include/asm/memblock.h
@@ -8,7 +8,6 @@ void memblock_x86_free_range(u64 start, u64 end);
 struct range;
 int __get_free_all_memory_range(struct range **range, int nodeid,
 			 unsigned long start_pfn, unsigned long end_pfn);
-int get_free_all_memory_range(struct range **rangep, int nodeid);
 
 u64 memblock_x86_hole_size(u64 start, u64 end);
 u64 memblock_x86_free_memory_in_range(u64 addr, u64 limit);
diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c
index 648d47d..0e8442a 100644
--- a/arch/x86/mm/memblock.c
+++ b/arch/x86/mm/memblock.c
@@ -89,16 +89,6 @@ int __init __get_free_all_memory_range(struct range **rangep, int nodeid,
 	return nr_range;
 }
 
-int __init get_free_all_memory_range(struct range **rangep, int nodeid)
-{
-	unsigned long end_pfn = -1UL;
-
-#ifdef CONFIG_X86_32
-	end_pfn = max_low_pfn;
-#endif
-	return __get_free_all_memory_range(rangep, nodeid, 0, end_pfn);
-}
-
 static u64 __init __memblock_x86_memory_in_range(u64 addr, u64 limit, bool get_free)
 {
 	int i, count;
diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c
index dd27f40..92e2711 100644
--- a/arch/x86/mm/numa_64.c
+++ b/arch/x86/mm/numa_64.c
@@ -19,7 +19,7 @@ unsigned long __init numa_free_all_bootmem(void)
 	for_each_online_node(i)
 		pages += free_all_bootmem_node(NODE_DATA(i));
 
-	pages += free_all_memory_core_early(MAX_NUMNODES);
+	pages += free_low_memory_core_early(MAX_NUMNODES);
 
 	return pages;
 }
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index ab344a5..66d3e95 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -44,7 +44,7 @@ extern unsigned long init_bootmem_node(pg_data_t *pgdat,
 				       unsigned long endpfn);
 extern unsigned long init_bootmem(unsigned long addr, unsigned long memend);
 
-unsigned long free_all_memory_core_early(int nodeid);
+extern unsigned long free_low_memory_core_early(int nodeid);
 extern unsigned long free_all_bootmem_node(pg_data_t *pgdat);
 extern unsigned long free_all_bootmem(void);
 
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index c781626..2037a8a 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -106,7 +106,7 @@ static void __init __free_pages_memory(unsigned long start, unsigned long end)
 		__free_pages_bootmem(pfn_to_page(i), 0);
 }
 
-unsigned long __init free_all_memory_core_early(int nodeid)
+unsigned long __init free_low_memory_core_early(int nodeid)
 {
 	int i;
 	u64 start, end;
@@ -114,7 +114,7 @@ unsigned long __init free_all_memory_core_early(int nodeid)
 	struct range *range = NULL;
 	int nr_range;
 
-	nr_range = get_free_all_memory_range(&range, nodeid);
+	nr_range = __get_free_all_memory_range(&range, nodeid, 0, max_low_pfn);
 
 	for (i = 0; i < nr_range; i++) {
 		start = range[i].start;
@@ -136,7 +136,7 @@ unsigned long __init free_all_bootmem_node(pg_data_t *pgdat)
 {
 	register_page_bootmem_info_node(pgdat);
 
-	/* free_all_memory_core_early(MAX_NUMNODES) will be called later */
+	/* free_low_memory_core_early(MAX_NUMNODES) will be called later */
 	return 0;
 }
 
@@ -154,7 +154,7 @@ unsigned long __init free_all_bootmem(void)
 	 * Use MAX_NUMNODES will make sure all ranges in early_node_map[]
 	 *  will be used instead of only Node0 related
 	 */
-	return free_all_memory_core_early(MAX_NUMNODES);
+	return free_low_memory_core_early(MAX_NUMNODES);
 }
 
 /**

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [tip:x86/memblock] memblock, x86: Replace __get_free_all_memory_range() with for_each_free_mem_range()
  2011-07-12  9:16 ` [PATCH 09/13] memblock, x86: Replace __get_free_all_memory_range() with for_each_free_mem_range() Tejun Heo
@ 2011-07-14 21:35   ` " tip-bot for Tejun Heo
  0 siblings, 0 replies; 54+ messages in thread
From: tip-bot for Tejun Heo @ 2011-07-14 21:35 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, benh, yinghai, tj, tglx, hpa

Commit-ID:  8a9ca34c11e1695dab7aff3cfa7780fbfe76b2f8
Gitweb:     http://git.kernel.org/tip/8a9ca34c11e1695dab7aff3cfa7780fbfe76b2f8
Author:     Tejun Heo <tj@kernel.org>
AuthorDate: Tue, 12 Jul 2011 11:16:02 +0200
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Thu, 14 Jul 2011 11:47:49 -0700

memblock, x86: Replace __get_free_all_memory_range() with for_each_free_mem_range()

__get_free_all_memory_range() walks memblock, calculates free memory
areas and fills in the specified range.  It can be easily replaced
with for_each_free_mem_range().

Convert free_low_memory_core_early() and
add_highpages_with_active_regions() to for_each_free_mem_range().
This leaves __get_free_all_memory_range() without any user.  Kill it
and related functions.

Signed-off-by: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/1310462166-31469-10-git-send-email-tj@kernel.org
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/include/asm/memblock.h |    3 --
 arch/x86/mm/init_32.c           |   28 +++++++-----------
 arch/x86/mm/memblock.c          |   59 ---------------------------------------
 mm/nobootmem.c                  |   28 ++++++++++--------
 4 files changed, 27 insertions(+), 91 deletions(-)

diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h
index 6c72eca..bc9e44b 100644
--- a/arch/x86/include/asm/memblock.h
+++ b/arch/x86/include/asm/memblock.h
@@ -5,9 +5,6 @@
 
 void memblock_x86_reserve_range(u64 start, u64 end, char *name);
 void memblock_x86_free_range(u64 start, u64 end);
-struct range;
-int __get_free_all_memory_range(struct range **range, int nodeid,
-			 unsigned long start_pfn, unsigned long end_pfn);
 
 u64 memblock_x86_hole_size(u64 start, u64 end);
 u64 memblock_x86_free_memory_in_range(u64 addr, u64 limit);
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 5d173db..0c1da39 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -427,23 +427,17 @@ static void __init add_one_highpage_init(struct page *page)
 void __init add_highpages_with_active_regions(int nid,
 			 unsigned long start_pfn, unsigned long end_pfn)
 {
-	struct range *range;
-	int nr_range;
-	int i;
-
-	nr_range = __get_free_all_memory_range(&range, nid, start_pfn, end_pfn);
-
-	for (i = 0; i < nr_range; i++) {
-		struct page *page;
-		int node_pfn;
-
-		for (node_pfn = range[i].start; node_pfn < range[i].end;
-		     node_pfn++) {
-			if (!pfn_valid(node_pfn))
-				continue;
-			page = pfn_to_page(node_pfn);
-			add_one_highpage_init(page);
-		}
+	phys_addr_t start, end;
+	u64 i;
+
+	for_each_free_mem_range(i, nid, &start, &end, NULL) {
+		unsigned long pfn = clamp_t(unsigned long, PFN_UP(start),
+					    start_pfn, end_pfn);
+		unsigned long e_pfn = clamp_t(unsigned long, PFN_DOWN(end),
+					      start_pfn, end_pfn);
+		for ( ; pfn < e_pfn; pfn++)
+			if (pfn_valid(pfn))
+				add_one_highpage_init(pfn_to_page(pfn));
 	}
 }
 #else
diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c
index 0e8442a..4107c1a 100644
--- a/arch/x86/mm/memblock.c
+++ b/arch/x86/mm/memblock.c
@@ -30,65 +30,6 @@ static __init struct range *find_range_array(int count)
 	return range;
 }
 
-static void __init memblock_x86_subtract_reserved(struct range *range, int az)
-{
-	u64 final_start, final_end;
-	struct memblock_region *r;
-
-	/* Take out region array itself at first*/
-	memblock_free_reserved_regions();
-
-	memblock_dbg("Subtract (%ld early reservations)\n", memblock.reserved.cnt);
-
-	for_each_memblock(reserved, r) {
-		memblock_dbg("  [%010llx-%010llx]\n", (u64)r->base, (u64)r->base + r->size - 1);
-		final_start = PFN_DOWN(r->base);
-		final_end = PFN_UP(r->base + r->size);
-		if (final_start >= final_end)
-			continue;
-		subtract_range(range, az, final_start, final_end);
-	}
-
-	/* Put region array back ? */
-	memblock_reserve_reserved_regions();
-}
-
-static int __init count_early_node_map(int nodeid)
-{
-	int i, cnt = 0;
-
-	for_each_mem_pfn_range(i, nodeid, NULL, NULL, NULL)
-		cnt++;
-	return cnt;
-}
-
-int __init __get_free_all_memory_range(struct range **rangep, int nodeid,
-			 unsigned long start_pfn, unsigned long end_pfn)
-{
-	int count;
-	struct range *range;
-	int nr_range;
-
-	count = (memblock.reserved.cnt + count_early_node_map(nodeid)) * 2;
-
-	range = find_range_array(count);
-	nr_range = 0;
-
-	/*
-	 * Use early_node_map[] and memblock.reserved.region to get range array
-	 * at first
-	 */
-	nr_range = add_from_early_node_map(range, count, nr_range, nodeid);
-	subtract_range(range, count, 0, start_pfn);
-	subtract_range(range, count, end_pfn, -1ULL);
-
-	memblock_x86_subtract_reserved(range, count);
-	nr_range = clean_sort_range(range, count);
-
-	*rangep = range;
-	return nr_range;
-}
-
 static u64 __init __memblock_x86_memory_in_range(u64 addr, u64 limit, bool get_free)
 {
 	int i, count;
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 2037a8a..7075bc0 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -108,21 +108,25 @@ static void __init __free_pages_memory(unsigned long start, unsigned long end)
 
 unsigned long __init free_low_memory_core_early(int nodeid)
 {
-	int i;
-	u64 start, end;
 	unsigned long count = 0;
-	struct range *range = NULL;
-	int nr_range;
-
-	nr_range = __get_free_all_memory_range(&range, nodeid, 0, max_low_pfn);
-
-	for (i = 0; i < nr_range; i++) {
-		start = range[i].start;
-		end = range[i].end;
-		count += end - start;
-		__free_pages_memory(start, end);
+	phys_addr_t start, end;
+	u64 i;
+
+	/* free reserved array temporarily so that it's treated as free area */
+	memblock_free_reserved_regions();
+
+	for_each_free_mem_range(i, MAX_NUMNODES, &start, &end, NULL) {
+		unsigned long start_pfn = PFN_UP(start);
+		unsigned long end_pfn = min_t(unsigned long,
+					      PFN_DOWN(end), max_low_pfn);
+		if (start_pfn < end_pfn) {
+			__free_pages_memory(start_pfn, end_pfn);
+			count += end_pfn - start_pfn;
+		}
 	}
 
+	/* put region array back? */
+	memblock_reserve_reserved_regions();
 	return count;
 }
 

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [tip:x86/memblock] memblock, x86: Reimplement memblock_find_dma_reserve() using iterators
  2011-07-12  9:16 ` [PATCH 10/13] memblock, x86: Reimplement memblock_find_dma_reserve() using iterators Tejun Heo
@ 2011-07-14 21:36   ` " tip-bot for Tejun Heo
  0 siblings, 0 replies; 54+ messages in thread
From: tip-bot for Tejun Heo @ 2011-07-14 21:36 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, benh, yinghai, tj, tglx, hpa

Commit-ID:  6b5d41a1b97f5529284f16170211b87fd60264c0
Gitweb:     http://git.kernel.org/tip/6b5d41a1b97f5529284f16170211b87fd60264c0
Author:     Tejun Heo <tj@kernel.org>
AuthorDate: Tue, 12 Jul 2011 11:16:03 +0200
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Thu, 14 Jul 2011 11:47:50 -0700

memblock, x86: Reimplement memblock_find_dma_reserve() using iterators

memblock_find_dma_reserve() wants to find out how much memory is
reserved under MAX_DMA_PFN.  memblock_x86_memory_[free_]in_range() are
used to find out the amounts of all available and free memory in the
area, which are then subtracted to find out the amount of reservation.

memblock_x86_memblock_[free_]in_range() are implemented using
__memblock_x86_memory_in_range() which builds ranges from memblock and
then count them, which is rather unnecessarily complex.

This patch open codes the counting logic directly in
memblock_find_dma_reserve() using memblock iterators and removes now
unused __memblock_x86_memory_in_range() and find_range_array().

Signed-off-by: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/1310462166-31469-11-git-send-email-tj@kernel.org
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/include/asm/memblock.h |    2 -
 arch/x86/kernel/e820.c          |   25 +++++++++--
 arch/x86/mm/memblock.c          |   87 ---------------------------------------
 3 files changed, 20 insertions(+), 94 deletions(-)

diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h
index bc9e44b..a0cc7d6 100644
--- a/arch/x86/include/asm/memblock.h
+++ b/arch/x86/include/asm/memblock.h
@@ -7,7 +7,5 @@ void memblock_x86_reserve_range(u64 start, u64 end, char *name);
 void memblock_x86_free_range(u64 start, u64 end);
 
 u64 memblock_x86_hole_size(u64 start, u64 end);
-u64 memblock_x86_free_memory_in_range(u64 addr, u64 limit);
-u64 memblock_x86_memory_in_range(u64 addr, u64 limit);
 
 #endif
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index b99d940..84475f1 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -1093,15 +1093,30 @@ void __init memblock_x86_fill(void)
 void __init memblock_find_dma_reserve(void)
 {
 #ifdef CONFIG_X86_64
-	u64 free_size_pfn;
-	u64 mem_size_pfn;
+	u64 nr_pages = 0, nr_free_pages = 0;
+	unsigned long start_pfn, end_pfn;
+	phys_addr_t start, end;
+	int i;
+	u64 u;
+
 	/*
 	 * need to find out used area below MAX_DMA_PFN
 	 * need to use memblock to get free size in [0, MAX_DMA_PFN]
 	 * at first, and assume boot_mem will not take below MAX_DMA_PFN
 	 */
-	mem_size_pfn = memblock_x86_memory_in_range(0, MAX_DMA_PFN << PAGE_SHIFT) >> PAGE_SHIFT;
-	free_size_pfn = memblock_x86_free_memory_in_range(0, MAX_DMA_PFN << PAGE_SHIFT) >> PAGE_SHIFT;
-	set_dma_reserve(mem_size_pfn - free_size_pfn);
+	for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, NULL) {
+		start_pfn = min_t(unsigned long, start_pfn, MAX_DMA_PFN);
+		end_pfn = min_t(unsigned long, end_pfn, MAX_DMA_PFN);
+		nr_pages += end_pfn - start_pfn;
+	}
+
+	for_each_free_mem_range(u, MAX_NUMNODES, &start, &end, NULL) {
+		start_pfn = min_t(unsigned long, PFN_UP(start), MAX_DMA_PFN);
+		end_pfn = min_t(unsigned long, PFN_DOWN(end), MAX_DMA_PFN);
+		if (start_pfn < end_pfn)
+			nr_free_pages += end_pfn - start_pfn;
+	}
+
+	set_dma_reserve(nr_pages - nr_free_pages);
 #endif
 }
diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c
index 4107c1a..a9d0972 100644
--- a/arch/x86/mm/memblock.c
+++ b/arch/x86/mm/memblock.c
@@ -7,93 +7,6 @@
 #include <linux/mm.h>
 #include <linux/range.h>
 
-static __init struct range *find_range_array(int count)
-{
-	u64 end, size, mem;
-	struct range *range;
-
-	size = sizeof(struct range) * count;
-	end = memblock.current_limit;
-
-	mem = memblock_find_in_range(0, end, size, sizeof(struct range));
-	if (!mem)
-		panic("can not find more space for range array");
-
-	/*
-	 * This range is tempoaray, so don't reserve it, it will not be
-	 * overlapped because We will not alloccate new buffer before
-	 * We discard this one
-	 */
-	range = __va(mem);
-	memset(range, 0, size);
-
-	return range;
-}
-
-static u64 __init __memblock_x86_memory_in_range(u64 addr, u64 limit, bool get_free)
-{
-	int i, count;
-	struct range *range;
-	int nr_range;
-	u64 final_start, final_end;
-	u64 free_size;
-	struct memblock_region *r;
-
-	count = (memblock.reserved.cnt + memblock.memory.cnt) * 2;
-
-	range = find_range_array(count);
-	nr_range = 0;
-
-	addr = PFN_UP(addr);
-	limit = PFN_DOWN(limit);
-
-	for_each_memblock(memory, r) {
-		final_start = PFN_UP(r->base);
-		final_end = PFN_DOWN(r->base + r->size);
-		if (final_start >= final_end)
-			continue;
-		if (final_start >= limit || final_end <= addr)
-			continue;
-
-		nr_range = add_range(range, count, nr_range, final_start, final_end);
-	}
-	subtract_range(range, count, 0, addr);
-	subtract_range(range, count, limit, -1ULL);
-
-	/* Subtract memblock.reserved.region in range ? */
-	if (!get_free)
-		goto sort_and_count_them;
-	for_each_memblock(reserved, r) {
-		final_start = PFN_DOWN(r->base);
-		final_end = PFN_UP(r->base + r->size);
-		if (final_start >= final_end)
-			continue;
-		if (final_start >= limit || final_end <= addr)
-			continue;
-
-		subtract_range(range, count, final_start, final_end);
-	}
-
-sort_and_count_them:
-	nr_range = clean_sort_range(range, count);
-
-	free_size = 0;
-	for (i = 0; i < nr_range; i++)
-		free_size += range[i].end - range[i].start;
-
-	return free_size << PAGE_SHIFT;
-}
-
-u64 __init memblock_x86_free_memory_in_range(u64 addr, u64 limit)
-{
-	return __memblock_x86_memory_in_range(addr, limit, true);
-}
-
-u64 __init memblock_x86_memory_in_range(u64 addr, u64 limit)
-{
-	return __memblock_x86_memory_in_range(addr, limit, false);
-}
-
 void __init memblock_x86_reserve_range(u64 start, u64 end, char *name)
 {
 	if (start == end)

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [tip:x86/memblock] x86: Use absent_pages_in_range() instead of memblock_x86_hole_size()
  2011-07-12  9:16 ` [PATCH 11/13] x86: Use absent_pages_in_range() instead of memblock_x86_hole_size() Tejun Heo
@ 2011-07-14 21:36   ` " tip-bot for Tejun Heo
  0 siblings, 0 replies; 54+ messages in thread
From: tip-bot for Tejun Heo @ 2011-07-14 21:36 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, benh, yinghai, tj, tglx, hpa

Commit-ID:  474b881bf4ee86aba55d46a4fdf293de32cba91b
Gitweb:     http://git.kernel.org/tip/474b881bf4ee86aba55d46a4fdf293de32cba91b
Author:     Tejun Heo <tj@kernel.org>
AuthorDate: Tue, 12 Jul 2011 11:16:04 +0200
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Thu, 14 Jul 2011 11:47:51 -0700

x86: Use absent_pages_in_range() instead of memblock_x86_hole_size()

memblock_x86_hole_size() calculates the total size of holes in a given
range according to memblock and is used by numa emulation code and
numa_meminfo_cover_memory().

Since conversion to MEMBLOCK_NODE_MAP, absent_pages_in_range() also
uses memblock and gives the same result.  This patch replaces
memblock_x86_hole_size() uses with absent_pages_in_range().  After the
conversion the x86 function doesn't have any user left and is killed.

Signed-off-by: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/1310462166-31469-12-git-send-email-tj@kernel.org
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/include/asm/memblock.h |    2 -
 arch/x86/mm/memblock.c          |   52 ---------------------------------------
 arch/x86/mm/numa.c              |    4 +-
 arch/x86/mm/numa_emulation.c    |   30 +++++++++++++---------
 4 files changed, 20 insertions(+), 68 deletions(-)

diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h
index a0cc7d6..17a882e 100644
--- a/arch/x86/include/asm/memblock.h
+++ b/arch/x86/include/asm/memblock.h
@@ -6,6 +6,4 @@
 void memblock_x86_reserve_range(u64 start, u64 end, char *name);
 void memblock_x86_free_range(u64 start, u64 end);
 
-u64 memblock_x86_hole_size(u64 start, u64 end);
-
 #endif
diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c
index a9d0972..7325c5d 100644
--- a/arch/x86/mm/memblock.c
+++ b/arch/x86/mm/memblock.c
@@ -32,55 +32,3 @@ void __init memblock_x86_free_range(u64 start, u64 end)
 
 	memblock_free(start, end - start);
 }
-
-/*
- * Finds an active region in the address range from start_pfn to last_pfn and
- * returns its range in ei_startpfn and ei_endpfn for the memblock entry.
- */
-static int __init memblock_x86_find_active_region(const struct memblock_region *ei,
-				  unsigned long start_pfn,
-				  unsigned long last_pfn,
-				  unsigned long *ei_startpfn,
-				  unsigned long *ei_endpfn)
-{
-	u64 align = PAGE_SIZE;
-
-	*ei_startpfn = round_up(ei->base, align) >> PAGE_SHIFT;
-	*ei_endpfn = round_down(ei->base + ei->size, align) >> PAGE_SHIFT;
-
-	/* Skip map entries smaller than a page */
-	if (*ei_startpfn >= *ei_endpfn)
-		return 0;
-
-	/* Skip if map is outside the node */
-	if (*ei_endpfn <= start_pfn || *ei_startpfn >= last_pfn)
-		return 0;
-
-	/* Check for overlaps */
-	if (*ei_startpfn < start_pfn)
-		*ei_startpfn = start_pfn;
-	if (*ei_endpfn > last_pfn)
-		*ei_endpfn = last_pfn;
-
-	return 1;
-}
-
-/*
- * Find the hole size (in bytes) in the memory range.
- * @start: starting address of the memory range to scan
- * @end: ending address of the memory range to scan
- */
-u64 __init memblock_x86_hole_size(u64 start, u64 end)
-{
-	unsigned long start_pfn = start >> PAGE_SHIFT;
-	unsigned long last_pfn = end >> PAGE_SHIFT;
-	unsigned long ei_startpfn, ei_endpfn, ram = 0;
-	struct memblock_region *r;
-
-	for_each_memblock(memory, r)
-		if (memblock_x86_find_active_region(r, start_pfn, last_pfn,
-					   &ei_startpfn, &ei_endpfn))
-			ram += ei_endpfn - ei_startpfn;
-
-	return end - start - ((u64)ram << PAGE_SHIFT);
-}
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index f4a40bd..88e5627 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -475,8 +475,8 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
 			numaram = 0;
 	}
 
-	e820ram = max_pfn - (memblock_x86_hole_size(0,
-					PFN_PHYS(max_pfn)) >> PAGE_SHIFT);
+	e820ram = max_pfn - absent_pages_in_range(0, max_pfn);
+
 	/* We seem to lose 3 pages somewhere. Allow 1M of slack. */
 	if ((s64)(e820ram - numaram) >= (1 << (20 - PAGE_SHIFT))) {
 		printk(KERN_ERR "NUMA: nodes only cover %LuMB of your %LuMB e820 RAM. Not used.\n",
diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c
index e3d471c..971fe70 100644
--- a/arch/x86/mm/numa_emulation.c
+++ b/arch/x86/mm/numa_emulation.c
@@ -28,6 +28,16 @@ static int __init emu_find_memblk_by_nid(int nid, const struct numa_meminfo *mi)
 	return -ENOENT;
 }
 
+static u64 mem_hole_size(u64 start, u64 end)
+{
+	unsigned long start_pfn = PFN_UP(start);
+	unsigned long end_pfn = PFN_DOWN(end);
+
+	if (start_pfn < end_pfn)
+		return PFN_PHYS(absent_pages_in_range(start_pfn, end_pfn));
+	return 0;
+}
+
 /*
  * Sets up nid to range from @start to @end.  The return value is -errno if
  * something went wrong, 0 otherwise.
@@ -89,7 +99,7 @@ static int __init split_nodes_interleave(struct numa_meminfo *ei,
 	 * Calculate target node size.  x86_32 freaks on __udivdi3() so do
 	 * the division in ulong number of pages and convert back.
 	 */
-	size = max_addr - addr - memblock_x86_hole_size(addr, max_addr);
+	size = max_addr - addr - mem_hole_size(addr, max_addr);
 	size = PFN_PHYS((unsigned long)(size >> PAGE_SHIFT) / nr_nodes);
 
 	/*
@@ -135,8 +145,7 @@ static int __init split_nodes_interleave(struct numa_meminfo *ei,
 			 * Continue to add memory to this fake node if its
 			 * non-reserved memory is less than the per-node size.
 			 */
-			while (end - start -
-			       memblock_x86_hole_size(start, end) < size) {
+			while (end - start - mem_hole_size(start, end) < size) {
 				end += FAKE_NODE_MIN_SIZE;
 				if (end > limit) {
 					end = limit;
@@ -150,7 +159,7 @@ static int __init split_nodes_interleave(struct numa_meminfo *ei,
 			 * this one must extend to the boundary.
 			 */
 			if (end < dma32_end && dma32_end - end -
-			    memblock_x86_hole_size(end, dma32_end) < FAKE_NODE_MIN_SIZE)
+			    mem_hole_size(end, dma32_end) < FAKE_NODE_MIN_SIZE)
 				end = dma32_end;
 
 			/*
@@ -158,8 +167,7 @@ static int __init split_nodes_interleave(struct numa_meminfo *ei,
 			 * next node, this one must extend to the end of the
 			 * physical node.
 			 */
-			if (limit - end -
-			    memblock_x86_hole_size(end, limit) < size)
+			if (limit - end - mem_hole_size(end, limit) < size)
 				end = limit;
 
 			ret = emu_setup_memblk(ei, pi, nid++ % nr_nodes,
@@ -180,7 +188,7 @@ static u64 __init find_end_of_node(u64 start, u64 max_addr, u64 size)
 {
 	u64 end = start + size;
 
-	while (end - start - memblock_x86_hole_size(start, end) < size) {
+	while (end - start - mem_hole_size(start, end) < size) {
 		end += FAKE_NODE_MIN_SIZE;
 		if (end > max_addr) {
 			end = max_addr;
@@ -211,8 +219,7 @@ static int __init split_nodes_size_interleave(struct numa_meminfo *ei,
 	 * creates a uniform distribution of node sizes across the entire
 	 * machine (but not necessarily over physical nodes).
 	 */
-	min_size = (max_addr - addr - memblock_x86_hole_size(addr, max_addr)) /
-						MAX_NUMNODES;
+	min_size = (max_addr - addr - mem_hole_size(addr, max_addr)) / MAX_NUMNODES;
 	min_size = max(min_size, FAKE_NODE_MIN_SIZE);
 	if ((min_size & FAKE_NODE_MIN_HASH_MASK) < min_size)
 		min_size = (min_size + FAKE_NODE_MIN_SIZE) &
@@ -252,7 +259,7 @@ static int __init split_nodes_size_interleave(struct numa_meminfo *ei,
 			 * this one must extend to the boundary.
 			 */
 			if (end < dma32_end && dma32_end - end -
-			    memblock_x86_hole_size(end, dma32_end) < FAKE_NODE_MIN_SIZE)
+			    mem_hole_size(end, dma32_end) < FAKE_NODE_MIN_SIZE)
 				end = dma32_end;
 
 			/*
@@ -260,8 +267,7 @@ static int __init split_nodes_size_interleave(struct numa_meminfo *ei,
 			 * next node, this one must extend to the end of the
 			 * physical node.
 			 */
-			if (limit - end -
-			    memblock_x86_hole_size(end, limit) < size)
+			if (limit - end - mem_hole_size(end, limit) < size)
 				end = limit;
 
 			ret = emu_setup_memblk(ei, pi, nid++ % MAX_NUMNODES,

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [tip:x86/memblock] memblock, x86: Make ARCH_DISCARD_MEMBLOCK a config option
  2011-07-14  9:46   ` [PATCH UPDATED " Tejun Heo
@ 2011-07-14 21:37     ` " tip-bot for Tejun Heo
  0 siblings, 0 replies; 54+ messages in thread
From: tip-bot for Tejun Heo @ 2011-07-14 21:37 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, benh, yinghai, tj, tglx, hpa

Commit-ID:  c378ddd53f9b8832a46fd4fec050a97fc2269858
Gitweb:     http://git.kernel.org/tip/c378ddd53f9b8832a46fd4fec050a97fc2269858
Author:     Tejun Heo <tj@kernel.org>
AuthorDate: Thu, 14 Jul 2011 11:46:03 +0200
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Thu, 14 Jul 2011 11:47:52 -0700

memblock, x86: Make ARCH_DISCARD_MEMBLOCK a config option

>From 6839454ae63f1eb21e515c10229ca95c22955fec Mon Sep 17 00:00:00 2001
From: Tejun Heo <tj@kernel.org>
Date: Thu, 14 Jul 2011 11:22:17 +0200

Make ARCH_DISCARD_MEMBLOCK a config option so that it can be handled
together with other MEMBLOCK options.

Signed-off-by: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/20110714094603.GH3455@htj.dyndns.org
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/Kconfig                |    1 +
 arch/x86/include/asm/memblock.h |    2 --
 include/linux/memblock.h        |    2 +-
 mm/Kconfig                      |    3 +++
 mm/memblock.c                   |    2 +-
 5 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 97f0894..28116d4 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -26,6 +26,7 @@ config X86
 	select HAVE_KPROBES
 	select HAVE_MEMBLOCK
 	select HAVE_MEMBLOCK_NODE_MAP
+	select ARCH_DISCARD_MEMBLOCK
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	select ARCH_WANT_FRAME_POINTERS
 	select HAVE_DMA_ATTRS
diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h
index 17a882e..bc56670 100644
--- a/arch/x86/include/asm/memblock.h
+++ b/arch/x86/include/asm/memblock.h
@@ -1,8 +1,6 @@
 #ifndef _X86_MEMBLOCK_H
 #define _X86_MEMBLOCK_H
 
-#define ARCH_DISCARD_MEMBLOCK
-
 void memblock_x86_reserve_range(u64 start, u64 end, char *name);
 void memblock_x86_free_range(u64 start, u64 end);
 
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 31def58..2491355 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -197,7 +197,7 @@ static inline unsigned long memblock_region_reserved_end_pfn(const struct memblo
 	     region++)
 
 
-#ifdef ARCH_DISCARD_MEMBLOCK
+#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
 #define __init_memblock __meminit
 #define __initdata_memblock __meminitdata
 #else
diff --git a/mm/Kconfig b/mm/Kconfig
index 30a5d47..7c56971 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -134,6 +134,9 @@ config HAVE_MEMBLOCK
 config HAVE_MEMBLOCK_NODE_MAP
 	boolean
 
+config ARCH_DISCARD_MEMBLOCK
+	boolean
+
 # eventually, we can have this option just 'select SPARSEMEM'
 config MEMORY_HOTPLUG
 	bool "Allow for memory hot-add"
diff --git a/mm/memblock.c b/mm/memblock.c
index c4a8750..ebc6119 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -959,7 +959,7 @@ static int __init early_memblock(char *p)
 }
 early_param("memblock", early_memblock);
 
-#if defined(CONFIG_DEBUG_FS) && !defined(ARCH_DISCARD_MEMBLOCK)
+#if defined(CONFIG_DEBUG_FS) && !defined(CONFIG_ARCH_DISCARD_MEMBLOCK)
 
 static int memblock_debug_show(struct seq_file *m, void *private)
 {

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [tip:x86/memblock] memblock, x86: Replace memblock_x86_reserve/free_range() with generic ones
  2011-07-12  9:16 ` [PATCH 13/13] memblock, x86: Replace memblock_x86_reserve/free_range() with generic ones Tejun Heo
  2011-07-14 20:10   ` H. Peter Anvin
@ 2011-07-14 21:37   ` tip-bot for Tejun Heo
  2011-07-26 21:06   ` [PATCH 13/13] " Yinghai Lu
  2 siblings, 0 replies; 54+ messages in thread
From: tip-bot for Tejun Heo @ 2011-07-14 21:37 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, benh, yinghai, tj, tglx, hpa

Commit-ID:  24aa07882b672fff2da2f5c955759f0bd13d32d5
Gitweb:     http://git.kernel.org/tip/24aa07882b672fff2da2f5c955759f0bd13d32d5
Author:     Tejun Heo <tj@kernel.org>
AuthorDate: Tue, 12 Jul 2011 11:16:06 +0200
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Thu, 14 Jul 2011 11:47:53 -0700

memblock, x86: Replace memblock_x86_reserve/free_range() with generic ones

Other than sanity check and debug message, the x86 specific version of
memblock reserve/free functions are simple wrappers around the generic
versions - memblock_reserve/free().

This patch adds debug messages with caller identification to the
generic versions and replaces x86 specific ones and kills them.
arch/x86/include/asm/memblock.h and arch/x86/mm/memblock.c are empty
after this change and removed.

Signed-off-by: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/1310462166-31469-14-git-send-email-tj@kernel.org
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 arch/x86/include/asm/memblock.h |    7 -------
 arch/x86/kernel/aperture_64.c   |    2 +-
 arch/x86/kernel/check.c         |    2 +-
 arch/x86/kernel/head.c          |    2 +-
 arch/x86/kernel/head32.c        |    5 +++--
 arch/x86/kernel/head64.c        |    5 +++--
 arch/x86/kernel/mpparse.c       |    6 ++----
 arch/x86/kernel/setup.c         |   17 ++++++++---------
 arch/x86/kernel/trampoline.c    |    2 +-
 arch/x86/mm/Makefile            |    2 --
 arch/x86/mm/init.c              |    6 +++---
 arch/x86/mm/memblock.c          |   34 ----------------------------------
 arch/x86/mm/memtest.c           |    2 +-
 arch/x86/mm/numa.c              |    5 ++---
 arch/x86/mm/numa_32.c           |    6 +++---
 arch/x86/mm/numa_emulation.c    |    4 ++--
 arch/x86/platform/efi/efi.c     |    6 ++----
 arch/x86/xen/mmu.c              |   12 ++++--------
 arch/x86/xen/setup.c            |    7 +++----
 include/linux/memblock.h        |    2 --
 mm/memblock.c                   |    5 +++++
 mm/nobootmem.c                  |    6 +++---
 22 files changed, 48 insertions(+), 97 deletions(-)

diff --git a/arch/x86/include/asm/memblock.h b/arch/x86/include/asm/memblock.h
deleted file mode 100644
index bc56670..0000000
--- a/arch/x86/include/asm/memblock.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef _X86_MEMBLOCK_H
-#define _X86_MEMBLOCK_H
-
-void memblock_x86_reserve_range(u64 start, u64 end, char *name);
-void memblock_x86_free_range(u64 start, u64 end);
-
-#endif
diff --git a/arch/x86/kernel/aperture_64.c b/arch/x86/kernel/aperture_64.c
index 5636308..6e76c19 100644
--- a/arch/x86/kernel/aperture_64.c
+++ b/arch/x86/kernel/aperture_64.c
@@ -94,7 +94,7 @@ static u32 __init allocate_aperture(void)
 				addr, aper_size>>10);
 		return 0;
 	}
-	memblock_x86_reserve_range(addr, addr + aper_size, "aperture64");
+	memblock_reserve(addr, aper_size);
 	/*
 	 * Kmemleak should not scan this block as it may not be mapped via the
 	 * kernel direct mapping.
diff --git a/arch/x86/kernel/check.c b/arch/x86/kernel/check.c
index 621cd23..5da1269 100644
--- a/arch/x86/kernel/check.c
+++ b/arch/x86/kernel/check.c
@@ -91,7 +91,7 @@ void __init setup_bios_corruption_check(void)
 		if (start >= end)
 			continue;
 
-		memblock_x86_reserve_range(start, end, "SCAN RAM");
+		memblock_reserve(start, end - start);
 		scan_areas[num_scan_areas].addr = start;
 		scan_areas[num_scan_areas].size = end - start;
 
diff --git a/arch/x86/kernel/head.c b/arch/x86/kernel/head.c
index af0699b..48d9d4e 100644
--- a/arch/x86/kernel/head.c
+++ b/arch/x86/kernel/head.c
@@ -52,5 +52,5 @@ void __init reserve_ebda_region(void)
 		lowmem = 0x9f000;
 
 	/* reserve all memory between lowmem and the 1MB mark */
-	memblock_x86_reserve_range(lowmem, 0x100000, "* BIOS reserved");
+	memblock_reserve(lowmem, 0x100000 - lowmem);
 }
diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c
index 3bb0850..be9282b 100644
--- a/arch/x86/kernel/head32.c
+++ b/arch/x86/kernel/head32.c
@@ -33,7 +33,8 @@ void __init i386_start_kernel(void)
 {
 	memblock_init();
 
-	memblock_x86_reserve_range(__pa_symbol(&_text), __pa_symbol(&__bss_stop), "TEXT DATA BSS");
+	memblock_reserve(__pa_symbol(&_text),
+			 __pa_symbol(&__bss_stop) - __pa_symbol(&_text));
 
 #ifdef CONFIG_BLK_DEV_INITRD
 	/* Reserve INITRD */
@@ -42,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_x86_reserve_range(ramdisk_image, ramdisk_end, "RAMDISK");
+		memblock_reserve(ramdisk_image, ramdisk_end - ramdisk_image);
 	}
 #endif
 
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index 5655c22..fd25b11 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -100,7 +100,8 @@ void __init x86_64_start_reservations(char *real_mode_data)
 
 	memblock_init();
 
-	memblock_x86_reserve_range(__pa_symbol(&_text), __pa_symbol(&__bss_stop), "TEXT DATA BSS");
+	memblock_reserve(__pa_symbol(&_text),
+			 __pa_symbol(&__bss_stop) - __pa_symbol(&_text));
 
 #ifdef CONFIG_BLK_DEV_INITRD
 	/* Reserve INITRD */
@@ -109,7 +110,7 @@ void __init x86_64_start_reservations(char *real_mode_data)
 		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_x86_reserve_range(ramdisk_image, ramdisk_end, "RAMDISK");
+		memblock_reserve(ramdisk_image, ramdisk_end - ramdisk_image);
 	}
 #endif
 
diff --git a/arch/x86/kernel/mpparse.c b/arch/x86/kernel/mpparse.c
index 8faeaa0..a6b79c1 100644
--- a/arch/x86/kernel/mpparse.c
+++ b/arch/x86/kernel/mpparse.c
@@ -564,9 +564,7 @@ void __init default_get_smp_config(unsigned int early)
 
 static void __init smp_reserve_memory(struct mpf_intel *mpf)
 {
-	unsigned long size = get_mpc_size(mpf->physptr);
-
-	memblock_x86_reserve_range(mpf->physptr, mpf->physptr+size, "* MP-table mpc");
+	memblock_reserve(mpf->physptr, get_mpc_size(mpf->physptr));
 }
 
 static int __init smp_scan_config(unsigned long base, unsigned long length)
@@ -595,7 +593,7 @@ static int __init smp_scan_config(unsigned long base, unsigned long length)
 			       mpf, (u64)virt_to_phys(mpf));
 
 			mem = virt_to_phys(mpf);
-			memblock_x86_reserve_range(mem, mem + sizeof(*mpf), "* MP-table mpf");
+			memblock_reserve(mem, sizeof(*mpf));
 			if (mpf->physptr)
 				smp_reserve_memory(mpf);
 
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 31ffe20..97d227e 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -306,7 +306,8 @@ static void __init cleanup_highmap(void)
 static void __init reserve_brk(void)
 {
 	if (_brk_end > _brk_start)
-		memblock_x86_reserve_range(__pa(_brk_start), __pa(_brk_end), "BRK");
+		memblock_reserve(__pa(_brk_start),
+				 __pa(_brk_end) - __pa(_brk_start));
 
 	/* Mark brk area as locked down and no longer taking any
 	   new allocations */
@@ -337,7 +338,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_x86_reserve_range(ramdisk_here, ramdisk_here + area_size, "NEW RAMDISK");
+	memblock_reserve(ramdisk_here, area_size);
 	initrd_start = ramdisk_here + PAGE_OFFSET;
 	initrd_end   = initrd_start + ramdisk_size;
 	printk(KERN_INFO "Allocated new RAMDISK: %08llx - %08llx\n",
@@ -393,7 +394,7 @@ static void __init reserve_initrd(void)
 	initrd_start = 0;
 
 	if (ramdisk_size >= (end_of_lowmem>>1)) {
-		memblock_x86_free_range(ramdisk_image, ramdisk_end);
+		memblock_free(ramdisk_image, ramdisk_end - ramdisk_image);
 		printk(KERN_ERR "initrd too large to handle, "
 		       "disabling initrd\n");
 		return;
@@ -416,7 +417,7 @@ static void __init reserve_initrd(void)
 
 	relocate_initrd();
 
-	memblock_x86_free_range(ramdisk_image, ramdisk_end);
+	memblock_free(ramdisk_image, ramdisk_end - ramdisk_image);
 }
 #else
 static void __init reserve_initrd(void)
@@ -490,15 +491,13 @@ static void __init memblock_x86_reserve_range_setup_data(void)
 {
 	struct setup_data *data;
 	u64 pa_data;
-	char buf[32];
 
 	if (boot_params.hdr.version < 0x0209)
 		return;
 	pa_data = boot_params.hdr.setup_data;
 	while (pa_data) {
 		data = early_memremap(pa_data, sizeof(*data));
-		sprintf(buf, "setup data %x", data->type);
-		memblock_x86_reserve_range(pa_data, pa_data+sizeof(*data)+data->len, buf);
+		memblock_reserve(pa_data, sizeof(*data) + data->len);
 		pa_data = data->next;
 		early_iounmap(data, sizeof(*data));
 	}
@@ -568,7 +567,7 @@ static void __init reserve_crashkernel(void)
 			return;
 		}
 	}
-	memblock_x86_reserve_range(crash_base, crash_base + crash_size, "CRASH KERNEL");
+	memblock_reserve(crash_base, crash_size);
 
 	printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
 			"for crashkernel (System RAM: %ldMB)\n",
@@ -626,7 +625,7 @@ static __init void reserve_ibft_region(void)
 	addr = find_ibft_region(&size);
 
 	if (size)
-		memblock_x86_reserve_range(addr, addr + size, "* ibft");
+		memblock_reserve(addr, size);
 }
 
 static unsigned reserve_low = CONFIG_X86_RESERVE_LOW << 10;
diff --git a/arch/x86/kernel/trampoline.c b/arch/x86/kernel/trampoline.c
index a1f13dd..a73b610 100644
--- a/arch/x86/kernel/trampoline.c
+++ b/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_x86_reserve_range(mem, mem + size, "TRAMPOLINE");
+	memblock_reserve(mem, size);
 
 	printk(KERN_DEBUG "Base memory trampoline at [%p] %llx size %zu\n",
 	       x86_trampoline_base, (unsigned long long)mem, size);
diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
index 3d11327..23d8e5f 100644
--- a/arch/x86/mm/Makefile
+++ b/arch/x86/mm/Makefile
@@ -27,6 +27,4 @@ obj-$(CONFIG_AMD_NUMA)		+= amdtopology.o
 obj-$(CONFIG_ACPI_NUMA)		+= srat.o
 obj-$(CONFIG_NUMA_EMU)		+= numa_emulation.o
 
-obj-$(CONFIG_HAVE_MEMBLOCK)		+= memblock.o
-
 obj-$(CONFIG_MEMTEST)		+= memtest.o
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 13cf05a..0b736b9 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -81,7 +81,7 @@ static void __init find_early_table_space(unsigned long end, int use_pse,
 
 void __init native_pagetable_reserve(u64 start, u64 end)
 {
-	memblock_x86_reserve_range(start, end, "PGTABLE");
+	memblock_reserve(start, end - start);
 }
 
 struct map_range {
@@ -280,8 +280,8 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
 	 * pgt_buf_end) and free the other ones (pgt_buf_end - pgt_buf_top)
 	 * so that they can be reused for other purposes.
 	 *
-	 * On native it just means calling memblock_x86_reserve_range, on Xen it
-	 * also means marking RW the pagetable pages that we allocated before
+	 * On native it just means calling memblock_reserve, on Xen it also
+	 * means marking RW the pagetable pages that we allocated before
 	 * but that haven't been used.
 	 *
 	 * In fact on xen we mark RO the whole range pgt_buf_start -
diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c
deleted file mode 100644
index 7325c5d..0000000
--- a/arch/x86/mm/memblock.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/init.h>
-#include <linux/bitops.h>
-#include <linux/memblock.h>
-#include <linux/bootmem.h>
-#include <linux/mm.h>
-#include <linux/range.h>
-
-void __init memblock_x86_reserve_range(u64 start, u64 end, char *name)
-{
-	if (start == end)
-		return;
-
-	if (WARN_ONCE(start > end, "memblock_x86_reserve_range: wrong range [%#llx, %#llx)\n", start, end))
-		return;
-
-	memblock_dbg("    memblock_x86_reserve_range: [%#010llx-%#010llx] %16s\n", start, end - 1, name);
-
-	memblock_reserve(start, end - start);
-}
-
-void __init memblock_x86_free_range(u64 start, u64 end)
-{
-	if (start == end)
-		return;
-
-	if (WARN_ONCE(start > end, "memblock_x86_free_range: wrong range [%#llx, %#llx)\n", start, end))
-		return;
-
-	memblock_dbg("       memblock_x86_free_range: [%#010llx-%#010llx]\n", start, end - 1);
-
-	memblock_free(start, end - start);
-}
diff --git a/arch/x86/mm/memtest.c b/arch/x86/mm/memtest.c
index 46a5ff2..c80b9fb 100644
--- a/arch/x86/mm/memtest.c
+++ b/arch/x86/mm/memtest.c
@@ -34,7 +34,7 @@ static void __init reserve_bad_mem(u64 pattern, u64 start_bad, u64 end_bad)
 	       (unsigned long long) pattern,
 	       (unsigned long long) start_bad,
 	       (unsigned long long) end_bad);
-	memblock_x86_reserve_range(start_bad, end_bad, "BAD RAM");
+	memblock_reserve(start_bad, end_bad - start_bad);
 }
 
 static void __init memtest(u64 pattern, u64 start_phys, u64 size)
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index 88e5627..496f494 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -364,8 +364,7 @@ void __init numa_reset_distance(void)
 
 	/* numa_distance could be 1LU marking allocation failure, test cnt */
 	if (numa_distance_cnt)
-		memblock_x86_free_range(__pa(numa_distance),
-					__pa(numa_distance) + size);
+		memblock_free(__pa(numa_distance), size);
 	numa_distance_cnt = 0;
 	numa_distance = NULL;	/* enable table creation */
 }
@@ -394,7 +393,7 @@ static int __init numa_alloc_distance(void)
 		numa_distance = (void *)1LU;
 		return -ENOMEM;
 	}
-	memblock_x86_reserve_range(phys, phys + size, "NUMA DIST");
+	memblock_reserve(phys, size);
 
 	numa_distance = __va(phys);
 	numa_distance_cnt = cnt;
diff --git a/arch/x86/mm/numa_32.c b/arch/x86/mm/numa_32.c
index 58878b5..534255a 100644
--- a/arch/x86/mm/numa_32.c
+++ b/arch/x86/mm/numa_32.c
@@ -204,7 +204,7 @@ void __init init_alloc_remap(int nid, u64 start, u64 end)
 			   size, nid);
 		return;
 	}
-	memblock_x86_reserve_range(node_pa, node_pa + size, "KVA RAM");
+	memblock_reserve(node_pa, size);
 
 	remap_pa = memblock_find_in_range(min_low_pfn << PAGE_SHIFT,
 					  max_low_pfn << PAGE_SHIFT,
@@ -212,10 +212,10 @@ void __init init_alloc_remap(int nid, u64 start, u64 end)
 	if (!remap_pa) {
 		pr_warning("remap_alloc: failed to allocate %lu bytes remap area for node %d\n",
 			   size, nid);
-		memblock_x86_free_range(node_pa, node_pa + size);
+		memblock_free(node_pa, size);
 		return;
 	}
-	memblock_x86_reserve_range(remap_pa, remap_pa + size, "KVA PG");
+	memblock_reserve(remap_pa, size);
 	remap_va = phys_to_virt(remap_pa);
 
 	/* perform actual remap */
diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c
index 971fe70..46db568 100644
--- a/arch/x86/mm/numa_emulation.c
+++ b/arch/x86/mm/numa_emulation.c
@@ -361,7 +361,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)
 			pr_warning("NUMA: Warning: can't allocate copy of distance table, disabling emulation\n");
 			goto no_emu;
 		}
-		memblock_x86_reserve_range(phys, phys + phys_size, "TMP NUMA DIST");
+		memblock_reserve(phys, phys_size);
 		phys_dist = __va(phys);
 
 		for (i = 0; i < numa_dist_cnt; i++)
@@ -430,7 +430,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)
 
 	/* free the copied physical distance table */
 	if (phys_dist)
-		memblock_x86_free_range(__pa(phys_dist), __pa(phys_dist) + phys_size);
+		memblock_free(__pa(phys_dist), phys_size);
 	return;
 
 no_emu:
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index a4c322c..3b4e86b 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -280,8 +280,7 @@ void __init efi_memblock_x86_reserve_range(void)
 		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_x86_reserve_range(pmap, pmap + memmap.nr_map * memmap.desc_size,
-		      "EFI memmap");
+	memblock_reserve(pmap, memmap.nr_map * memmap.desc_size);
 }
 
 #if EFI_DEBUG
@@ -332,8 +331,7 @@ void __init efi_reserve_boot_services(void)
 					"[0x%010llx-0x%010llx]\n",
 						start, start+size-1);
 		} else
-			memblock_x86_reserve_range(start, start+size,
-							"EFI Boot");
+			memblock_reserve(start, size);
 	}
 }
 
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 0ccccb6..ad54fa1 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -1720,10 +1720,8 @@ pgd_t * __init xen_setup_kernel_pagetable(pgd_t *pgd,
 	__xen_write_cr3(true, __pa(pgd));
 	xen_mc_issue(PARAVIRT_LAZY_CPU);
 
-	memblock_x86_reserve_range(__pa(xen_start_info->pt_base),
-		      __pa(xen_start_info->pt_base +
-			   xen_start_info->nr_pt_frames * PAGE_SIZE),
-		      "XEN PAGETABLES");
+	memblock_reserve(__pa(xen_start_info->pt_base),
+			 xen_start_info->nr_pt_frames * PAGE_SIZE);
 
 	return pgd;
 }
@@ -1799,10 +1797,8 @@ pgd_t * __init xen_setup_kernel_pagetable(pgd_t *pgd,
 			  PFN_DOWN(__pa(initial_page_table)));
 	xen_write_cr3(__pa(initial_page_table));
 
-	memblock_x86_reserve_range(__pa(xen_start_info->pt_base),
-		      __pa(xen_start_info->pt_base +
-			   xen_start_info->nr_pt_frames * PAGE_SIZE),
-		      "XEN PAGETABLES");
+	memblock_reserve(__pa(xen_start_info->pt_base),
+			 xen_start_info->nr_pt_frames * PAGE_SIZE));
 
 	return initial_page_table;
 }
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 60aeeb5..73daaf7 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -63,7 +63,7 @@ static void __init xen_add_extra_mem(unsigned long pages)
 	e820_add_region(extra_start, size, E820_RAM);
 	sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
 
-	memblock_x86_reserve_range(extra_start, extra_start + size, "XEN EXTRA");
+	memblock_reserve(extra_start, size);
 
 	xen_extra_mem_size += size;
 
@@ -287,9 +287,8 @@ char * __init xen_memory_setup(void)
 	 *  - xen_start_info
 	 * See comment above "struct start_info" in <xen/interface/xen.h>
 	 */
-	memblock_x86_reserve_range(__pa(xen_start_info->mfn_list),
-		      __pa(xen_start_info->pt_base),
-			"XEN START INFO");
+	memblock_reserve(__pa(xen_start_info->mfn_list),
+			 xen_start_info->pt_base - xen_start_info->mfn_list);
 
 	sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
 
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 2491355..9074631 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -17,8 +17,6 @@
 #include <linux/init.h>
 #include <linux/mm.h>
 
-#include <asm/memblock.h>
-
 #define INIT_MEMBLOCK_REGIONS	128
 
 struct memblock_region {
diff --git a/mm/memblock.c b/mm/memblock.c
index ebc6119..0cb4da6 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -449,6 +449,9 @@ long __init_memblock memblock_remove(phys_addr_t base, phys_addr_t size)
 
 long __init_memblock memblock_free(phys_addr_t base, phys_addr_t size)
 {
+	memblock_dbg("   memblock_free: [%#016llx-%#016llx] %pF\n",
+		     base, base + size, (void *)_RET_IP_);
+
 	return __memblock_remove(&memblock.reserved, base, size);
 }
 
@@ -456,6 +459,8 @@ long __init_memblock memblock_reserve(phys_addr_t base, phys_addr_t size)
 {
 	struct memblock_type *_rgn = &memblock.reserved;
 
+	memblock_dbg("memblock_reserve: [%#016llx-%#016llx] %pF\n",
+		     base, base + size, (void *)_RET_IP_);
 	BUG_ON(0 == size);
 
 	return memblock_add_region(_rgn, base, size);
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 7075bc0..29d948c 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -47,7 +47,7 @@ static void * __init __alloc_memory_core_early(int nid, u64 size, u64 align,
 
 	ptr = phys_to_virt(addr);
 	memset(ptr, 0, size);
-	memblock_x86_reserve_range(addr, addr + size, "BOOTMEM");
+	memblock_reserve(addr, size);
 	/*
 	 * The min_count is set to 0 so that bootmem allocated blocks
 	 * are never reported as leaks.
@@ -175,7 +175,7 @@ void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,
 			      unsigned long size)
 {
 	kmemleak_free_part(__va(physaddr), size);
-	memblock_x86_free_range(physaddr, physaddr + size);
+	memblock_free(physaddr, size);
 }
 
 /**
@@ -190,7 +190,7 @@ void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,
 void __init free_bootmem(unsigned long addr, unsigned long size)
 {
 	kmemleak_free_part(__va(addr), size);
-	memblock_x86_free_range(addr, addr + size);
+	memblock_free(addr, size);
 }
 
 static void * __init ___alloc_bootmem_nopanic(unsigned long size,

^ permalink raw reply	[flat|nested] 54+ messages in thread

* [tip:x86/memblock] memblock: Cast phys_addr_t to unsigned long long for printf use
  2011-07-14 20:10   ` H. Peter Anvin
  2011-07-14 20:20     ` Tejun Heo
@ 2011-07-14 21:38     ` tip-bot for H. Peter Anvin
  1 sibling, 0 replies; 54+ messages in thread
From: tip-bot for H. Peter Anvin @ 2011-07-14 21:38 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, tj, tglx, hpa

Commit-ID:  a150439c4a97db379f0ed6faa46fbbb6e7bf3cb2
Gitweb:     http://git.kernel.org/tip/a150439c4a97db379f0ed6faa46fbbb6e7bf3cb2
Author:     H. Peter Anvin <hpa@linux.intel.com>
AuthorDate: Thu, 14 Jul 2011 11:57:10 -0700
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Thu, 14 Jul 2011 11:57:10 -0700

memblock: Cast phys_addr_t to unsigned long long for printf use

phys_addr_t is not necessarily the same thing as unsigned long long.
It is, however, easier to cast it to unsigned long long for printf
purposes than it is to deal with differnent printf formats.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/4E1F4D2C.3000507@zytor.com
---
 mm/memblock.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/mm/memblock.c b/mm/memblock.c
index 0cb4da6..a75723d 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -450,7 +450,9 @@ long __init_memblock memblock_remove(phys_addr_t base, phys_addr_t size)
 long __init_memblock memblock_free(phys_addr_t base, phys_addr_t size)
 {
 	memblock_dbg("   memblock_free: [%#016llx-%#016llx] %pF\n",
-		     base, base + size, (void *)_RET_IP_);
+		     (unsigned long long)base,
+		     (unsigned long long)base + size,
+		     (void *)_RET_IP_);
 
 	return __memblock_remove(&memblock.reserved, base, size);
 }
@@ -460,7 +462,9 @@ long __init_memblock memblock_reserve(phys_addr_t base, phys_addr_t size)
 	struct memblock_type *_rgn = &memblock.reserved;
 
 	memblock_dbg("memblock_reserve: [%#016llx-%#016llx] %pF\n",
-		     base, base + size, (void *)_RET_IP_);
+		     (unsigned long long)base,
+		     (unsigned long long)base + size,
+		     (void *)_RET_IP_);
 	BUG_ON(0 == size);
 
 	return memblock_add_region(_rgn, base, size);

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH 2.5/13] memblock: Use __meminit[data] instead of __init[data]
  2011-07-14 21:00   ` Yinghai Lu
  2011-07-14 21:24     ` H. Peter Anvin
@ 2011-07-15  5:45     ` Tejun Heo
  1 sibling, 0 replies; 54+ messages in thread
From: Tejun Heo @ 2011-07-15  5:45 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: mingo, hpa, tglx, benh, davem, linux-kernel, linux-arch, x86

Hello,

On Thu, Jul 14, 2011 at 02:00:51PM -0700, Yinghai Lu wrote:
> >  #ifdef ARCH_DISCARD_MEMBLOCK
> > -#define __init_memblock __init
> > -#define __initdata_memblock __initdata
> > +#define __init_memblock __meminit
> > +#define __initdata_memblock __meminitdata
> >  #else
> >  #define __init_memblock
> >  #define __initdata_memblock
> 
> that is not good. It will keep memblock.reserved related data and
> functions after boot.
> and those data/func are not used after slab is ready.

Yeah, if MEMORY_HOTPLUG is enabled.  It isn't too big area to begin
with and early_node_map[] and related code removal should offset it.
The problem is that refining different __init tags here is a bit
complex thanks to DISCARD_MEMBLOCK.  We end up having to deal with the
combination of DISCARD_MEMBLOCK and MEMORY_HOTPLUG.  I was hoping that
once we get memblock usage more consistent across different archs, we
could do away with DISCARD_MEMBLOCK.

Thank you.

-- 
tejun

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH 13/13] memblock, x86: Replace memblock_x86_reserve/free_range() with generic ones
  2011-07-12  9:16 ` [PATCH 13/13] memblock, x86: Replace memblock_x86_reserve/free_range() with generic ones Tejun Heo
  2011-07-14 20:10   ` H. Peter Anvin
  2011-07-14 21:37   ` [tip:x86/memblock] memblock, x86: Replace memblock_x86_reserve/free_range() with generic ones tip-bot for Tejun Heo
@ 2011-07-26 21:06   ` " Yinghai Lu
  2011-07-26 21:46     ` Tejun Heo
  2 siblings, 1 reply; 54+ messages in thread
From: Yinghai Lu @ 2011-07-26 21:06 UTC (permalink / raw)
  To: Tejun Heo; +Cc: mingo, hpa, tglx, benh, davem, linux-kernel, linux-arch, x86

On Tue, Jul 12, 2011 at 2:16 AM, Tejun Heo <tj@kernel.org> wrote:
> Other than sanity check and debug message, the x86 specific version of
> memblock reserve/free functions are simple wrappers around the generic
> versions - memblock_reserve/free().
>
> This patch adds debug messages with caller identification to the
> generic versions and replaces x86 specific ones and kills them.
> arch/x86/include/asm/memblock.h and arch/x86/mm/memblock.c are empty
> after this change and removed.
>
...
> diff --git a/arch/x86/kernel/aperture_64.c b/arch/x86/kernel/aperture_64.c
> index 5636308..6e76c19 100644
> --- a/arch/x86/kernel/aperture_64.c
> +++ b/arch/x86/kernel/aperture_64.c
> @@ -94,7 +94,7 @@ static u32 __init allocate_aperture(void)
>                                addr, aper_size>>10);
>                return 0;
>        }
> -       memblock_x86_reserve_range(addr, addr + aper_size, "aperture64");
> +       memblock_reserve(addr, aper_size);

Wonder if we have a new function like

__memblock_reserve(addr, size, name)

in mm/memblock.c

so could keep string for debug purpose instead of using _RET_IP_.

with that, we can figure out what is in exact reserved position with boot log.

Thanks

Yinghai

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH 13/13] memblock, x86: Replace memblock_x86_reserve/free_range() with generic ones
  2011-07-26 21:06   ` [PATCH 13/13] " Yinghai Lu
@ 2011-07-26 21:46     ` Tejun Heo
  2011-07-27  0:59       ` Yinghai Lu
  0 siblings, 1 reply; 54+ messages in thread
From: Tejun Heo @ 2011-07-26 21:46 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: mingo, hpa, tglx, benh, davem, linux-kernel, linux-arch, x86

Hello, Yinghai.

On Tue, Jul 26, 2011 at 11:06 PM, Yinghai Lu <yhlu.kernel@gmail.com> wrote:
> Wonder if we have a new function like
>
> __memblock_reserve(addr, size, name)
>
> in mm/memblock.c
>
> so could keep string for debug purpose instead of using _RET_IP_.
>
> with that, we can figure out what is in exact reserved position with boot log.

If you look at the current users, the caller function name is unique
except for one or two cases, so we can already tell who's doing what
even without consulting the exact IP.  I can't see much point in
providing debug strings explicitly.  The only benefit would be that it
would be prettier but these are purely debug messages.  One thing
which might make sense is preserving _RET_IP_ of callers of alloc
functions so that reserve can show who's allocating instead of
printing the alloc function each time.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH 13/13] memblock, x86: Replace memblock_x86_reserve/free_range() with generic ones
  2011-07-26 21:46     ` Tejun Heo
@ 2011-07-27  0:59       ` Yinghai Lu
  2011-07-27  8:07         ` Tejun Heo
  0 siblings, 1 reply; 54+ messages in thread
From: Yinghai Lu @ 2011-07-27  0:59 UTC (permalink / raw)
  To: Tejun Heo; +Cc: mingo, hpa, tglx, benh, davem, linux-kernel, linux-arch, x86

On Tue, Jul 26, 2011 at 2:46 PM, Tejun Heo <tj@kernel.org> wrote:
> Hello, Yinghai.
>
> On Tue, Jul 26, 2011 at 11:06 PM, Yinghai Lu <yhlu.kernel@gmail.com> wrote:
>> Wonder if we have a new function like
>>
>> __memblock_reserve(addr, size, name)
>>
>> in mm/memblock.c
>>
>> so could keep string for debug purpose instead of using _RET_IP_.
>>
>> with that, we can figure out what is in exact reserved position with boot log.
>
> If you look at the current users, the caller function name is unique
> except for one or two cases, so we can already tell who's doing what
> even without consulting the exact IP.  I can't see much point in
> providing debug strings explicitly.  The only benefit would be that it
> would be prettier but these are purely debug messages.  One thing
> which might make sense is preserving _RET_IP_ of callers of alloc
> functions so that reserve can show who's allocating instead of
> printing the alloc function each time.

yes, with bootmem wrap stage, the print out are all the same.

will have
__alloc_memory_core_early+0x63
everywhere.

add name print out for comparing, name could give some hint.

early console in decompress_kernel
decompress_kernel:
  input: [0x268a269-0x2e110ac], output: 0x1000000, heap: [0x2e16080-0x2e1e07f]..

Decompressing Linux... xz... Parsing ELF... done
Booting the kernel
[    0.000000] bootconsole [uart0] enabled
[    0.000000] Kernel Layout:
[    0.000000]   .text: [0x01000000-0x01c40639]
[    0.000000] .rodata: [0x01c46000-0x023e7fff]
[    0.000000]   .data: [0x023e8000-0x02521b7f]
[    0.000000]   .init: [0x02524000-0x027f3fff]
[    0.000000]    .bss: [0x027fe000-0x033affff]
[    0.000000]    .brk: [0x033b0000-0x033cffff]
[    0.000000] memblock_reserve: [0x01000000-0x033affff]
x86_64_start_reservations+0x67/0xaf TEXT DATA BSS
[    0.000000] memblock_reserve: [0x7baf3000-0x7f72ffff]
x86_64_start_reservations+0xa0/0xaf RAMDISK
[    0.000000] memblock_reserve: [0x00095400-0x000fffff]
reserve_ebda_region+0x62/0x64 * BIOS reserved
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Linux version 3.0.0-tip-yh-06478-g4d387ec-dirty
(yhlu@linux-siqj.site) (gcc version 4.5.0 20100604 [gcc-4_5-branch
revision 160292] (SUSE Linux) ) #1155 SMP Tue Jul 26 17:28:15 PDT 2011
[    0.000000] Command line: console=uart8250,io,0x3f8,115200n8
initrd=kernel.org/x.gz rw root=/dev/ram0 debug ignore_loglevel
unknown_nmi_panic initcall_debug apic=debug pci=routeirq ip=dhcp
load_ramdisk=1 BOOT_IMAGE=kernel.org/bzImage_3.0_k8.2
[    0.000000] KERNEL supported cpus:
[    0.000000]   Intel GenuineIntel
[    0.000000]   AMD AuthenticAMD
[    0.000000]   Centaur CentaurHauls
[    0.000000] BIOS-provided physical RAM map:
[    0.000000]  BIOS-e820: [0x00000000000000-0x000000000957ff] (usable)
[    0.000000]  BIOS-e820: [0x00000000095800-0x0000000009ffff] (reserved)
[    0.000000]  BIOS-e820: [0x000000000e0000-0x000000000fffff] (reserved)
[    0.000000]  BIOS-e820: [0x00000000100000-0x0000007f74ffff] (usable)
[    0.000000]  BIOS-e820: [0x0000007f75e000-0x0000007f75ffff] type 9
[    0.000000]  BIOS-e820: [0x0000007f760000-0x0000007f76dfff] (ACPI data)
[    0.000000]  BIOS-e820: [0x0000007f76e000-0x0000007f7cffff] (ACPI NVS)
[    0.000000]  BIOS-e820: [0x0000007f7d0000-0x0000007f7dffff] (reserved)
[    0.000000]  BIOS-e820: [0x0000007f7ec000-0x0000008fffffff] (reserved)
[    0.000000]  BIOS-e820: [0x000000fee00000-0x000000fee00fff] (reserved)
[    0.000000]  BIOS-e820: [0x000000ffc00000-0x000000ffffffff] (reserved)
[    0.000000]  BIOS-e820: [0x00000100000000-0x0000807fffffff] (usable)
[    0.000000] debug: ignoring loglevel setting.
[    0.000000] NX (Execute Disable) protection: active
[    0.000000] e820 update range: [0x00000000095000-0x000000000957ff]
(usable) ==> (reserved)
[    0.000000] aligned physical RAM map:
[    0.000000]  aligned: [0x00000000000000-0x00000000094fff] (usable)
[    0.000000]  aligned: [0x00000000095000-0x0000000009ffff] (reserved)
[    0.000000]  aligned: [0x000000000e0000-0x000000000fffff] (reserved)
[    0.000000]  aligned: [0x00000000100000-0x0000007f74ffff] (usable)
[    0.000000]  aligned: [0x0000007f75e000-0x0000007f75ffff] type 9
[    0.000000]  aligned: [0x0000007f760000-0x0000007f76dfff] (ACPI data)
[    0.000000]  aligned: [0x0000007f76e000-0x0000007f7cffff] (ACPI NVS)
[    0.000000]  aligned: [0x0000007f7d0000-0x0000007f7dffff] (reserved)
[    0.000000]  aligned: [0x0000007f7ec000-0x0000008fffffff] (reserved)
[    0.000000]  aligned: [0x000000fee00000-0x000000fee00fff] (reserved)
[    0.000000]  aligned: [0x000000ffc00000-0x000000ffffffff] (reserved)
[    0.000000]  aligned: [0x00000100000000-0x0000807fffffff] (usable)
[    0.000000] DMI present.
[    0.000000] DMI: Oracle Corporation  Sun Fire X4800/     , BIOS
11016600    05/17/2011
[    0.000000] e820 update range: [0x00000000000000-0x0000000000ffff]
(usable) ==> (reserved)
[    0.000000] e820 remove range: [0x000000000a0000-0x000000000fffff] (usable)
[    0.000000] No AGP bridge found
[    0.000000] last_pfn = 0x8080000 max_arch_pfn = 0x400000000
[    0.000000] e820 update range: [0x0000007f800000-0x000000ffffffff]
(usable) ==> (reserved)
[    0.000000] last_pfn = 0x7f750 max_arch_pfn = 0x400000000
[    0.000000] Scan SMP from ffff880000000000 for 1024 bytes.
[    0.000000] Scan SMP from ffff88000009fc00 for 1024 bytes.
[    0.000000] Scan SMP from ffff8800000f0000 for 65536 bytes.
[    0.000000] found SMP MP-table at [ffff8800000ff780] ff780
[    0.000000] memblock_reserve: [0x000ff780-0x000ff78f]
smp_scan_config+0xbf/0xfa * MP-table mpf
[    0.000000]   mpc: e77f0-e85a4
[    0.000000] memblock_reserve: [0x000e77f0-0x000e85a3]
smp_scan_config+0xdf/0xfa * MP-table mpc
[    0.000000] memblock_reserve: [0x033b0000-0x033b08a9]
setup_arch+0x593/0x847 BRK
[    0.000000] MEMBLOCK configuration:
[    0.000000]  memory size = 0x7fff6d5000 reserved size = 0x60584aa
[    0.000000]  memory.cnt  = 0x3
[    0.000000]  memory[0x0]	[0x00010000-0x00094fff], 0x85000 bytes
[    0.000000]  memory[0x1]	[0x00100000-0x7f74ffff], 0x7f650000 bytes
[    0.000000]  memory[0x2]	[0x100000000-0x807fffffff], 0x7f80000000 bytes
[    0.000000]  reserved.cnt  = 0x3
[    0.000000]  reserved[0x0]	[0x00095400-0x000fffff], 0x6ac00 bytes
[    0.000000]  reserved[0x1]	[0x01000000-0x033b08a9], 0x23b08aa bytes
[    0.000000]  reserved[0x2]	[0x7baf3000-0x7f72ffff], 0x3c3d000 bytes
[    0.000000] initial memory mapped : 0 - 20000000
[    0.000000] memblock_reserve: [0x00090000-0x00094fff]
setup_trampolines+0x79/0xae TRAMPOLINE
[    0.000000] Base memory trampoline at [ffff880000090000] 90000 size 20480
[    0.000000] init_memory_mapping: [0x00000000000000-0x0000007f74ffff]
[    0.000000]  0000000000 - 007f600000 page 2M
[    0.000000]  007f600000 - 007f750000 page 4k
[    0.000000] kernel direct mapping tables up to 7f750000 @
[0x7f74e000-0x7f74ffff]
[    0.000000] memblock_reserve: [0x7f74e000-0x7f74ffff]
find_early_table_space.clone.0+0x16a/0x16f PGTABLE
[    0.000000] init_memory_mapping: [0x00000100000000-0x0000807fffffff]
[    0.000000]  0100000000 - 8080000000 page 2M
[    0.000000] kernel direct mapping tables up to 8080000000 @
[0x807fe01000-0x807fffffff]
[    0.000000] memblock_reserve: [0x807fe01000-0x807fffffff]
find_early_table_space.clone.0+0x16a/0x16f PGTABLE
[    0.000000] RAMDISK: 7baf3000 - 7f730000
[    0.000000] ACPI: RSDP 00000000000fab60 00024 (v02 SUN   )
[    0.000000] ACPI: XSDT 000000007f760100 0009C (v01 SUN    X4800
20110517 MSFT 00000097)
[    0.000000] ACPI: FACP 000000007f760290 000F4 (v04 SUN    X4800
20110517 MSFT 00000097)
[    0.000000] ACPI: DSDT 000000007f760a30 0828E (v02 SUN    X4800
00000066 INTL 20051117)
[    0.000000] ACPI: FACS 000000007f76e000 00040
[    0.000000] ACPI: APIC 000000007f760390 00482 (v02 SUN    X4800
20110517 MSFT 00000097)
[    0.000000] ACPI: SPCR 000000007f760820 00050 (v01 SUN    X4800
20110517 MSFT 00000097)
[    0.000000] ACPI: MCFG 000000007f760870 0003C (v01 SUN    X4800
20110517 MSFT 00000097)
[    0.000000] ACPI: SLIT 000000007f76096c 0006C (v01 SUN    X4800
20110517 MSFT 00000097)
[    0.000000] ACPI: SPMI 000000007f7609e0 00041 (v05 SUN    X4800
20110517 MSFT 00000097)
[    0.000000] ACPI: OEMB 000000007f76e040 00139 (v01 SUN    X4800
20110517 MSFT 00000097)
[    0.000000] ACPI: HPET 000000007f76ba30 00038 (v01 SUN    X4800
20110517 MSFT 00000097)
[    0.000000] ACPI: SRAT 000000007f76ba70 009C0 (v02 SUN    X4800
00000001 INTL 00000001)
[    0.000000] ACPI: DMAR 000000007f76e180 002C8 (v01 SUN    X4800
00000001 MSFT 00000097)
[    0.000000] ACPI: SSDT 000000007f7a0e20 0036D (v01 SUN       CpuPm
00000012 INTL 20051117)
[    0.000000] ACPI: EINJ 000000007f76c430 00130 (v01 SUN    X4800
20110517 MSFT 00000097)
[    0.000000] ACPI: BERT 000000007f76c5c0 00030 (v01 SUN    X4800
20110517 MSFT 00000097)
[    0.000000] ACPI: ERST 000000007f76c5f0 00210 (v01 SUN    X4800
20110517 MSFT 00000097)
[    0.000000] ACPI: HEST 000000007f76c800 000A8 (v01 SUN    X4800
20110517 MSFT 00000097)
[    0.000000] ACPI: Local APIC address 0xfee00000
[    0.000000] mapped APIC to ffffffffff5fb000 (        fee00000)
[    0.000000] SRAT: PXM 0 -> APIC 0x00 -> Node 0
[    0.000000] SRAT: PXM 0 -> APIC 0x02 -> Node 0
[    0.000000] SRAT: PXM 0 -> APIC 0x04 -> Node 0
[    0.000000] SRAT: PXM 0 -> APIC 0x06 -> Node 0
[    0.000000] SRAT: PXM 0 -> APIC 0x10 -> Node 0
[    0.000000] SRAT: PXM 0 -> APIC 0x12 -> Node 0
[    0.000000] SRAT: PXM 0 -> APIC 0x14 -> Node 0
[    0.000000] SRAT: PXM 0 -> APIC 0x16 -> Node 0
[    0.000000] SRAT: PXM 1 -> APIC 0x20 -> Node 1
[    0.000000] SRAT: PXM 1 -> APIC 0x22 -> Node 1
[    0.000000] SRAT: PXM 1 -> APIC 0x24 -> Node 1
[    0.000000] SRAT: PXM 1 -> APIC 0x26 -> Node 1
[    0.000000] SRAT: PXM 1 -> APIC 0x30 -> Node 1
[    0.000000] SRAT: PXM 1 -> APIC 0x32 -> Node 1
[    0.000000] SRAT: PXM 1 -> APIC 0x34 -> Node 1
[    0.000000] SRAT: PXM 1 -> APIC 0x36 -> Node 1
[    0.000000] SRAT: PXM 2 -> APIC 0x40 -> Node 2
[    0.000000] SRAT: PXM 2 -> APIC 0x42 -> Node 2
[    0.000000] SRAT: PXM 2 -> APIC 0x44 -> Node 2
[    0.000000] SRAT: PXM 2 -> APIC 0x46 -> Node 2
[    0.000000] SRAT: PXM 2 -> APIC 0x50 -> Node 2
[    0.000000] SRAT: PXM 2 -> APIC 0x52 -> Node 2
[    0.000000] SRAT: PXM 2 -> APIC 0x54 -> Node 2
[    0.000000] SRAT: PXM 2 -> APIC 0x56 -> Node 2
[    0.000000] SRAT: PXM 3 -> APIC 0x60 -> Node 3
[    0.000000] SRAT: PXM 3 -> APIC 0x62 -> Node 3
[    0.000000] SRAT: PXM 3 -> APIC 0x64 -> Node 3
[    0.000000] SRAT: PXM 3 -> APIC 0x66 -> Node 3
[    0.000000] SRAT: PXM 3 -> APIC 0x70 -> Node 3
[    0.000000] SRAT: PXM 3 -> APIC 0x72 -> Node 3
[    0.000000] SRAT: PXM 3 -> APIC 0x74 -> Node 3
[    0.000000] SRAT: PXM 3 -> APIC 0x76 -> Node 3
[    0.000000] SRAT: PXM 4 -> APIC 0x80 -> Node 4
[    0.000000] SRAT: PXM 4 -> APIC 0x82 -> Node 4
[    0.000000] SRAT: PXM 4 -> APIC 0x84 -> Node 4
[    0.000000] SRAT: PXM 4 -> APIC 0x86 -> Node 4
[    0.000000] SRAT: PXM 4 -> APIC 0x90 -> Node 4
[    0.000000] SRAT: PXM 4 -> APIC 0x92 -> Node 4
[    0.000000] SRAT: PXM 4 -> APIC 0x94 -> Node 4
[    0.000000] SRAT: PXM 4 -> APIC 0x96 -> Node 4
[    0.000000] SRAT: PXM 5 -> APIC 0xa0 -> Node 5
[    0.000000] SRAT: PXM 5 -> APIC 0xa2 -> Node 5
[    0.000000] SRAT: PXM 5 -> APIC 0xa4 -> Node 5
[    0.000000] SRAT: PXM 5 -> APIC 0xa6 -> Node 5
[    0.000000] SRAT: PXM 5 -> APIC 0xb0 -> Node 5
[    0.000000] SRAT: PXM 5 -> APIC 0xb2 -> Node 5
[    0.000000] SRAT: PXM 5 -> APIC 0xb4 -> Node 5
[    0.000000] SRAT: PXM 5 -> APIC 0xb6 -> Node 5
[    0.000000] SRAT: PXM 6 -> APIC 0xc0 -> Node 6
[    0.000000] SRAT: PXM 6 -> APIC 0xc2 -> Node 6
[    0.000000] SRAT: PXM 6 -> APIC 0xc4 -> Node 6
[    0.000000] SRAT: PXM 6 -> APIC 0xc6 -> Node 6
[    0.000000] SRAT: PXM 6 -> APIC 0xd0 -> Node 6
[    0.000000] SRAT: PXM 6 -> APIC 0xd2 -> Node 6
[    0.000000] SRAT: PXM 6 -> APIC 0xd4 -> Node 6
[    0.000000] SRAT: PXM 6 -> APIC 0xd6 -> Node 6
[    0.000000] SRAT: PXM 7 -> APIC 0xe0 -> Node 7
[    0.000000] SRAT: PXM 7 -> APIC 0xe2 -> Node 7
[    0.000000] SRAT: PXM 7 -> APIC 0xe4 -> Node 7
[    0.000000] SRAT: PXM 7 -> APIC 0xe6 -> Node 7
[    0.000000] SRAT: PXM 7 -> APIC 0xf0 -> Node 7
[    0.000000] SRAT: PXM 7 -> APIC 0xf2 -> Node 7
[    0.000000] SRAT: PXM 7 -> APIC 0xf4 -> Node 7
[    0.000000] SRAT: PXM 7 -> APIC 0xf6 -> Node 7
[    0.000000] SRAT: PXM 0 -> APIC 0x01 -> Node 0
[    0.000000] SRAT: PXM 0 -> APIC 0x03 -> Node 0
[    0.000000] SRAT: PXM 0 -> APIC 0x05 -> Node 0
[    0.000000] SRAT: PXM 0 -> APIC 0x07 -> Node 0
[    0.000000] SRAT: PXM 0 -> APIC 0x11 -> Node 0
[    0.000000] SRAT: PXM 0 -> APIC 0x13 -> Node 0
[    0.000000] SRAT: PXM 0 -> APIC 0x15 -> Node 0
[    0.000000] SRAT: PXM 0 -> APIC 0x17 -> Node 0
[    0.000000] SRAT: PXM 1 -> APIC 0x21 -> Node 1
[    0.000000] SRAT: PXM 1 -> APIC 0x23 -> Node 1
[    0.000000] SRAT: PXM 1 -> APIC 0x25 -> Node 1
[    0.000000] SRAT: PXM 1 -> APIC 0x27 -> Node 1
[    0.000000] SRAT: PXM 1 -> APIC 0x31 -> Node 1
[    0.000000] SRAT: PXM 1 -> APIC 0x33 -> Node 1
[    0.000000] SRAT: PXM 1 -> APIC 0x35 -> Node 1
[    0.000000] SRAT: PXM 1 -> APIC 0x37 -> Node 1
[    0.000000] SRAT: PXM 2 -> APIC 0x41 -> Node 2
[    0.000000] SRAT: PXM 2 -> APIC 0x43 -> Node 2
[    0.000000] SRAT: PXM 2 -> APIC 0x45 -> Node 2
[    0.000000] SRAT: PXM 2 -> APIC 0x47 -> Node 2
[    0.000000] SRAT: PXM 2 -> APIC 0x51 -> Node 2
[    0.000000] SRAT: PXM 2 -> APIC 0x53 -> Node 2
[    0.000000] SRAT: PXM 2 -> APIC 0x55 -> Node 2
[    0.000000] SRAT: PXM 2 -> APIC 0x57 -> Node 2
[    0.000000] SRAT: PXM 3 -> APIC 0x61 -> Node 3
[    0.000000] SRAT: PXM 3 -> APIC 0x63 -> Node 3
[    0.000000] SRAT: PXM 3 -> APIC 0x65 -> Node 3
[    0.000000] SRAT: PXM 3 -> APIC 0x67 -> Node 3
[    0.000000] SRAT: PXM 3 -> APIC 0x71 -> Node 3
[    0.000000] SRAT: PXM 3 -> APIC 0x73 -> Node 3
[    0.000000] SRAT: PXM 3 -> APIC 0x75 -> Node 3
[    0.000000] SRAT: PXM 3 -> APIC 0x77 -> Node 3
[    0.000000] SRAT: PXM 4 -> APIC 0x81 -> Node 4
[    0.000000] SRAT: PXM 4 -> APIC 0x83 -> Node 4
[    0.000000] SRAT: PXM 4 -> APIC 0x85 -> Node 4
[    0.000000] SRAT: PXM 4 -> APIC 0x87 -> Node 4
[    0.000000] SRAT: PXM 4 -> APIC 0x91 -> Node 4
[    0.000000] SRAT: PXM 4 -> APIC 0x93 -> Node 4
[    0.000000] SRAT: PXM 4 -> APIC 0x95 -> Node 4
[    0.000000] SRAT: PXM 4 -> APIC 0x97 -> Node 4
[    0.000000] SRAT: PXM 5 -> APIC 0xa1 -> Node 5
[    0.000000] SRAT: PXM 5 -> APIC 0xa3 -> Node 5
[    0.000000] SRAT: PXM 5 -> APIC 0xa5 -> Node 5
[    0.000000] SRAT: PXM 5 -> APIC 0xa7 -> Node 5
[    0.000000] SRAT: PXM 5 -> APIC 0xb1 -> Node 5
[    0.000000] SRAT: PXM 5 -> APIC 0xb3 -> Node 5
[    0.000000] SRAT: PXM 5 -> APIC 0xb5 -> Node 5
[    0.000000] SRAT: PXM 5 -> APIC 0xb7 -> Node 5
[    0.000000] SRAT: PXM 6 -> APIC 0xc1 -> Node 6
[    0.000000] SRAT: PXM 6 -> APIC 0xc3 -> Node 6
[    0.000000] SRAT: PXM 6 -> APIC 0xc5 -> Node 6
[    0.000000] SRAT: PXM 6 -> APIC 0xc7 -> Node 6
[    0.000000] SRAT: PXM 6 -> APIC 0xd1 -> Node 6
[    0.000000] SRAT: PXM 6 -> APIC 0xd3 -> Node 6
[    0.000000] SRAT: PXM 6 -> APIC 0xd5 -> Node 6
[    0.000000] SRAT: PXM 6 -> APIC 0xd7 -> Node 6
[    0.000000] SRAT: PXM 7 -> APIC 0xe1 -> Node 7
[    0.000000] SRAT: PXM 7 -> APIC 0xe3 -> Node 7
[    0.000000] SRAT: PXM 7 -> APIC 0xe5 -> Node 7
[    0.000000] SRAT: PXM 7 -> APIC 0xe7 -> Node 7
[    0.000000] SRAT: PXM 7 -> APIC 0xf1 -> Node 7
[    0.000000] SRAT: PXM 7 -> APIC 0xf3 -> Node 7
[    0.000000] SRAT: PXM 7 -> APIC 0xf5 -> Node 7
[    0.000000] SRAT: PXM 7 -> APIC 0xf7 -> Node 7
[    0.000000] SRAT: Node 0 PXM 0 0-a0000
[    0.000000] SRAT: Node 0 PXM 0 100000-80000000
[    0.000000] SRAT: Node 0 PXM 0 100000000-1080000000
[    0.000000] SRAT: Node 1 PXM 1 1080000000-2080000000
[    0.000000] SRAT: Node 2 PXM 2 2080000000-3080000000
[    0.000000] SRAT: Node 3 PXM 3 3080000000-4080000000
[    0.000000] SRAT: Node 4 PXM 4 4080000000-5080000000
[    0.000000] SRAT: Node 5 PXM 5 5080000000-6080000000
[    0.000000] SRAT: Node 6 PXM 6 6080000000-7080000000
[    0.000000] SRAT: Node 7 PXM 7 7080000000-8080000000
[    0.000000] ACPI: SLIT: nodes = 8
[    0.000000]    10 15 20 15 15 20 20 20
[    0.000000]    15 10 15 20 20 15 20 20
[    0.000000]    20 15 10 15 20 20 15 20
[    0.000000]    15 20 15 10 20 20 20 15
[    0.000000]    15 20 20 20 10 15 15 20
[    0.000000]    20 15 20 20 15 10 20 15
[    0.000000]    20 20 15 20 15 20 10 15
[    0.000000]    20 20 20 15 20 15 15 10
[    0.000000] memblock_reserve: [0x807fe00000-0x807fe0003f]
numa_alloc_distance+0xd4/0x13e NODE DIST
[    0.000000] NUMA: Initialized distance table, cnt=8
[    0.000000] NUMA: Node 0 [0,a0000) + [100000,80000000) -> [0,80000000)
[    0.000000] NUMA: Node 0 [0,80000000) + [100000000,1080000000) ->
[0,1080000000)
[    0.000000] Initmem setup node 0 [0000000000000000-000000107fffffff]
[    0.000000] memblock_reserve: [0x107fffb000-0x107fffffff]
memblock_reserve+0x10/0x12
[    0.000000]   NODE_DATA [#000000107fffb000 - 0x0000107fffffff]
[    0.000000] Initmem setup node 1 [0000001080000000-000000207fffffff]
[    0.000000] memblock_reserve: [0x207fffb000-0x207fffffff]
memblock_reserve+0x10/0x12
[    0.000000]   NODE_DATA [#000000207fffb000 - 0x0000207fffffff]
[    0.000000] Initmem setup node 2 [0000002080000000-000000307fffffff]
[    0.000000] memblock_reserve: [0x307fffb000-0x307fffffff]
memblock_reserve+0x10/0x12
[    0.000000]   NODE_DATA [#000000307fffb000 - 0x0000307fffffff]
[    0.000000] Initmem setup node 3 [0000003080000000-000000407fffffff]
[    0.000000] memblock_reserve: [0x407fffb000-0x407fffffff]
memblock_reserve+0x10/0x12
[    0.000000]   NODE_DATA [#000000407fffb000 - 0x0000407fffffff]
[    0.000000] Initmem setup node 4 [0000004080000000-000000507fffffff]
[    0.000000] memblock_reserve: [0x507fffb000-0x507fffffff]
memblock_reserve+0x10/0x12
[    0.000000]   NODE_DATA [#000000507fffb000 - 0x0000507fffffff]
[    0.000000] Initmem setup node 5 [0000005080000000-000000607fffffff]
[    0.000000] memblock_reserve: [0x607fffb000-0x607fffffff]
memblock_reserve+0x10/0x12
[    0.000000]   NODE_DATA [#000000607fffb000 - 0x0000607fffffff]
[    0.000000] Initmem setup node 6 [0000006080000000-000000707fffffff]
[    0.000000] memblock_reserve: [0x707fffb000-0x707fffffff]
memblock_reserve+0x10/0x12
[    0.000000]   NODE_DATA [#000000707fffb000 - 0x0000707fffffff]
[    0.000000] Initmem setup node 7 [0000007080000000-000000807fffffff]
[    0.000000] memblock_reserve: [0x807fdfb000-0x807fdfffff]
memblock_reserve+0x10/0x12
[    0.000000]   NODE_DATA [#000000807fdfb000 - 0x0000807fdfffff]
[    0.000000] MEMBLOCK configuration:
[    0.000000]  memory size = 0x7fff6d5000 reserved size = 0x62864ea
[    0.000000]  memory.cnt  = 0xa
[    0.000000]  memory[0x0]	[0x00010000-0x00094fff], 0x85000 bytes on node 0
[    0.000000]  memory[0x1]	[0x00100000-0x7f74ffff], 0x7f650000 bytes on node 0
[    0.000000]  memory[0x2]	[0x100000000-0x107fffffff], 0xf80000000
bytes on node 0
[    0.000000]  memory[0x3]	[0x1080000000-0x207fffffff], 0x1000000000
bytes on node 1
[    0.000000]  memory[0x4]	[0x2080000000-0x307fffffff], 0x1000000000
bytes on node 2
[    0.000000]  memory[0x5]	[0x3080000000-0x407fffffff], 0x1000000000
bytes on node 3
[    0.000000]  memory[0x6]	[0x4080000000-0x507fffffff], 0x1000000000
bytes on node 4
[    0.000000]  memory[0x7]	[0x5080000000-0x607fffffff], 0x1000000000
bytes on node 5
[    0.000000]  memory[0x8]	[0x6080000000-0x707fffffff], 0x1000000000
bytes on node 6
[    0.000000]  memory[0x9]	[0x7080000000-0x807fffffff], 0x1000000000
bytes on node 7
[    0.000000]  reserved.cnt  = 0xe
[    0.000000]  reserved[0x0]	[0x00090000-0x00094fff], 0x5000 bytes
[    0.000000]  reserved[0x1]	[0x00095400-0x000fffff], 0x6ac00 bytes
[    0.000000]  reserved[0x2]	[0x01000000-0x033b08a9], 0x23b08aa bytes
[    0.000000]  reserved[0x3]	[0x7baf3000-0x7f72ffff], 0x3c3d000 bytes
[    0.000000]  reserved[0x4]	[0x7f74e000-0x7f74ffff], 0x2000 bytes
[    0.000000]  reserved[0x5]	[0x107fffb000-0x107fffffff], 0x5000 bytes
[    0.000000]  reserved[0x6]	[0x207fffb000-0x207fffffff], 0x5000 bytes
[    0.000000]  reserved[0x7]	[0x307fffb000-0x307fffffff], 0x5000 bytes
[    0.000000]  reserved[0x8]	[0x407fffb000-0x407fffffff], 0x5000 bytes
[    0.000000]  reserved[0x9]	[0x507fffb000-0x507fffffff], 0x5000 bytes
[    0.000000]  reserved[0xa]	[0x607fffb000-0x607fffffff], 0x5000 bytes
[    0.000000]  reserved[0xb]	[0x707fffb000-0x707fffffff], 0x5000 bytes
[    0.000000]  reserved[0xc]	[0x807fdfb000-0x807fe0003f], 0x5040 bytes
[    0.000000]  reserved[0xd]	[0x807fe01000-0x807fffffff], 0x1ff000 bytes
[    0.000000] memblock_reserve: [0x107fffa000-0x107fffafff]
__alloc_memory_core_early+0x63/0xad sparse section
[    0.000000] memblock_reserve: [0x107fff9000-0x107fff9fff]
__alloc_memory_core_early+0x63/0xad sparse section
[    0.000000] memblock_reserve: [0x107fff8000-0x107fff8fff]
__alloc_memory_core_early+0x63/0xad sparse section
[    0.000000] memblock_reserve: [0x207fffa000-0x207fffafff]
__alloc_memory_core_early+0x63/0xad sparse section
[    0.000000] memblock_reserve: [0x207fff9000-0x207fff9fff]
__alloc_memory_core_early+0x63/0xad sparse section
[    0.000000] memblock_reserve: [0x307fffa000-0x307fffafff]
__alloc_memory_core_early+0x63/0xad sparse section
[    0.000000] memblock_reserve: [0x307fff9000-0x307fff9fff]
__alloc_memory_core_early+0x63/0xad sparse section
[    0.000000] memblock_reserve: [0x407fffa000-0x407fffafff]
__alloc_memory_core_early+0x63/0xad sparse section
[    0.000000] memblock_reserve: [0x407fff9000-0x407fff9fff]
__alloc_memory_core_early+0x63/0xad sparse section
[    0.000000] memblock_reserve: [0x507fffa000-0x507fffafff]
__alloc_memory_core_early+0x63/0xad sparse section
[    0.000000] memblock_reserve: [0x507fff9000-0x507fff9fff]
__alloc_memory_core_early+0x63/0xad sparse section
[    0.000000] memblock_reserve: [0x607fffa000-0x607fffafff]
__alloc_memory_core_early+0x63/0xad sparse section
[    0.000000] memblock_reserve: [0x607fff9000-0x607fff9fff]
__alloc_memory_core_early+0x63/0xad sparse section
[    0.000000] memblock_reserve: [0x707fffa000-0x707fffafff]
__alloc_memory_core_early+0x63/0xad sparse section
[    0.000000] memblock_reserve: [0x707fff9000-0x707fff9fff]
__alloc_memory_core_early+0x63/0xad sparse section
[    0.000000] memblock_reserve: [0x807fdfa000-0x807fdfafff]
__alloc_memory_core_early+0x63/0xad sparse section
[    0.000000] memblock_reserve: [0x807fdf9000-0x807fdf9fff]
__alloc_memory_core_early+0x63/0xad sparse section
[    0.000000] memblock_reserve: [0x807f9f9000-0x807fdf8fff]
__alloc_memory_core_early+0x63/0xad usemap_map
[    0.000000] memblock_reserve: [0x107fff5000-0x107fff7fff]
__alloc_memory_core_early+0x63/0xad usemap section
[    0.000000] memblock_reserve: [0x207fff6000-0x207fff8fff]
__alloc_memory_core_early+0x63/0xad usemap section
[    0.000000] memblock_reserve: [0x307fff6000-0x307fff8fff]
__alloc_memory_core_early+0x63/0xad usemap section
[    0.000000] memblock_reserve: [0x407fff6000-0x407fff8fff]
__alloc_memory_core_early+0x63/0xad usemap section
[    0.000000] memblock_reserve: [0x507fff6000-0x507fff8fff]
__alloc_memory_core_early+0x63/0xad usemap section
[    0.000000] memblock_reserve: [0x607fff6000-0x607fff8fff]
__alloc_memory_core_early+0x63/0xad usemap section
[    0.000000] memblock_reserve: [0x707fff6000-0x707fff8fff]
__alloc_memory_core_early+0x63/0xad usemap section
[    0.000000] memblock_reserve: [0x807f9f6000-0x807f9f8fff]
__alloc_memory_core_early+0x63/0xad usemap section
[    0.000000] memblock_reserve: [0x807f5f6000-0x807f9f5fff]
__alloc_memory_core_early+0x63/0xad map_map
[    0.000000] memblock_reserve: [0x103fe00000-0x107fdfffff]
__alloc_memory_core_early+0x63/0xad vmemmap buf
[    0.000000] memblock_reserve: [0x107fff4000-0x107fff4fff]
__alloc_memory_core_early+0x63/0xad vmemmap block
[    0.000000]  [ffffea0000000000-ffffea7fffffffff] PGD ->
ffff88107fff4000 on node 0
[    0.000000] memblock_reserve: [0x107fff3000-0x107fff3fff]
__alloc_memory_core_early+0x63/0xad vmemmap block
[    0.000000]  [ffffea0000000000-ffffea003fffffff] PUD ->
ffff88107fff3000 on node 0
[    0.000000]    memblock_free: [0x1077e00000-0x107fdfffff]
[    0.000000] memblock_reserve: [0x203fe00000-0x207fdfffff]
__alloc_memory_core_early+0x63/0xad vmemmap buf
[    0.000000]  [ffffea0000000000-ffffea0039bfffff] PMD ->
[ffff88103fe00000-ffff881077dfffff] on node 0
[    0.000000] memblock_reserve: [0x207fff5000-0x207fff5fff]
__alloc_memory_core_early+0x63/0xad vmemmap block
[    0.000000]  [ffffea0040000000-ffffea007fffffff] PUD ->
ffff88207fff5000 on node 1
[    0.000000]    memblock_free: [0x2077e00000-0x207fdfffff]
[    0.000000] memblock_reserve: [0x303fe00000-0x307fdfffff]
__alloc_memory_core_early+0x63/0xad vmemmap buf
[    0.000000]  [ffffea0039c00000-ffffea0071bfffff] PMD ->
[ffff88203fe00000-ffff882077dfffff] on node 1
[    0.000000] memblock_reserve: [0x307fff5000-0x307fff5fff]
__alloc_memory_core_early+0x63/0xad vmemmap block
[    0.000000]  [ffffea0080000000-ffffea00bfffffff] PUD ->
ffff88307fff5000 on node 2
[    0.000000]    memblock_free: [0x3077e00000-0x307fdfffff]
[    0.000000] memblock_reserve: [0x403fe00000-0x407fdfffff]
__alloc_memory_core_early+0x63/0xad vmemmap buf
[    0.000000]  [ffffea0071c00000-ffffea00a9bfffff] PMD ->
[ffff88303fe00000-ffff883077dfffff] on node 2
[    0.000000] memblock_reserve: [0x407fff5000-0x407fff5fff]
__alloc_memory_core_early+0x63/0xad vmemmap block
[    0.000000]  [ffffea00c0000000-ffffea00ffffffff] PUD ->
ffff88407fff5000 on node 3
[    0.000000]    memblock_free: [0x4077e00000-0x407fdfffff]
[    0.000000] memblock_reserve: [0x503fe00000-0x507fdfffff]
__alloc_memory_core_early+0x63/0xad vmemmap buf
[    0.000000]  [ffffea00a9c00000-ffffea00e1bfffff] PMD ->
[ffff88403fe00000-ffff884077dfffff] on node 3
[    0.000000] memblock_reserve: [0x507fff5000-0x507fff5fff]
__alloc_memory_core_early+0x63/0xad vmemmap block
[    0.000000]  [ffffea0100000000-ffffea013fffffff] PUD ->
ffff88507fff5000 on node 4
[    0.000000]    memblock_free: [0x5077e00000-0x507fdfffff]
[    0.000000] memblock_reserve: [0x603fe00000-0x607fdfffff]
__alloc_memory_core_early+0x63/0xad vmemmap buf
[    0.000000]  [ffffea00e1c00000-ffffea0119bfffff] PMD ->
[ffff88503fe00000-ffff885077dfffff] on node 4
[    0.000000] memblock_reserve: [0x607fff5000-0x607fff5fff]
__alloc_memory_core_early+0x63/0xad vmemmap block
[    0.000000]  [ffffea0140000000-ffffea017fffffff] PUD ->
ffff88607fff5000 on node 5
[    0.000000]    memblock_free: [0x6077e00000-0x607fdfffff]
[    0.000000] memblock_reserve: [0x703fe00000-0x707fdfffff]
__alloc_memory_core_early+0x63/0xad vmemmap buf
[    0.000000]  [ffffea0119c00000-ffffea0151bfffff] PMD ->
[ffff88603fe00000-ffff886077dfffff] on node 5
[    0.000000] memblock_reserve: [0x707fff5000-0x707fff5fff]
__alloc_memory_core_early+0x63/0xad vmemmap block
[    0.000000]  [ffffea0180000000-ffffea01bfffffff] PUD ->
ffff88707fff5000 on node 6
[    0.000000]    memblock_free: [0x7077e00000-0x707fdfffff]
[    0.000000] memblock_reserve: [0x803f400000-0x807f3fffff]
__alloc_memory_core_early+0x63/0xad vmemmap buf
[    0.000000]  [ffffea0151c00000-ffffea0189bfffff] PMD ->
[ffff88703fe00000-ffff887077dfffff] on node 6
[    0.000000] memblock_reserve: [0x807f5f5000-0x807f5f5fff]
__alloc_memory_core_early+0x63/0xad vmemmap block
[    0.000000]  [ffffea01c0000000-ffffea01ffffffff] PUD ->
ffff88807f5f5000 on node 7
[    0.000000]    memblock_free: [0x8077400000-0x807f3fffff]
[    0.000000]  [ffffea0189c00000-ffffea01c1bfffff] PMD ->
[ffff88803f400000-ffff8880773fffff] on node 7
[    0.000000]    memblock_free: [0x807f5f6000-0x807f9f5fff]
[    0.000000]    memblock_free: [0x807f9f9000-0x807fdf8fff]Zone PFN ranges:
[    0.000000]   DMA      0x00000010 -> 0x00001000
[    0.000000]   DMA32    0x00001000 -> 0x00100000
[    0.000000]   Normal   0x00100000 -> 0x08080000
[    0.000000] Movable zone start PFN for each node
[    0.000000] Early memory PFN ranges
[    0.000000]     0: 0x00000010 -> 0x00000095
[    0.000000]     0: 0x00000100 -> 0x0007f750
[    0.000000]     0: 0x00100000 -> 0x01080000
[    0.000000]     1: 0x01080000 -> 0x02080000
[    0.000000]     2: 0x02080000 -> 0x03080000
[    0.000000]     3: 0x03080000 -> 0x04080000
[    0.000000]     4: 0x04080000 -> 0x05080000
[    0.000000]     5: 0x05080000 -> 0x06080000
[    0.000000]     6: 0x06080000 -> 0x07080000
[    0.000000]     7: 0x07080000 -> 0x08080000
[    0.000000] start - node_states[2]:
[    0.000000] On node 0 totalpages: 16774869
[    0.000000]   DMA zone: 56 pages used for memmap
[    0.000000]   DMA zone: 5 pages reserved
[    0.000000]   DMA zone: 3912 pages, LIFO batch:0
[    0.000000] memblock_reserve: [0x107ff9b000-0x107fff2fff]
__alloc_memory_core_early+0x63/0xad pgdat
[    0.000000]   DMA32 zone: 14280 pages used for memmap
[    0.000000]   DMA32 zone: 503688 pages, LIFO batch:31
[    0.000000] memblock_reserve: [0x107ff43000-0x107ff9afff]
__alloc_memory_core_early+0x63/0xad pgdat
[    0.000000]   Normal zone: 222208 pages used for memmap
[    0.000000]   Normal zone: 16030720 pages, LIFO batch:31
[    0.000000] memblock_reserve: [0x107feeb000-0x107ff42fff]
__alloc_memory_core_early+0x63/0xad pgdat
[    0.000000] On node 1 totalpages: 16777216
[    0.000000]   Normal zone: 229376 pages used for memmap
[    0.000000]   Normal zone: 16547840 pages, LIFO batch:31
[    0.000000] memblock_reserve: [0x207ff9d000-0x207fff4fff]
__alloc_memory_core_early+0x63/0xad pgdat
[    0.000000] On node 2 totalpages: 16777216
[    0.000000]   Normal zone: 229376 pages used for memmap
[    0.000000]   Normal zone: 16547840 pages, LIFO batch:31
[    0.000000] memblock_reserve: [0x307ff9d000-0x307fff4fff]
__alloc_memory_core_early+0x63/0xad pgdat
[    0.000000] On node 3 totalpages: 16777216
[    0.000000]   Normal zone: 229376 pages used for memmap
[    0.000000]   Normal zone: 16547840 pages, LIFO batch:31
[    0.000000] memblock_reserve: [0x407ff9d000-0x407fff4fff]
__alloc_memory_core_early+0x63/0xad pgdat
[    0.000000] On node 4 totalpages: 16777216
[    0.000000]   Normal zone: 229376 pages used for memmap
[    0.000000]   Normal zone: 16547840 pages, LIFO batch:31
[    0.000000] memblock_reserve: [0x507ff9d000-0x507fff4fff]
__alloc_memory_core_early+0x63/0xad pgdat
[    0.000000] On node 5 totalpages: 16777216
[    0.000000]   Normal zone: 229376 pages used for memmap
[    0.000000]   Normal zone: 16547840 pages, LIFO batch:31
[    0.000000] memblock_reserve: [0x607ff9d000-0x607fff4fff]
__alloc_memory_core_early+0x63/0xad pgdat
[    0.000000] On node 6 totalpages: 16777216
[    0.000000]   Normal zone: 229376 pages used for memmap
[    0.000000]   Normal zone: 16547840 pages, LIFO batch:31
[    0.000000] memblock_reserve: [0x707ff9d000-0x707fff4fff]
__alloc_memory_core_early+0x63/0xad pgdat
[    0.000000] On node 7 totalpages: 16777216
[    0.000000]   Normal zone: 229376 pages used for memmap
[    0.000000]   Normal zone: 16547840 pages, LIFO batch:31
[    0.000000] memblock_reserve: [0x807fda1000-0x807fdf8fff]
__alloc_memory_core_early+0x63/0xad pgdat
[    0.000000] after - node_states[2]: 0-7
[    0.000000] memblock_reserve: [0x807fda0000-0x807fda0fff]
__alloc_memory_core_early+0x63/0xad pgtable
[    0.000000] ACPI: PM-Timer IO Port: 0x808
[    0.000000] ACPI: Local APIC address 0xfee00000
[    0.000000] mapped APIC to ffffffffff5fb000 (        fee00000)
[    0.000000] ACPI: LAPIC (acpi_id[0x01] lapic_id[0x00] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x02] lapic_id[0x02] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x03] lapic_id[0x04] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x04] lapic_id[0x06] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x05] lapic_id[0x10] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x06] lapic_id[0x12] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x07] lapic_id[0x14] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x08] lapic_id[0x16] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x09] lapic_id[0x20] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x0a] lapic_id[0x22] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x0b] lapic_id[0x24] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x0c] lapic_id[0x26] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x0d] lapic_id[0x30] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x0e] lapic_id[0x32] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x0f] lapic_id[0x34] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x10] lapic_id[0x36] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x11] lapic_id[0x40] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x12] lapic_id[0x42] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x13] lapic_id[0x44] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x14] lapic_id[0x46] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x15] lapic_id[0x50] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x16] lapic_id[0x52] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x17] lapic_id[0x54] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x18] lapic_id[0x56] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x19] lapic_id[0x60] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x1a] lapic_id[0x62] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x1b] lapic_id[0x64] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x1c] lapic_id[0x66] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x1d] lapic_id[0x70] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x1e] lapic_id[0x72] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x1f] lapic_id[0x74] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x20] lapic_id[0x76] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x21] lapic_id[0x80] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x22] lapic_id[0x82] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x23] lapic_id[0x84] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x24] lapic_id[0x86] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x25] lapic_id[0x90] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x26] lapic_id[0x92] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x27] lapic_id[0x94] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x28] lapic_id[0x96] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x29] lapic_id[0xa0] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x2a] lapic_id[0xa2] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x2b] lapic_id[0xa4] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x2c] lapic_id[0xa6] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x2d] lapic_id[0xb0] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x2e] lapic_id[0xb2] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x2f] lapic_id[0xb4] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x30] lapic_id[0xb6] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x31] lapic_id[0xc0] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x32] lapic_id[0xc2] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x33] lapic_id[0xc4] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x34] lapic_id[0xc6] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x35] lapic_id[0xd0] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x36] lapic_id[0xd2] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x37] lapic_id[0xd4] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x38] lapic_id[0xd6] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x39] lapic_id[0xe0] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x3a] lapic_id[0xe2] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x3b] lapic_id[0xe4] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x3c] lapic_id[0xe6] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x3d] lapic_id[0xf0] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x3e] lapic_id[0xf2] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x3f] lapic_id[0xf4] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x40] lapic_id[0xf6] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x41] lapic_id[0x01] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x42] lapic_id[0x03] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x43] lapic_id[0x05] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x44] lapic_id[0x07] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x45] lapic_id[0x11] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x46] lapic_id[0x13] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x47] lapic_id[0x15] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x48] lapic_id[0x17] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x49] lapic_id[0x21] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x4a] lapic_id[0x23] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x4b] lapic_id[0x25] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x4c] lapic_id[0x27] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x4d] lapic_id[0x31] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x4e] lapic_id[0x33] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x4f] lapic_id[0x35] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x50] lapic_id[0x37] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x51] lapic_id[0x41] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x52] lapic_id[0x43] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x53] lapic_id[0x45] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x54] lapic_id[0x47] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x55] lapic_id[0x51] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x56] lapic_id[0x53] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x57] lapic_id[0x55] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x58] lapic_id[0x57] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x59] lapic_id[0x61] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x5a] lapic_id[0x63] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x5b] lapic_id[0x65] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x5c] lapic_id[0x67] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x5d] lapic_id[0x71] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x5e] lapic_id[0x73] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x5f] lapic_id[0x75] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x60] lapic_id[0x77] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x61] lapic_id[0x81] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x62] lapic_id[0x83] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x63] lapic_id[0x85] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x64] lapic_id[0x87] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x65] lapic_id[0x91] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x66] lapic_id[0x93] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x67] lapic_id[0x95] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x68] lapic_id[0x97] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x69] lapic_id[0xa1] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x6a] lapic_id[0xa3] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x6b] lapic_id[0xa5] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x6c] lapic_id[0xa7] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x6d] lapic_id[0xb1] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x6e] lapic_id[0xb3] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x6f] lapic_id[0xb5] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x70] lapic_id[0xb7] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x71] lapic_id[0xc1] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x72] lapic_id[0xc3] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x73] lapic_id[0xc5] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x74] lapic_id[0xc7] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x75] lapic_id[0xd1] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x76] lapic_id[0xd3] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x77] lapic_id[0xd5] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x78] lapic_id[0xd7] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x79] lapic_id[0xe1] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x7a] lapic_id[0xe3] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x7b] lapic_id[0xe5] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x7c] lapic_id[0xe7] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x7d] lapic_id[0xf1] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x7e] lapic_id[0xf3] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x7f] lapic_id[0xf5] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x80] lapic_id[0xf7] enabled)
[    0.000000] ACPI: LAPIC_NMI (acpi_id[0xff] high edge lint[0x1])
[    0.000000] ACPI: IOAPIC (id[0x08] address[0xfec00000] gsi_base[0])
[    0.000000] mapped IOAPIC to ffffffffff5fa000 (fec00000)
[    0.000000] IOAPIC[0]: apic_id 8, version 32, address 0xfec00000, GSI 0-23
[    0.000000] ACPI: IOAPIC (id[0x09] address[0xfec02000] gsi_base[24])
[    0.000000] mapped IOAPIC to ffffffffff5f9000 (fec02000)
[    0.000000] IOAPIC[1]: apic_id 9, version 32, address 0xfec02000, GSI 24-47
[    0.000000] ACPI: IOAPIC (id[0x0a] address[0xfec04000] gsi_base[48])
[    0.000000] mapped IOAPIC to ffffffffff5f8000 (fec04000)
[    0.000000] IOAPIC[2]: apic_id 10, version 32, address 0xfec04000, GSI 48-71
[    0.000000] ACPI: IOAPIC (id[0x0b] address[0xfec08000] gsi_base[72])
[    0.000000] mapped IOAPIC to ffffffffff5f7000 (fec08000)
[    0.000000] IOAPIC[3]: apic_id 11, version 32, address 0xfec08000, GSI 72-95
[    0.000000] ACPI: IOAPIC (id[0x0c] address[0xfec0c000] gsi_base[96])
[    0.000000] mapped IOAPIC to ffffffffff5f6000 (fec0c000)
[    0.000000] IOAPIC[4]: apic_id 12, version 32, address 0xfec0c000, GSI 96-119
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl)
[    0.000000] Int: type 0, pol 0, trig 0, bus 00, IRQ 00, APIC ID 8,
APIC INT 02
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 high level)
[    0.000000] Int: type 0, pol 1, trig 3, bus 00, IRQ 09, APIC ID 8,
APIC INT 09
[    0.000000] ACPI: IRQ0 used by override.
[    0.000000] Int: type 0, pol 0, trig 0, bus 00, IRQ 01, APIC ID 8,
APIC INT 01
[    0.000000] ACPI: IRQ2 used by override.
[    0.000000] Int: type 0, pol 0, trig 0, bus 00, IRQ 03, APIC ID 8,
APIC INT 03
[    0.000000] Int: type 0, pol 0, trig 0, bus 00, IRQ 04, APIC ID 8,
APIC INT 04
[    0.000000] Int: type 0, pol 0, trig 0, bus 00, IRQ 05, APIC ID 8,
APIC INT 05
[    0.000000] Int: type 0, pol 0, trig 0, bus 00, IRQ 06, APIC ID 8,
APIC INT 06
[    0.000000] Int: type 0, pol 0, trig 0, bus 00, IRQ 07, APIC ID 8,
APIC INT 07
[    0.000000] Int: type 0, pol 0, trig 0, bus 00, IRQ 08, APIC ID 8,
APIC INT 08
[    0.000000] ACPI: IRQ9 used by override.
[    0.000000] Int: type 0, pol 0, trig 0, bus 00, IRQ 0a, APIC ID 8,
APIC INT 0a
[    0.000000] Int: type 0, pol 0, trig 0, bus 00, IRQ 0b, APIC ID 8,
APIC INT 0b
[    0.000000] Int: type 0, pol 0, trig 0, bus 00, IRQ 0c, APIC ID 8,
APIC INT 0c
[    0.000000] Int: type 0, pol 0, trig 0, bus 00, IRQ 0d, APIC ID 8,
APIC INT 0d
[    0.000000] Int: type 0, pol 0, trig 0, bus 00, IRQ 0e, APIC ID 8,
APIC INT 0e
[    0.000000] Int: type 0, pol 0, trig 0, bus 00, IRQ 0f, APIC ID 8,
APIC INT 0f
[    0.000000] Using ACPI (MADT) for SMP configuration information
[    0.000000] ACPI: HPET id: 0x8086a301 base: 0xfed00000
[    0.000000] memblock_reserve: [0x807fe00f80-0x807fe00fc0]
__alloc_memory_core_early+0x63/0xad hpet res
[    0.000000] SMP: Allowing 128 CPUs, 0 hotplug CPUs
[    0.000000] memblock_reserve: [0x807fe00e00-0x807fe00f4e]
__alloc_memory_core_early+0x63/0xad ioapic res
[    0.000000] nr_irqs_gsi: 136
[    0.000000] memblock_reserve: [0x807fe00b00-0x807fe00dd7]
__alloc_memory_core_early+0x63/0xad e820 resources
[    0.000000] memblock_reserve: [0x807fe00a80-0x807fe00ae7]
__alloc_memory_core_early+0x63/0xad firmware map
[    0.000000] memblock_reserve: [0x807fe00a00-0x807fe00a67]
__alloc_memory_core_early+0x63/0xad firmware map
[    0.000000] memblock_reserve: [0x807fe00980-0x807fe009e7]
__alloc_memory_core_early+0x63/0xad firmware map
[    0.000000] memblock_reserve: [0x807fe00900-0x807fe00967]
__alloc_memory_core_early+0x63/0xad firmware map
[    0.000000] memblock_reserve: [0x807fe00880-0x807fe008e7]
__alloc_memory_core_early+0x63/0xad firmware map
[    0.000000] memblock_reserve: [0x807fe00800-0x807fe00867]
__alloc_memory_core_early+0x63/0xad firmware map
[    0.000000] memblock_reserve: [0x807fe00780-0x807fe007e7]
__alloc_memory_core_early+0x63/0xad firmware map
[    0.000000] memblock_reserve: [0x807fe00700-0x807fe00767]
__alloc_memory_core_early+0x63/0xad firmware map
[    0.000000] memblock_reserve: [0x807fe00680-0x807fe006e7]
__alloc_memory_core_early+0x63/0xad firmware map
[    0.000000] memblock_reserve: [0x807fe00600-0x807fe00667]
__alloc_memory_core_early+0x63/0xad firmware map
[    0.000000] memblock_reserve: [0x807fe00580-0x807fe005e7]
__alloc_memory_core_early+0x63/0xad firmware map
[    0.000000] memblock_reserve: [0x807fe00500-0x807fe00567]
__alloc_memory_core_early+0x63/0xad firmware map
[    0.000000] Allocating PCI resources starting at 90000000 (gap:
90000000:6ee00000)
[    0.000000] memblock_reserve: [0x807fe00400-0x807fe004d9]
__alloc_memory_core_early+0x63/0xad saved_command_l
[    0.000000] memblock_reserve: [0x807fe00300-0x807fe003d9]
__alloc_memory_core_early+0x63/0xad static_command_
[    0.000000] setup_percpu: NR_CPUS:255 nr_cpumask_bits:255
nr_cpu_ids:128 nr_node_ids:8
[    0.000000] memblock_reserve: [0x807fd9f000-0x807fd9ffff]
__alloc_memory_core_early+0x63/0xad pcpu_alloc_info
[    0.000000] memblock_reserve: [0x807fd9e000-0x807fd9efff]
__alloc_memory_core_early+0x63/0xad pcpu area
[    0.000000] memblock_reserve: [0x107de00000-0x107fdfffff]
__alloc_memory_core_early+0x63/0xad pcpu_alloc
[    0.000000]    memblock_free: [0x107dfdb000-0x107dffffff]
[    0.000000]    memblock_free: [0x107e1db000-0x107e1fffff]
[    0.000000]    memblock_free: [0x107e3db000-0x107e3fffff]
[    0.000000]    memblock_free: [0x107e5db000-0x107e5fffff]
[    0.000000]    memblock_free: [0x107e7db000-0x107e7fffff]
[    0.000000]    memblock_free: [0x107e9db000-0x107e9fffff]
[    0.000000]    memblock_free: [0x107ebdb000-0x107ebfffff]
[    0.000000]    memblock_free: [0x107eddb000-0x107edfffff]
[    0.000000]    memblock_free: [0x107efdb000-0x107effffff]
[    0.000000]    memblock_free: [0x107f1db000-0x107f1fffff]
[    0.000000]    memblock_free: [0x107f3db000-0x107f3fffff]
[    0.000000]    memblock_free: [0x107f5db000-0x107f5fffff]
[    0.000000]    memblock_free: [0x107f7db000-0x107f7fffff]
[    0.000000]    memblock_free: [0x107f9db000-0x107f9fffff]
[    0.000000]    memblock_free: [0x107fbdb000-0x107fbfffff]
[    0.000000]    memblock_free: [0x107fddb000-0x107fdfffff]
[    0.000000] memblock_reserve: [0x207de00000-0x207fdfffff]
__alloc_memory_core_early+0x63/0xad pcpu_alloc
[    0.000000]    memblock_free: [0x207dfdb000-0x207dffffff]
[    0.000000]    memblock_free: [0x207e1db000-0x207e1fffff]
[    0.000000]    memblock_free: [0x207e3db000-0x207e3fffff]
[    0.000000]    memblock_free: [0x207e5db000-0x207e5fffff]
[    0.000000]    memblock_free: [0x207e7db000-0x207e7fffff]
[    0.000000]    memblock_free: [0x207e9db000-0x207e9fffff]
[    0.000000]    memblock_free: [0x207ebdb000-0x207ebfffff]
[    0.000000]    memblock_free: [0x207eddb000-0x207edfffff]
[    0.000000]    memblock_free: [0x207efdb000-0x207effffff]
[    0.000000]    memblock_free: [0x207f1db000-0x207f1fffff]
[    0.000000]    memblock_free: [0x207f3db000-0x207f3fffff]
[    0.000000]    memblock_free: [0x207f5db000-0x207f5fffff]
[    0.000000]    memblock_free: [0x207f7db000-0x207f7fffff]
[    0.000000]    memblock_free: [0x207f9db000-0x207f9fffff]
[    0.000000]    memblock_free: [0x207fbdb000-0x207fbfffff]
[    0.000000]    memblock_free: [0x207fddb000-0x207fdfffff]
[    0.000000] memblock_reserve: [0x307de00000-0x307fdfffff]
__alloc_memory_core_early+0x63/0xad pcpu_alloc
[    0.000000]    memblock_free: [0x307dfdb000-0x307dffffff]
[    0.000000]    memblock_free: [0x307e1db000-0x307e1fffff]
[    0.000000]    memblock_free: [0x307e3db000-0x307e3fffff]
[    0.000000]    memblock_free: [0x307e5db000-0x307e5fffff]
[    0.000000]    memblock_free: [0x307e7db000-0x307e7fffff]
[    0.000000]    memblock_free: [0x307e9db000-0x307e9fffff]
[    0.000000]    memblock_free: [0x307ebdb000-0x307ebfffff]
[    0.000000]    memblock_free: [0x307eddb000-0x307edfffff]
[    0.000000]    memblock_free: [0x307efdb000-0x307effffff]
[    0.000000]    memblock_free: [0x307f1db000-0x307f1fffff]
[    0.000000]    memblock_free: [0x307f3db000-0x307f3fffff]
[    0.000000]    memblock_free: [0x307f5db000-0x307f5fffff]
[    0.000000]    memblock_free: [0x307f7db000-0x307f7fffff]
[    0.000000]    memblock_free: [0x307f9db000-0x307f9fffff]
[    0.000000]    memblock_free: [0x307fbdb000-0x307fbfffff]
[    0.000000]    memblock_free: [0x307fddb000-0x307fdfffff]
[    0.000000] memblock_reserve: [0x407de00000-0x407fdfffff]
__alloc_memory_core_early+0x63/0xad pcpu_alloc
[    0.000000]    memblock_free: [0x407dfdb000-0x407dffffff]
[    0.000000]    memblock_free: [0x407e1db000-0x407e1fffff]
[    0.000000]    memblock_free: [0x407e3db000-0x407e3fffff]
[    0.000000]    memblock_free: [0x407e5db000-0x407e5fffff]
[    0.000000]    memblock_free: [0x407e7db000-0x407e7fffff]
[    0.000000]    memblock_free: [0x407e9db000-0x407e9fffff]
[    0.000000]    memblock_free: [0x407ebdb000-0x407ebfffff]
[    0.000000]    memblock_free: [0x407eddb000-0x407edfffff]
[    0.000000]    memblock_free: [0x407efdb000-0x407effffff]
[    0.000000]    memblock_free: [0x407f1db000-0x407f1fffff]
[    0.000000]    memblock_free: [0x407f3db000-0x407f3fffff]
[    0.000000]    memblock_free: [0x407f5db000-0x407f5fffff]
[    0.000000]    memblock_free: [0x407f7db000-0x407f7fffff]
[    0.000000]    memblock_free: [0x407f9db000-0x407f9fffff]
[    0.000000]    memblock_free: [0x407fbdb000-0x407fbfffff]
[    0.000000]    memblock_free: [0x407fddb000-0x407fdfffff]
[    0.000000] memblock_reserve: [0x507de00000-0x507fdfffff]
__alloc_memory_core_early+0x63/0xad pcpu_alloc
[    0.000000]    memblock_free: [0x507dfdb000-0x507dffffff]
[    0.000000]    memblock_free: [0x507e1db000-0x507e1fffff]
[    0.000000]    memblock_free: [0x507e3db000-0x507e3fffff]
[    0.000000]    memblock_free: [0x507e5db000-0x507e5fffff]
[    0.000000]    memblock_free: [0x507e7db000-0x507e7fffff]
[    0.000000]    memblock_free: [0x507e9db000-0x507e9fffff]
[    0.000000]    memblock_free: [0x507ebdb000-0x507ebfffff]
[    0.000000]    memblock_free: [0x507eddb000-0x507edfffff]
[    0.000000]    memblock_free: [0x507efdb000-0x507effffff]
[    0.000000]    memblock_free: [0x507f1db000-0x507f1fffff]
[    0.000000]    memblock_free: [0x507f3db000-0x507f3fffff]
[    0.000000]    memblock_free: [0x507f5db000-0x507f5fffff]
[    0.000000]    memblock_free: [0x507f7db000-0x507f7fffff]
[    0.000000]    memblock_free: [0x507f9db000-0x507f9fffff]
[    0.000000]    memblock_free: [0x507fbdb000-0x507fbfffff]
[    0.000000]    memblock_free: [0x507fddb000-0x507fdfffff]
[    0.000000] memblock_reserve: [0x607de00000-0x607fdfffff]
__alloc_memory_core_early+0x63/0xad pcpu_alloc
[    0.000000]    memblock_free: [0x607dfdb000-0x607dffffff]
[    0.000000]    memblock_free: [0x607e1db000-0x607e1fffff]
[    0.000000]    memblock_free: [0x607e3db000-0x607e3fffff]
[    0.000000]    memblock_free: [0x607e5db000-0x607e5fffff]
[    0.000000]    memblock_free: [0x607e7db000-0x607e7fffff]
[    0.000000]    memblock_free: [0x607e9db000-0x607e9fffff]
[    0.000000] memblock: reserved array is doubled to 256 at
[0x807fd9c800-0x807fd9dfff]
[    0.000000] memblock_reserve: [0x807fd9c800-0x807fd9dfff]
memblock_reserve+0x10/0x12
[    0.000000]    memblock_free: [0x607ebdb000-0x607ebfffff]
[    0.000000]    memblock_free: [0x607eddb000-0x607edfffff]
[    0.000000]    memblock_free: [0x607efdb000-0x607effffff]
[    0.000000]    memblock_free: [0x607f1db000-0x607f1fffff]
[    0.000000]    memblock_free: [0x607f3db000-0x607f3fffff]
[    0.000000]    memblock_free: [0x607f5db000-0x607f5fffff]
[    0.000000]    memblock_free: [0x607f7db000-0x607f7fffff]
[    0.000000]    memblock_free: [0x607f9db000-0x607f9fffff]
[    0.000000]    memblock_free: [0x607fbdb000-0x607fbfffff]
[    0.000000]    memblock_free: [0x607fddb000-0x607fdfffff]
[    0.000000] memblock_reserve: [0x707de00000-0x707fdfffff]
__alloc_memory_core_early+0x63/0xad pcpu_alloc
[    0.000000]    memblock_free: [0x707dfdb000-0x707dffffff]
[    0.000000]    memblock_free: [0x707e1db000-0x707e1fffff]
[    0.000000]    memblock_free: [0x707e3db000-0x707e3fffff]
[    0.000000]    memblock_free: [0x707e5db000-0x707e5fffff]
[    0.000000]    memblock_free: [0x707e7db000-0x707e7fffff]
[    0.000000]    memblock_free: [0x707e9db000-0x707e9fffff]
[    0.000000]    memblock_free: [0x707ebdb000-0x707ebfffff]
[    0.000000]    memblock_free: [0x707eddb000-0x707edfffff]
[    0.000000]    memblock_free: [0x707efdb000-0x707effffff]
[    0.000000]    memblock_free: [0x707f1db000-0x707f1fffff]
[    0.000000]    memblock_free: [0x707f3db000-0x707f3fffff]
[    0.000000]    memblock_free: [0x707f5db000-0x707f5fffff]
[    0.000000]    memblock_free: [0x707f7db000-0x707f7fffff]
[    0.000000]    memblock_free: [0x707f9db000-0x707f9fffff]
[    0.000000]    memblock_free: [0x707fbdb000-0x707fbfffff]
[    0.000000]    memblock_free: [0x707fddb000-0x707fdfffff]
[    0.000000] memblock_reserve: [0x807d400000-0x807f3fffff]
__alloc_memory_core_early+0x63/0xad pcpu_alloc
[    0.000000]    memblock_free: [0x807d5db000-0x807d5fffff]
[    0.000000]    memblock_free: [0x807d7db000-0x807d7fffff]
[    0.000000]    memblock_free: [0x807d9db000-0x807d9fffff]
[    0.000000]    memblock_free: [0x807dbdb000-0x807dbfffff]
[    0.000000]    memblock_free: [0x807dddb000-0x807ddfffff]
[    0.000000]    memblock_free: [0x807dfdb000-0x807dffffff]
[    0.000000]    memblock_free: [0x807e1db000-0x807e1fffff]
[    0.000000]    memblock_free: [0x807e3db000-0x807e3fffff]
[    0.000000]    memblock_free: [0x807e5db000-0x807e5fffff]
[    0.000000]    memblock_free: [0x807e7db000-0x807e7fffff]
[    0.000000]    memblock_free: [0x807e9db000-0x807e9fffff]
[    0.000000]    memblock_free: [0x807ebdb000-0x807ebfffff]
[    0.000000]    memblock_free: [0x807eddb000-0x807edfffff]
[    0.000000]    memblock_free: [0x807efdb000-0x807effffff]
[    0.000000]    memblock_free: [0x807f1db000-0x807f1fffff]
[    0.000000]    memblock_free: [0x807f3db000-0x807f3fffff]
[    0.000000] PERCPU: Embedded 475 pages/cpu @ffff88107de00000
s1913304 r8192 d24104 u2097152
[    0.000000] memblock_reserve: [0x807fe002c0-0x807fe002ff]
__alloc_memory_core_early+0x63/0xad pcpu group_offs
[    0.000000] memblock_reserve: [0x807fe00280-0x807fe002bf]
__alloc_memory_core_early+0x63/0xad pcpu group_size
[    0.000000] memblock_reserve: [0x807fe00080-0x807fe0027f]
__alloc_memory_core_early+0x63/0xad pcpu unit_map
[    0.000000] memblock_reserve: [0x807fd9c400-0x807fd9c7ff]
__alloc_memory_core_early+0x63/0xad pcpu unit_off
[    0.000000] pcpu-alloc: s1913304 r8192 d24104 u2097152 alloc=1*2097152
[    0.000000] pcpu-alloc: [0] 000 [0] 001 [0] 002 [0] 003
[    0.000000] pcpu-alloc: [0] 004 [0] 005 [0] 006 [0] 007
[    0.000000] pcpu-alloc: [0] 064 [0] 065 [0] 066 [0] 067
[    0.000000] pcpu-alloc: [0] 068 [0] 069 [0] 070 [0] 071
[    0.000000] pcpu-alloc: [1] 008 [1] 009 [1] 010 [1] 011
[    0.000000] pcpu-alloc: [1] 012 [1] 013 [1] 014 [1] 015
[    0.000000] pcpu-alloc: [1] 072 [1] 073 [1] 074 [1] 075
[    0.000000] pcpu-alloc: [1] 076 [1] 077 [1] 078 [1] 079
[    0.000000] pcpu-alloc: [2] 016 [2] 017 [2] 018 [2] 019
[    0.000000] pcpu-alloc: [2] 020 [2] 021 [2] 022 [2] 023
[    0.000000] pcpu-alloc: [2] 080 [2] 081 [2] 082 [2] 083
[    0.000000] pcpu-alloc: [2] 084 [2] 085 [2] 086 [2] 087
[    0.000000] pcpu-alloc: [3] 024 [3] 025 [3] 026 [3] 027
[    0.000000] pcpu-alloc: [3] 028 [3] 029 [3] 030 [3] 031
[    0.000000] pcpu-alloc: [3] 088 [3] 089 [3] 090 [3] 091
[    0.000000] pcpu-alloc: [3] 092 [3] 093 [3] 094 [3] 095
[    0.000000] pcpu-alloc: [4] 032 [4] 033 [4] 034 [4] 035
[    0.000000] pcpu-alloc: [4] 036 [4] 037 [4] 038 [4] 039
[    0.000000] pcpu-alloc: [4] 096 [4] 097 [4] 098 [4] 099
[    0.000000] pcpu-alloc: [4] 100 [4] 101 [4] 102 [4] 103
[    0.000000] pcpu-alloc: [5] 040 [5] 041 [5] 042 [5] 043
[    0.000000] pcpu-alloc: [5] 044 [5] 045 [5] 046 [5] 047
[    0.000000] pcpu-alloc: [5] 104 [5] 105 [5] 106 [5] 107
[    0.000000] pcpu-alloc: [5] 108 [5] 109 [5] 110 [5] 111
[    0.000000] pcpu-alloc: [6] 048 [6] 049 [6] 050 [6] 051
[    0.000000] pcpu-alloc: [6] 052 [6] 053 [6] 054 [6] 055
[    0.000000] pcpu-alloc: [6] 112 [6] 113 [6] 114 [6] 115
[    0.000000] pcpu-alloc: [6] 116 [6] 117 [6] 118 [6] 119
[    0.000000] pcpu-alloc: [7] 056 [7] 057 [7] 058 [7] 059
[    0.000000] pcpu-alloc: [7] 060 [7] 061 [7] 062 [7] 063
[    0.000000] pcpu-alloc: [7] 120 [7] 121 [7] 122 [7] 123
[    0.000000] pcpu-alloc: [7] 124 [7] 125 [7] 126 [7] 127
[    0.000000] memblock_reserve: [0x807fd9c280-0x807fd9c3cf]
__alloc_memory_core_early+0x63/0xad pcpu slot
[    0.000000] memblock_reserve: [0x807fd9c200-0x807fd9c27f]
__alloc_memory_core_early+0x63/0xad pcpu chunk_stru
[    0.000000] memblock_reserve: [0x807fd9c180-0x807fd9c1ff]
__alloc_memory_core_early+0x63/0xad pcpu chunk_stru
[    0.000000]    memblock_free: [0x807fd9f000-0x807fd9ffff]
[    0.000000]    memblock_free: [0x807fd9e000-0x807fd9efff]
[    0.000000] build_zonelists: local_node: 0 next_best_node: 0 1 3 4 2 5 6 7
[    0.000000] build_zonelists: local_node: 1 next_best_node: 1 5 2 0 3 4 6 7
[    0.000000] build_zonelists: local_node: 2 next_best_node: 2 6 3 1 4 7 5 0
[    0.000000] build_zonelists: local_node: 3 next_best_node: 3 7 0 2 4 5 6 1
[    0.000000] build_zonelists: local_node: 4 next_best_node: 4 5 6 0 7 2 3 1
[    0.000000] build_zonelists: local_node: 5 next_best_node: 5 7 4 1 6 0 2 3
[    0.000000] build_zonelists: local_node: 6 next_best_node: 6 7 2 4 0 3 1 5
[    0.000000] build_zonelists: local_node: 7 next_best_node: 7 3 6 5 0 2 4 1
[    0.000000] Built 8 zonelists in Zone order, mobility grouping on.
Total pages: 132373200
[    0.000000] Policy zone: Normal
[    0.000000] Kernel command line: console=uart8250,io,0x3f8,115200n8
initrd=kernel.org/x.gz rw root=/dev/ram0 debug ignore_loglevel
unknown_nmi_panic initcall_debug apic=debug pci=routeirq ip=dhcp
load_ramdisk=1 BOOT_IMAGE=kernel.org/bzImage_3.0_k8.2
[    0.000000] memblock_reserve: [0x807fd94180-0x807fd9c17f]
__alloc_memory_core_early+0x63/0xad large system ha
[    0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes)
[    0.000000] Initializing CPU#0
[    0.000000] memblock_reserve: [0x77af3000-0x7baf2fff]
__alloc_memory_core_early+0x63/0xad swiotlb buffer
[    0.000000] memblock_reserve: [0x807fd74000-0x807fd93fff]
__alloc_memory_core_early+0x63/0xad swiotlb list
[    0.000000] memblock_reserve: [0x807fd34000-0x807fd73fff]
__alloc_memory_core_early+0x63/0xad swiotlb orig_ad
[    0.000000] memblock_reserve: [0x7f746000-0x7f74dfff]
__alloc_memory_core_early+0x63/0xad swiotlb overflo
[    0.000000] Checking aperture...
[    0.000000] No AGP bridge found
[    0.000000] Queued invalidation will be enabled to support x2apic
and Intr-remapping.
[    0.000000]    memblock_free: [0x807fd9c800-0x807fd9dfff]
[    0.000000] memblock_reserve: [0x807fd9c800-0x807fd9dfff]
memblock_reserve+0x10/0x12

^ permalink raw reply	[flat|nested] 54+ messages in thread

* Re: [PATCH 13/13] memblock, x86: Replace memblock_x86_reserve/free_range() with generic ones
  2011-07-27  0:59       ` Yinghai Lu
@ 2011-07-27  8:07         ` Tejun Heo
  0 siblings, 0 replies; 54+ messages in thread
From: Tejun Heo @ 2011-07-27  8:07 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: mingo, hpa, tglx, benh, davem, linux-kernel, linux-arch, x86

Hello, Yinghai.

On Tue, Jul 26, 2011 at 05:59:13PM -0700, Yinghai Lu wrote:
> yes, with bootmem wrap stage, the print out are all the same.
> 
> will have
> __alloc_memory_core_early+0x63
> everywhere.
> 
> add name print out for comparing, name could give some hint.

The better solution would be making __alloc_memory_core_early() pass
in its caller and print it out.  I don't think requiring pretty name
just for debugging is a good or scalable idea.  There's no reason to
bother API users with it.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 54+ messages in thread

end of thread, back to index

Thread overview: 54+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-12  9:15 [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Tejun Heo
2011-07-12  9:15 ` [PATCH 01/13] memblock: Remove memblock_memory_can_coalesce() Tejun Heo
2011-07-14 21:31   ` [tip:x86/memblock] " tip-bot for Tejun Heo
2011-07-12  9:15 ` [PATCH 02/13] memblock: Reimplement memblock_add_region() Tejun Heo
2011-07-14 21:32   ` [tip:x86/memblock] " tip-bot for Tejun Heo
2011-07-12  9:15 ` [PATCH 03/13] memblock: Add optional region->nid Tejun Heo
2011-07-14  9:43   ` [PATCH UPDATED " Tejun Heo
2011-07-14 21:32     ` [tip:x86/memblock] " tip-bot for Tejun Heo
2011-07-12  9:15 ` [PATCH 04/13] x86: Use HAVE_MEMBLOCK_NODE_MAP Tejun Heo
2011-07-14  1:35   ` H. Peter Anvin
2011-07-14  9:44   ` [PATCH UPDATED " Tejun Heo
2011-07-14 21:33     ` [tip:x86/memblock] " tip-bot for Tejun Heo
2011-07-12  9:15 ` [PATCH 05/13] x86: Use __memblock_alloc_base() in early_reserve_e820() Tejun Heo
2011-07-14 21:33   ` [tip:x86/memblock] " tip-bot for Tejun Heo
2011-07-12  9:15 ` [PATCH 06/13] memblock: Implement for_each_free_mem_range() Tejun Heo
2011-07-14 21:34   ` [tip:x86/memblock] " tip-bot for Tejun Heo
2011-07-12  9:16 ` [PATCH 07/13] x86: Replace memblock_x86_find_in_range_size() with for_each_free_mem_range() Tejun Heo
2011-07-14 21:34   ` [tip:x86/memblock] " tip-bot for Tejun Heo
2011-07-12  9:16 ` [PATCH 08/13] memblock, x86: Make free_all_memory_core_early() explicitly free lowmem only Tejun Heo
2011-07-14 21:35   ` [tip:x86/memblock] " tip-bot for Tejun Heo
2011-07-12  9:16 ` [PATCH 09/13] memblock, x86: Replace __get_free_all_memory_range() with for_each_free_mem_range() Tejun Heo
2011-07-14 21:35   ` [tip:x86/memblock] " tip-bot for Tejun Heo
2011-07-12  9:16 ` [PATCH 10/13] memblock, x86: Reimplement memblock_find_dma_reserve() using iterators Tejun Heo
2011-07-14 21:36   ` [tip:x86/memblock] " tip-bot for Tejun Heo
2011-07-12  9:16 ` [PATCH 11/13] x86: Use absent_pages_in_range() instead of memblock_x86_hole_size() Tejun Heo
2011-07-14 21:36   ` [tip:x86/memblock] " tip-bot for Tejun Heo
2011-07-12  9:16 ` [PATCH 12/13] memblock, x86: Make ARCH_DISCARD_MEMBLOCK a config option Tejun Heo
2011-07-14  9:46   ` [PATCH UPDATED " Tejun Heo
2011-07-14 21:37     ` [tip:x86/memblock] " tip-bot for Tejun Heo
2011-07-12  9:16 ` [PATCH 13/13] memblock, x86: Replace memblock_x86_reserve/free_range() with generic ones Tejun Heo
2011-07-14 20:10   ` H. Peter Anvin
2011-07-14 20:20     ` Tejun Heo
2011-07-14 20:23       ` H. Peter Anvin
2011-07-14 20:32         ` Tejun Heo
2011-07-14 20:38           ` H. Peter Anvin
2011-07-14 20:41             ` Tejun Heo
2011-07-14 20:43               ` H. Peter Anvin
2011-07-14 21:38     ` [tip:x86/memblock] memblock: Cast phys_addr_t to unsigned long long for printf use tip-bot for H. Peter Anvin
2011-07-14 21:37   ` [tip:x86/memblock] memblock, x86: Replace memblock_x86_reserve/free_range() with generic ones tip-bot for Tejun Heo
2011-07-26 21:06   ` [PATCH 13/13] " Yinghai Lu
2011-07-26 21:46     ` Tejun Heo
2011-07-27  0:59       ` Yinghai Lu
2011-07-27  8:07         ` Tejun Heo
2011-07-12 23:26 ` [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Yinghai Lu
2011-07-13  3:21   ` H. Peter Anvin
2011-07-13  9:16     ` Tejun Heo
2011-07-13  9:11   ` Tejun Heo
2011-07-13 19:06     ` Yinghai Lu
2011-07-14  9:42 ` [PATCH 2.5/13] memblock: Use __meminit[data] instead of __init[data] Tejun Heo
2011-07-14 21:00   ` Yinghai Lu
2011-07-14 21:24     ` H. Peter Anvin
2011-07-15  5:45     ` Tejun Heo
2011-07-14 21:32   ` [tip:x86/memblock] " tip-bot for Tejun Heo
2011-07-14  9:49 ` [PATCHSET x86/mm] memblock, x86: Allow node info in memblock and remove x86 specific memblock code Tejun Heo

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git