All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch 00/10] (no)bootmem bits for 3.5
@ 2012-05-07 11:37 ` Johannes Weiner
  0 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-07 11:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

Hi,

here are some (no)bootmem fixes and cleanups for 3.5.  Most of it is
unifying allocation behaviour across bootmem and nobootmem when it
comes to respecting the specified allocation address goal and numa.

But also refactoring the codebases of the two bootmem APIs so that we
can think about sharing code between them again.

 include/linux/bootmem.h |    3 ---
 mm/bootmem.c            |  118 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------
 mm/nobootmem.c          |  112 ++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------
 mm/sparse.c             |   25 ++++++++++++-------------
 4 files changed, 127 insertions(+), 131 deletions(-)


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

* [patch 00/10] (no)bootmem bits for 3.5
@ 2012-05-07 11:37 ` Johannes Weiner
  0 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-07 11:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

Hi,

here are some (no)bootmem fixes and cleanups for 3.5.  Most of it is
unifying allocation behaviour across bootmem and nobootmem when it
comes to respecting the specified allocation address goal and numa.

But also refactoring the codebases of the two bootmem APIs so that we
can think about sharing code between them again.

 include/linux/bootmem.h |    3 ---
 mm/bootmem.c            |  118 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------
 mm/nobootmem.c          |  112 ++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------
 mm/sparse.c             |   25 ++++++++++++-------------
 4 files changed, 127 insertions(+), 131 deletions(-)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [patch 01/10] mm: bootmem: fix checking the bitmap when finally freeing bootmem
  2012-05-07 11:37 ` Johannes Weiner
@ 2012-05-07 11:37   ` Johannes Weiner
  -1 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-07 11:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

From: Gavin Shan <shangw@linux.vnet.ibm.com>

When bootmem releases an unaligned chunk of memory at the beginning of
a node to the page allocator, it iterates from that unaligned PFN but
checks an aligned word of the page bitmap.  The checked bits do not
correspond to the PFNs and, as a result, reserved pages can be freed.

Properly shift the bitmap word so that the lowest bit corresponds to
the starting PFN before entering the freeing loop.

This bug has been around since 41546c1 "bootmem: clean up
free_all_bootmem_core" (2.6.27) without known reports.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/bootmem.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/bootmem.c b/mm/bootmem.c
index 0131170..67872fc 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -203,6 +203,7 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
 		} else {
 			unsigned long off = 0;
 
+			vec >>= start & (BITS_PER_LONG - 1);
 			while (vec && off < BITS_PER_LONG) {
 				if (vec & 1) {
 					page = pfn_to_page(start + off);
-- 
1.7.10


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

* [patch 01/10] mm: bootmem: fix checking the bitmap when finally freeing bootmem
@ 2012-05-07 11:37   ` Johannes Weiner
  0 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-07 11:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

From: Gavin Shan <shangw@linux.vnet.ibm.com>

When bootmem releases an unaligned chunk of memory at the beginning of
a node to the page allocator, it iterates from that unaligned PFN but
checks an aligned word of the page bitmap.  The checked bits do not
correspond to the PFNs and, as a result, reserved pages can be freed.

Properly shift the bitmap word so that the lowest bit corresponds to
the starting PFN before entering the freeing loop.

This bug has been around since 41546c1 "bootmem: clean up
free_all_bootmem_core" (2.6.27) without known reports.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/bootmem.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/bootmem.c b/mm/bootmem.c
index 0131170..67872fc 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -203,6 +203,7 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
 		} else {
 			unsigned long off = 0;
 
+			vec >>= start & (BITS_PER_LONG - 1);
 			while (vec && off < BITS_PER_LONG) {
 				if (vec & 1) {
 					page = pfn_to_page(start + off);
-- 
1.7.10

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [patch 02/10] mm: bootmem: remove redundant offset check when finally freeing bootmem
  2012-05-07 11:37 ` Johannes Weiner
@ 2012-05-07 11:37   ` Johannes Weiner
  -1 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-07 11:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

When bootmem releases an unaligned BITS_PER_LONG pages chunk of memory
to the page allocator, it checks the bitmap if there are still
unreserved pages in the chunk (set bits), but also if the offset in
the chunk indicates BITS_PER_LONG loop iterations already.

But since the consulted bitmap is only a one-word-excerpt of the full
per-node bitmap, there can not be more than BITS_PER_LONG bits set in
it.  The additional offset check is unnecessary.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/bootmem.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/bootmem.c b/mm/bootmem.c
index 67872fc..053ac3f 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -204,7 +204,7 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
 			unsigned long off = 0;
 
 			vec >>= start & (BITS_PER_LONG - 1);
-			while (vec && off < BITS_PER_LONG) {
+			while (vec) {
 				if (vec & 1) {
 					page = pfn_to_page(start + off);
 					__free_pages_bootmem(page, 0);
-- 
1.7.10


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

* [patch 02/10] mm: bootmem: remove redundant offset check when finally freeing bootmem
@ 2012-05-07 11:37   ` Johannes Weiner
  0 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-07 11:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

When bootmem releases an unaligned BITS_PER_LONG pages chunk of memory
to the page allocator, it checks the bitmap if there are still
unreserved pages in the chunk (set bits), but also if the offset in
the chunk indicates BITS_PER_LONG loop iterations already.

But since the consulted bitmap is only a one-word-excerpt of the full
per-node bitmap, there can not be more than BITS_PER_LONG bits set in
it.  The additional offset check is unnecessary.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/bootmem.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/bootmem.c b/mm/bootmem.c
index 67872fc..053ac3f 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -204,7 +204,7 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
 			unsigned long off = 0;
 
 			vec >>= start & (BITS_PER_LONG - 1);
-			while (vec && off < BITS_PER_LONG) {
+			while (vec) {
 				if (vec & 1) {
 					page = pfn_to_page(start + off);
 					__free_pages_bootmem(page, 0);
-- 
1.7.10

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [patch 03/10] mm: bootmem: rename alloc_bootmem_core to alloc_bootmem_bdata
  2012-05-07 11:37 ` Johannes Weiner
@ 2012-05-07 11:37   ` Johannes Weiner
  -1 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-07 11:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

Callsites need to provide a bootmem_data_t *, make the naming more
descriptive.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/bootmem.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/mm/bootmem.c b/mm/bootmem.c
index 053ac3f..ceed0df 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -468,7 +468,7 @@ static unsigned long __init align_off(struct bootmem_data *bdata,
 	return ALIGN(base + off, align) - base;
 }
 
-static void * __init alloc_bootmem_core(struct bootmem_data *bdata,
+static void * __init alloc_bootmem_bdata(struct bootmem_data *bdata,
 					unsigned long size, unsigned long align,
 					unsigned long goal, unsigned long limit)
 {
@@ -589,7 +589,7 @@ static void * __init alloc_arch_preferred_bootmem(bootmem_data_t *bdata,
 		p_bdata = bootmem_arch_preferred_node(bdata, size, align,
 							goal, limit);
 		if (p_bdata)
-			return alloc_bootmem_core(p_bdata, size, align,
+			return alloc_bootmem_bdata(p_bdata, size, align,
 							goal, limit);
 	}
 #endif
@@ -615,7 +615,7 @@ restart:
 		if (limit && bdata->node_min_pfn >= PFN_DOWN(limit))
 			break;
 
-		region = alloc_bootmem_core(bdata, size, align, goal, limit);
+		region = alloc_bootmem_bdata(bdata, size, align, goal, limit);
 		if (region)
 			return region;
 	}
@@ -695,7 +695,7 @@ static void * __init ___alloc_bootmem_node(bootmem_data_t *bdata,
 	if (ptr)
 		return ptr;
 
-	ptr = alloc_bootmem_core(bdata, size, align, goal, limit);
+	ptr = alloc_bootmem_bdata(bdata, size, align, goal, limit);
 	if (ptr)
 		return ptr;
 
@@ -744,7 +744,7 @@ void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
 		unsigned long new_goal;
 
 		new_goal = MAX_DMA32_PFN << PAGE_SHIFT;
-		ptr = alloc_bootmem_core(pgdat->bdata, size, align,
+		ptr = alloc_bootmem_bdata(pgdat->bdata, size, align,
 						 new_goal, 0);
 		if (ptr)
 			return ptr;
@@ -773,7 +773,7 @@ void * __init alloc_bootmem_section(unsigned long size,
 	goal = pfn << PAGE_SHIFT;
 	bdata = &bootmem_node_data[early_pfn_to_nid(pfn)];
 
-	return alloc_bootmem_core(bdata, size, SMP_CACHE_BYTES, goal, 0);
+	return alloc_bootmem_bdata(bdata, size, SMP_CACHE_BYTES, goal, 0);
 }
 #endif
 
@@ -789,7 +789,7 @@ void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size,
 	if (ptr)
 		return ptr;
 
-	ptr = alloc_bootmem_core(pgdat->bdata, size, align, goal, 0);
+	ptr = alloc_bootmem_bdata(pgdat->bdata, size, align, goal, 0);
 	if (ptr)
 		return ptr;
 
-- 
1.7.10


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

* [patch 03/10] mm: bootmem: rename alloc_bootmem_core to alloc_bootmem_bdata
@ 2012-05-07 11:37   ` Johannes Weiner
  0 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-07 11:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

Callsites need to provide a bootmem_data_t *, make the naming more
descriptive.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/bootmem.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/mm/bootmem.c b/mm/bootmem.c
index 053ac3f..ceed0df 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -468,7 +468,7 @@ static unsigned long __init align_off(struct bootmem_data *bdata,
 	return ALIGN(base + off, align) - base;
 }
 
-static void * __init alloc_bootmem_core(struct bootmem_data *bdata,
+static void * __init alloc_bootmem_bdata(struct bootmem_data *bdata,
 					unsigned long size, unsigned long align,
 					unsigned long goal, unsigned long limit)
 {
@@ -589,7 +589,7 @@ static void * __init alloc_arch_preferred_bootmem(bootmem_data_t *bdata,
 		p_bdata = bootmem_arch_preferred_node(bdata, size, align,
 							goal, limit);
 		if (p_bdata)
-			return alloc_bootmem_core(p_bdata, size, align,
+			return alloc_bootmem_bdata(p_bdata, size, align,
 							goal, limit);
 	}
 #endif
@@ -615,7 +615,7 @@ restart:
 		if (limit && bdata->node_min_pfn >= PFN_DOWN(limit))
 			break;
 
-		region = alloc_bootmem_core(bdata, size, align, goal, limit);
+		region = alloc_bootmem_bdata(bdata, size, align, goal, limit);
 		if (region)
 			return region;
 	}
@@ -695,7 +695,7 @@ static void * __init ___alloc_bootmem_node(bootmem_data_t *bdata,
 	if (ptr)
 		return ptr;
 
-	ptr = alloc_bootmem_core(bdata, size, align, goal, limit);
+	ptr = alloc_bootmem_bdata(bdata, size, align, goal, limit);
 	if (ptr)
 		return ptr;
 
@@ -744,7 +744,7 @@ void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
 		unsigned long new_goal;
 
 		new_goal = MAX_DMA32_PFN << PAGE_SHIFT;
-		ptr = alloc_bootmem_core(pgdat->bdata, size, align,
+		ptr = alloc_bootmem_bdata(pgdat->bdata, size, align,
 						 new_goal, 0);
 		if (ptr)
 			return ptr;
@@ -773,7 +773,7 @@ void * __init alloc_bootmem_section(unsigned long size,
 	goal = pfn << PAGE_SHIFT;
 	bdata = &bootmem_node_data[early_pfn_to_nid(pfn)];
 
-	return alloc_bootmem_core(bdata, size, SMP_CACHE_BYTES, goal, 0);
+	return alloc_bootmem_bdata(bdata, size, SMP_CACHE_BYTES, goal, 0);
 }
 #endif
 
@@ -789,7 +789,7 @@ void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size,
 	if (ptr)
 		return ptr;
 
-	ptr = alloc_bootmem_core(pgdat->bdata, size, align, goal, 0);
+	ptr = alloc_bootmem_bdata(pgdat->bdata, size, align, goal, 0);
 	if (ptr)
 		return ptr;
 
-- 
1.7.10

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [patch 04/10] mm: bootmem: split out goal-to-node mapping from goal dropping
  2012-05-07 11:37 ` Johannes Weiner
@ 2012-05-07 11:37   ` Johannes Weiner
  -1 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-07 11:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

Matching the desired goal to the right node is one thing, dropping the
goal when it can not be satisfied is another.  Split this into
separate functions so that subsequent patches can use the node-finding
but drop and handle the goal fallback on their own terms.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/bootmem.c |   17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/mm/bootmem.c b/mm/bootmem.c
index ceed0df..bafeb2c 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -596,7 +596,7 @@ static void * __init alloc_arch_preferred_bootmem(bootmem_data_t *bdata,
 	return NULL;
 }
 
-static void * __init ___alloc_bootmem_nopanic(unsigned long size,
+static void * __init alloc_bootmem_core(unsigned long size,
 					unsigned long align,
 					unsigned long goal,
 					unsigned long limit)
@@ -604,7 +604,6 @@ static void * __init ___alloc_bootmem_nopanic(unsigned long size,
 	bootmem_data_t *bdata;
 	void *region;
 
-restart:
 	region = alloc_arch_preferred_bootmem(NULL, size, align, goal, limit);
 	if (region)
 		return region;
@@ -620,6 +619,20 @@ restart:
 			return region;
 	}
 
+	return NULL;
+}
+
+static void * __init ___alloc_bootmem_nopanic(unsigned long size,
+					      unsigned long align,
+					      unsigned long goal,
+					      unsigned long limit)
+{
+	void *ptr;
+
+restart:
+	ptr = alloc_bootmem_core(size, align, goal, limit);
+	if (ptr)
+		return ptr;
 	if (goal) {
 		goal = 0;
 		goto restart;
-- 
1.7.10


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

* [patch 04/10] mm: bootmem: split out goal-to-node mapping from goal dropping
@ 2012-05-07 11:37   ` Johannes Weiner
  0 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-07 11:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

Matching the desired goal to the right node is one thing, dropping the
goal when it can not be satisfied is another.  Split this into
separate functions so that subsequent patches can use the node-finding
but drop and handle the goal fallback on their own terms.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/bootmem.c |   17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/mm/bootmem.c b/mm/bootmem.c
index ceed0df..bafeb2c 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -596,7 +596,7 @@ static void * __init alloc_arch_preferred_bootmem(bootmem_data_t *bdata,
 	return NULL;
 }
 
-static void * __init ___alloc_bootmem_nopanic(unsigned long size,
+static void * __init alloc_bootmem_core(unsigned long size,
 					unsigned long align,
 					unsigned long goal,
 					unsigned long limit)
@@ -604,7 +604,6 @@ static void * __init ___alloc_bootmem_nopanic(unsigned long size,
 	bootmem_data_t *bdata;
 	void *region;
 
-restart:
 	region = alloc_arch_preferred_bootmem(NULL, size, align, goal, limit);
 	if (region)
 		return region;
@@ -620,6 +619,20 @@ restart:
 			return region;
 	}
 
+	return NULL;
+}
+
+static void * __init ___alloc_bootmem_nopanic(unsigned long size,
+					      unsigned long align,
+					      unsigned long goal,
+					      unsigned long limit)
+{
+	void *ptr;
+
+restart:
+	ptr = alloc_bootmem_core(size, align, goal, limit);
+	if (ptr)
+		return ptr;
 	if (goal) {
 		goal = 0;
 		goto restart;
-- 
1.7.10

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [patch 05/10] mm: bootmem: allocate in order node+goal, goal, node, anywhere
  2012-05-07 11:37 ` Johannes Weiner
@ 2012-05-07 11:37   ` Johannes Weiner
  -1 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-07 11:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

Match the nobootmem version of __alloc_bootmem_node.  Try to satisfy
both the node and the goal, then just the goal, then just the node,
then allocate anywhere before panicking.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/bootmem.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/mm/bootmem.c b/mm/bootmem.c
index bafeb2c..b5babdf 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -704,6 +704,7 @@ static void * __init ___alloc_bootmem_node(bootmem_data_t *bdata,
 {
 	void *ptr;
 
+again:
 	ptr = alloc_arch_preferred_bootmem(bdata, size, align, goal, limit);
 	if (ptr)
 		return ptr;
@@ -712,7 +713,18 @@ static void * __init ___alloc_bootmem_node(bootmem_data_t *bdata,
 	if (ptr)
 		return ptr;
 
-	return ___alloc_bootmem(size, align, goal, limit);
+	ptr = alloc_bootmem_core(size, align, goal, limit);
+	if (ptr)
+		return ptr;
+
+	if (goal) {
+		goal = 0;
+		goto again;
+	}
+
+	printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
+	panic("Out of memory");
+	return NULL;
 }
 
 /**
-- 
1.7.10


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

* [patch 05/10] mm: bootmem: allocate in order node+goal, goal, node, anywhere
@ 2012-05-07 11:37   ` Johannes Weiner
  0 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-07 11:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

Match the nobootmem version of __alloc_bootmem_node.  Try to satisfy
both the node and the goal, then just the goal, then just the node,
then allocate anywhere before panicking.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/bootmem.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/mm/bootmem.c b/mm/bootmem.c
index bafeb2c..b5babdf 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -704,6 +704,7 @@ static void * __init ___alloc_bootmem_node(bootmem_data_t *bdata,
 {
 	void *ptr;
 
+again:
 	ptr = alloc_arch_preferred_bootmem(bdata, size, align, goal, limit);
 	if (ptr)
 		return ptr;
@@ -712,7 +713,18 @@ static void * __init ___alloc_bootmem_node(bootmem_data_t *bdata,
 	if (ptr)
 		return ptr;
 
-	return ___alloc_bootmem(size, align, goal, limit);
+	ptr = alloc_bootmem_core(size, align, goal, limit);
+	if (ptr)
+		return ptr;
+
+	if (goal) {
+		goal = 0;
+		goto again;
+	}
+
+	printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
+	panic("Out of memory");
+	return NULL;
 }
 
 /**
-- 
1.7.10

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [patch 06/10] mm: bootmem: unify allocation policy of (non-)panicking node allocations
  2012-05-07 11:37 ` Johannes Weiner
@ 2012-05-07 11:37   ` Johannes Weiner
  -1 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-07 11:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

While the panicking node-specific allocation function tries to satisfy
node+goal, goal, node, anywhere, the non-panicking function still does
node+goal, goal, anywhere.

Make it simpler: define the panicking version in terms of the
non-panicking one, like the node-agnostic interface, so they always
behave the same way apart from how to deal with allocation failure.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/bootmem.c |   44 ++++++++++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/mm/bootmem.c b/mm/bootmem.c
index b5babdf..d9185c3 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -698,7 +698,7 @@ void * __init __alloc_bootmem(unsigned long size, unsigned long align,
 	return ___alloc_bootmem(size, align, goal, limit);
 }
 
-static void * __init ___alloc_bootmem_node(bootmem_data_t *bdata,
+static void * __init ___alloc_bootmem_node_nopanic(bootmem_data_t *bdata,
 				unsigned long size, unsigned long align,
 				unsigned long goal, unsigned long limit)
 {
@@ -722,6 +722,29 @@ again:
 		goto again;
 	}
 
+	return NULL;
+}
+
+void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size,
+				   unsigned long align, unsigned long goal)
+{
+	if (WARN_ON_ONCE(slab_is_available()))
+		return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
+
+	return ___alloc_bootmem_node_nopanic(pgdat->bdata, size,
+					     align, goal, 0);
+}
+
+void * __init ___alloc_bootmem_node(bootmem_data_t *bdata, unsigned long size,
+				    unsigned long align, unsigned long goal,
+				    unsigned long limit)
+{
+	void *ptr;
+
+	ptr = ___alloc_bootmem_node_nopanic(bdata, size, align, goal, 0);
+	if (ptr)
+		return ptr;
+
 	printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
 	panic("Out of memory");
 	return NULL;
@@ -802,25 +825,6 @@ void * __init alloc_bootmem_section(unsigned long size,
 }
 #endif
 
-void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size,
-				   unsigned long align, unsigned long goal)
-{
-	void *ptr;
-
-	if (WARN_ON_ONCE(slab_is_available()))
-		return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
-
-	ptr = alloc_arch_preferred_bootmem(pgdat->bdata, size, align, goal, 0);
-	if (ptr)
-		return ptr;
-
-	ptr = alloc_bootmem_bdata(pgdat->bdata, size, align, goal, 0);
-	if (ptr)
-		return ptr;
-
-	return __alloc_bootmem_nopanic(size, align, goal);
-}
-
 #ifndef ARCH_LOW_ADDRESS_LIMIT
 #define ARCH_LOW_ADDRESS_LIMIT	0xffffffffUL
 #endif
-- 
1.7.10


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

* [patch 06/10] mm: bootmem: unify allocation policy of (non-)panicking node allocations
@ 2012-05-07 11:37   ` Johannes Weiner
  0 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-07 11:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

While the panicking node-specific allocation function tries to satisfy
node+goal, goal, node, anywhere, the non-panicking function still does
node+goal, goal, anywhere.

Make it simpler: define the panicking version in terms of the
non-panicking one, like the node-agnostic interface, so they always
behave the same way apart from how to deal with allocation failure.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/bootmem.c |   44 ++++++++++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/mm/bootmem.c b/mm/bootmem.c
index b5babdf..d9185c3 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -698,7 +698,7 @@ void * __init __alloc_bootmem(unsigned long size, unsigned long align,
 	return ___alloc_bootmem(size, align, goal, limit);
 }
 
-static void * __init ___alloc_bootmem_node(bootmem_data_t *bdata,
+static void * __init ___alloc_bootmem_node_nopanic(bootmem_data_t *bdata,
 				unsigned long size, unsigned long align,
 				unsigned long goal, unsigned long limit)
 {
@@ -722,6 +722,29 @@ again:
 		goto again;
 	}
 
+	return NULL;
+}
+
+void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size,
+				   unsigned long align, unsigned long goal)
+{
+	if (WARN_ON_ONCE(slab_is_available()))
+		return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
+
+	return ___alloc_bootmem_node_nopanic(pgdat->bdata, size,
+					     align, goal, 0);
+}
+
+void * __init ___alloc_bootmem_node(bootmem_data_t *bdata, unsigned long size,
+				    unsigned long align, unsigned long goal,
+				    unsigned long limit)
+{
+	void *ptr;
+
+	ptr = ___alloc_bootmem_node_nopanic(bdata, size, align, goal, 0);
+	if (ptr)
+		return ptr;
+
 	printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
 	panic("Out of memory");
 	return NULL;
@@ -802,25 +825,6 @@ void * __init alloc_bootmem_section(unsigned long size,
 }
 #endif
 
-void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size,
-				   unsigned long align, unsigned long goal)
-{
-	void *ptr;
-
-	if (WARN_ON_ONCE(slab_is_available()))
-		return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
-
-	ptr = alloc_arch_preferred_bootmem(pgdat->bdata, size, align, goal, 0);
-	if (ptr)
-		return ptr;
-
-	ptr = alloc_bootmem_bdata(pgdat->bdata, size, align, goal, 0);
-	if (ptr)
-		return ptr;
-
-	return __alloc_bootmem_nopanic(size, align, goal);
-}
-
 #ifndef ARCH_LOW_ADDRESS_LIMIT
 #define ARCH_LOW_ADDRESS_LIMIT	0xffffffffUL
 #endif
-- 
1.7.10

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [patch 07/10] mm: nobootmem: panic on node-specific allocation failure
  2012-05-07 11:37 ` Johannes Weiner
@ 2012-05-07 11:37   ` Johannes Weiner
  -1 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-07 11:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

__alloc_bootmem_node and __alloc_bootmem_low_node documentation claims
the functions panic on allocation failure.  Do it.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/nobootmem.c |   20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index e53bb8a..b078ff8 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -306,11 +306,17 @@ again:
 
 	ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
 					goal, -1ULL);
-	if (!ptr && goal) {
+	if (ptr)
+		return ptr;
+
+	if (goal) {
 		goal = 0;
 		goto again;
 	}
-	return ptr;
+
+	printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
+	panic("Out of memory");
+	return NULL;
 }
 
 void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
@@ -408,6 +414,12 @@ void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, unsigned long size,
 	if (ptr)
 		return ptr;
 
-	return  __alloc_memory_core_early(MAX_NUMNODES, size, align,
-				goal, ARCH_LOW_ADDRESS_LIMIT);
+	ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
+					goal, ARCH_LOW_ADDRESS_LIMIT);
+	if (ptr)
+		return ptr;
+
+	printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
+	panic("Out of memory");
+	return NULL;
 }
-- 
1.7.10


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

* [patch 07/10] mm: nobootmem: panic on node-specific allocation failure
@ 2012-05-07 11:37   ` Johannes Weiner
  0 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-07 11:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

__alloc_bootmem_node and __alloc_bootmem_low_node documentation claims
the functions panic on allocation failure.  Do it.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/nobootmem.c |   20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index e53bb8a..b078ff8 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -306,11 +306,17 @@ again:
 
 	ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
 					goal, -1ULL);
-	if (!ptr && goal) {
+	if (ptr)
+		return ptr;
+
+	if (goal) {
 		goal = 0;
 		goto again;
 	}
-	return ptr;
+
+	printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
+	panic("Out of memory");
+	return NULL;
 }
 
 void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
@@ -408,6 +414,12 @@ void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, unsigned long size,
 	if (ptr)
 		return ptr;
 
-	return  __alloc_memory_core_early(MAX_NUMNODES, size, align,
-				goal, ARCH_LOW_ADDRESS_LIMIT);
+	ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
+					goal, ARCH_LOW_ADDRESS_LIMIT);
+	if (ptr)
+		return ptr;
+
+	printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
+	panic("Out of memory");
+	return NULL;
 }
-- 
1.7.10

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [patch 08/10] mm: nobootmem: unify allocation policy of (non-)panicking node allocations
  2012-05-07 11:37 ` Johannes Weiner
@ 2012-05-07 11:37   ` Johannes Weiner
  -1 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-07 11:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

While the panicking node-specific allocation function tries to satisfy
node+goal, goal, node, anywhere, the non-panicking function still does
node+goal, goal, anywhere.

Make it simpler: define the panicking version in terms of the
non-panicking one, like the node-agnostic interface, so they always
behave the same way apart from how to deal with allocation failure.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/nobootmem.c |  106 +++++++++++++++++++++++++++++---------------------------
 1 file changed, 54 insertions(+), 52 deletions(-)

diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index b078ff8..77069bb 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -275,6 +275,57 @@ void * __init __alloc_bootmem(unsigned long size, unsigned long align,
 	return ___alloc_bootmem(size, align, goal, limit);
 }
 
+static void * __init ___alloc_bootmem_node_nopanic(pg_data_t *pgdat,
+						   unsigned long size,
+						   unsigned long align,
+						   unsigned long goal,
+						   unsigned long limit)
+{
+	void *ptr;
+
+again:
+	ptr = __alloc_memory_core_early(pgdat->node_id, size, align,
+					goal, limit);
+	if (ptr)
+		return ptr;
+
+	ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
+					goal, limit);
+	if (ptr)
+		return ptr;
+
+	if (goal) {
+		goal = 0;
+		goto again;
+	}
+
+	return NULL;
+}
+
+void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size,
+				   unsigned long align, unsigned long goal)
+{
+	if (WARN_ON_ONCE(slab_is_available()))
+		return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
+
+	return ___alloc_bootmem_node_nopanic(pgdat, size, align, goal, 0);
+}
+
+void * __init ___alloc_bootmem_node(pg_data_t *pgdat, unsigned long size,
+				    unsigned long align, unsigned long goal,
+				    unsigned long limit)
+{
+	void *ptr;
+
+	ptr = ___alloc_bootmem_node_nopanic(pgdat, size, align, goal, limit);
+	if (ptr)
+		return ptr;
+
+	printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
+	panic("Out of memory");
+	return NULL;
+}
+
 /**
  * __alloc_bootmem_node - allocate boot memory from a specific node
  * @pgdat: node to allocate from
@@ -293,30 +344,10 @@ void * __init __alloc_bootmem(unsigned long size, unsigned long align,
 void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size,
 				   unsigned long align, unsigned long goal)
 {
-	void *ptr;
-
 	if (WARN_ON_ONCE(slab_is_available()))
 		return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
 
-again:
-	ptr = __alloc_memory_core_early(pgdat->node_id, size, align,
-					 goal, -1ULL);
-	if (ptr)
-		return ptr;
-
-	ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
-					goal, -1ULL);
-	if (ptr)
-		return ptr;
-
-	if (goal) {
-		goal = 0;
-		goto again;
-	}
-
-	printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
-	panic("Out of memory");
-	return NULL;
+	return ___alloc_bootmem_node(pgdat, size, align, goal, 0);
 }
 
 void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
@@ -347,22 +378,6 @@ void * __init alloc_bootmem_section(unsigned long size,
 }
 #endif
 
-void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size,
-				   unsigned long align, unsigned long goal)
-{
-	void *ptr;
-
-	if (WARN_ON_ONCE(slab_is_available()))
-		return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
-
-	ptr =  __alloc_memory_core_early(pgdat->node_id, size, align,
-						 goal, -1ULL);
-	if (ptr)
-		return ptr;
-
-	return __alloc_bootmem_nopanic(size, align, goal);
-}
-
 #ifndef ARCH_LOW_ADDRESS_LIMIT
 #define ARCH_LOW_ADDRESS_LIMIT	0xffffffffUL
 #endif
@@ -404,22 +419,9 @@ void * __init __alloc_bootmem_low(unsigned long size, unsigned long align,
 void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, unsigned long size,
 				       unsigned long align, unsigned long goal)
 {
-	void *ptr;
-
 	if (WARN_ON_ONCE(slab_is_available()))
 		return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
 
-	ptr = __alloc_memory_core_early(pgdat->node_id, size, align,
-				goal, ARCH_LOW_ADDRESS_LIMIT);
-	if (ptr)
-		return ptr;
-
-	ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
-					goal, ARCH_LOW_ADDRESS_LIMIT);
-	if (ptr)
-		return ptr;
-
-	printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
-	panic("Out of memory");
-	return NULL;
+	return ___alloc_bootmem_node(pgdat, size, align, goal,
+				     ARCH_LOW_ADDRESS_LIMIT);
 }
-- 
1.7.10


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

* [patch 08/10] mm: nobootmem: unify allocation policy of (non-)panicking node allocations
@ 2012-05-07 11:37   ` Johannes Weiner
  0 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-07 11:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

While the panicking node-specific allocation function tries to satisfy
node+goal, goal, node, anywhere, the non-panicking function still does
node+goal, goal, anywhere.

Make it simpler: define the panicking version in terms of the
non-panicking one, like the node-agnostic interface, so they always
behave the same way apart from how to deal with allocation failure.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/nobootmem.c |  106 +++++++++++++++++++++++++++++---------------------------
 1 file changed, 54 insertions(+), 52 deletions(-)

diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index b078ff8..77069bb 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -275,6 +275,57 @@ void * __init __alloc_bootmem(unsigned long size, unsigned long align,
 	return ___alloc_bootmem(size, align, goal, limit);
 }
 
+static void * __init ___alloc_bootmem_node_nopanic(pg_data_t *pgdat,
+						   unsigned long size,
+						   unsigned long align,
+						   unsigned long goal,
+						   unsigned long limit)
+{
+	void *ptr;
+
+again:
+	ptr = __alloc_memory_core_early(pgdat->node_id, size, align,
+					goal, limit);
+	if (ptr)
+		return ptr;
+
+	ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
+					goal, limit);
+	if (ptr)
+		return ptr;
+
+	if (goal) {
+		goal = 0;
+		goto again;
+	}
+
+	return NULL;
+}
+
+void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size,
+				   unsigned long align, unsigned long goal)
+{
+	if (WARN_ON_ONCE(slab_is_available()))
+		return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
+
+	return ___alloc_bootmem_node_nopanic(pgdat, size, align, goal, 0);
+}
+
+void * __init ___alloc_bootmem_node(pg_data_t *pgdat, unsigned long size,
+				    unsigned long align, unsigned long goal,
+				    unsigned long limit)
+{
+	void *ptr;
+
+	ptr = ___alloc_bootmem_node_nopanic(pgdat, size, align, goal, limit);
+	if (ptr)
+		return ptr;
+
+	printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
+	panic("Out of memory");
+	return NULL;
+}
+
 /**
  * __alloc_bootmem_node - allocate boot memory from a specific node
  * @pgdat: node to allocate from
@@ -293,30 +344,10 @@ void * __init __alloc_bootmem(unsigned long size, unsigned long align,
 void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size,
 				   unsigned long align, unsigned long goal)
 {
-	void *ptr;
-
 	if (WARN_ON_ONCE(slab_is_available()))
 		return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
 
-again:
-	ptr = __alloc_memory_core_early(pgdat->node_id, size, align,
-					 goal, -1ULL);
-	if (ptr)
-		return ptr;
-
-	ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
-					goal, -1ULL);
-	if (ptr)
-		return ptr;
-
-	if (goal) {
-		goal = 0;
-		goto again;
-	}
-
-	printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
-	panic("Out of memory");
-	return NULL;
+	return ___alloc_bootmem_node(pgdat, size, align, goal, 0);
 }
 
 void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
@@ -347,22 +378,6 @@ void * __init alloc_bootmem_section(unsigned long size,
 }
 #endif
 
-void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size,
-				   unsigned long align, unsigned long goal)
-{
-	void *ptr;
-
-	if (WARN_ON_ONCE(slab_is_available()))
-		return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
-
-	ptr =  __alloc_memory_core_early(pgdat->node_id, size, align,
-						 goal, -1ULL);
-	if (ptr)
-		return ptr;
-
-	return __alloc_bootmem_nopanic(size, align, goal);
-}
-
 #ifndef ARCH_LOW_ADDRESS_LIMIT
 #define ARCH_LOW_ADDRESS_LIMIT	0xffffffffUL
 #endif
@@ -404,22 +419,9 @@ void * __init __alloc_bootmem_low(unsigned long size, unsigned long align,
 void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, unsigned long size,
 				       unsigned long align, unsigned long goal)
 {
-	void *ptr;
-
 	if (WARN_ON_ONCE(slab_is_available()))
 		return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
 
-	ptr = __alloc_memory_core_early(pgdat->node_id, size, align,
-				goal, ARCH_LOW_ADDRESS_LIMIT);
-	if (ptr)
-		return ptr;
-
-	ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
-					goal, ARCH_LOW_ADDRESS_LIMIT);
-	if (ptr)
-		return ptr;
-
-	printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
-	panic("Out of memory");
-	return NULL;
+	return ___alloc_bootmem_node(pgdat, size, align, goal,
+				     ARCH_LOW_ADDRESS_LIMIT);
 }
-- 
1.7.10

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [patch 09/10] mm: bootmem: pass pgdat instead of pgdat->bdata down the stack
  2012-05-07 11:37 ` Johannes Weiner
@ 2012-05-07 11:37   ` Johannes Weiner
  -1 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-07 11:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

Pass down the node descriptor instead of the more specific bootmem
node descriptor down the call stack, like nobootmem does, when there
is no good reason for the two to be different.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/bootmem.c |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/mm/bootmem.c b/mm/bootmem.c
index d9185c3..9d0f266 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -698,18 +698,19 @@ void * __init __alloc_bootmem(unsigned long size, unsigned long align,
 	return ___alloc_bootmem(size, align, goal, limit);
 }
 
-static void * __init ___alloc_bootmem_node_nopanic(bootmem_data_t *bdata,
+static void * __init ___alloc_bootmem_node_nopanic(pg_data_t *pgdat,
 				unsigned long size, unsigned long align,
 				unsigned long goal, unsigned long limit)
 {
 	void *ptr;
 
 again:
-	ptr = alloc_arch_preferred_bootmem(bdata, size, align, goal, limit);
+	ptr = alloc_arch_preferred_bootmem(pgdat->bdata, size,
+					   align, goal, limit);
 	if (ptr)
 		return ptr;
 
-	ptr = alloc_bootmem_bdata(bdata, size, align, goal, limit);
+	ptr = alloc_bootmem_bdata(pgdat->bdata, size, align, goal, limit);
 	if (ptr)
 		return ptr;
 
@@ -731,17 +732,16 @@ void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size,
 	if (WARN_ON_ONCE(slab_is_available()))
 		return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
 
-	return ___alloc_bootmem_node_nopanic(pgdat->bdata, size,
-					     align, goal, 0);
+	return ___alloc_bootmem_node_nopanic(pgdat, size, align, goal, 0);
 }
 
-void * __init ___alloc_bootmem_node(bootmem_data_t *bdata, unsigned long size,
+void * __init ___alloc_bootmem_node(pg_data_t *pgdat, unsigned long size,
 				    unsigned long align, unsigned long goal,
 				    unsigned long limit)
 {
 	void *ptr;
 
-	ptr = ___alloc_bootmem_node_nopanic(bdata, size, align, goal, 0);
+	ptr = ___alloc_bootmem_node_nopanic(pgdat, size, align, goal, 0);
 	if (ptr)
 		return ptr;
 
@@ -771,7 +771,7 @@ void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size,
 	if (WARN_ON_ONCE(slab_is_available()))
 		return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
 
-	return  ___alloc_bootmem_node(pgdat->bdata, size, align, goal, 0);
+	return  ___alloc_bootmem_node(pgdat, size, align, goal, 0);
 }
 
 void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
@@ -869,6 +869,6 @@ void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, unsigned long size,
 	if (WARN_ON_ONCE(slab_is_available()))
 		return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
 
-	return ___alloc_bootmem_node(pgdat->bdata, size, align,
-				goal, ARCH_LOW_ADDRESS_LIMIT);
+	return ___alloc_bootmem_node(pgdat, size, align,
+				     goal, ARCH_LOW_ADDRESS_LIMIT);
 }
-- 
1.7.10


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

* [patch 09/10] mm: bootmem: pass pgdat instead of pgdat->bdata down the stack
@ 2012-05-07 11:37   ` Johannes Weiner
  0 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-07 11:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

Pass down the node descriptor instead of the more specific bootmem
node descriptor down the call stack, like nobootmem does, when there
is no good reason for the two to be different.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/bootmem.c |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/mm/bootmem.c b/mm/bootmem.c
index d9185c3..9d0f266 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -698,18 +698,19 @@ void * __init __alloc_bootmem(unsigned long size, unsigned long align,
 	return ___alloc_bootmem(size, align, goal, limit);
 }
 
-static void * __init ___alloc_bootmem_node_nopanic(bootmem_data_t *bdata,
+static void * __init ___alloc_bootmem_node_nopanic(pg_data_t *pgdat,
 				unsigned long size, unsigned long align,
 				unsigned long goal, unsigned long limit)
 {
 	void *ptr;
 
 again:
-	ptr = alloc_arch_preferred_bootmem(bdata, size, align, goal, limit);
+	ptr = alloc_arch_preferred_bootmem(pgdat->bdata, size,
+					   align, goal, limit);
 	if (ptr)
 		return ptr;
 
-	ptr = alloc_bootmem_bdata(bdata, size, align, goal, limit);
+	ptr = alloc_bootmem_bdata(pgdat->bdata, size, align, goal, limit);
 	if (ptr)
 		return ptr;
 
@@ -731,17 +732,16 @@ void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size,
 	if (WARN_ON_ONCE(slab_is_available()))
 		return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
 
-	return ___alloc_bootmem_node_nopanic(pgdat->bdata, size,
-					     align, goal, 0);
+	return ___alloc_bootmem_node_nopanic(pgdat, size, align, goal, 0);
 }
 
-void * __init ___alloc_bootmem_node(bootmem_data_t *bdata, unsigned long size,
+void * __init ___alloc_bootmem_node(pg_data_t *pgdat, unsigned long size,
 				    unsigned long align, unsigned long goal,
 				    unsigned long limit)
 {
 	void *ptr;
 
-	ptr = ___alloc_bootmem_node_nopanic(bdata, size, align, goal, 0);
+	ptr = ___alloc_bootmem_node_nopanic(pgdat, size, align, goal, 0);
 	if (ptr)
 		return ptr;
 
@@ -771,7 +771,7 @@ void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size,
 	if (WARN_ON_ONCE(slab_is_available()))
 		return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
 
-	return  ___alloc_bootmem_node(pgdat->bdata, size, align, goal, 0);
+	return  ___alloc_bootmem_node(pgdat, size, align, goal, 0);
 }
 
 void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
@@ -869,6 +869,6 @@ void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, unsigned long size,
 	if (WARN_ON_ONCE(slab_is_available()))
 		return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
 
-	return ___alloc_bootmem_node(pgdat->bdata, size, align,
-				goal, ARCH_LOW_ADDRESS_LIMIT);
+	return ___alloc_bootmem_node(pgdat, size, align,
+				     goal, ARCH_LOW_ADDRESS_LIMIT);
 }
-- 
1.7.10

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [patch 10/10] mm: remove sparsemem allocation details from the bootmem allocator
  2012-05-07 11:37 ` Johannes Weiner
@ 2012-05-07 11:37   ` Johannes Weiner
  -1 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-07 11:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

alloc_bootmem_section() derives allocation area constraints from the
specified sparsemem section.  This is a bit specific for a generic
memory allocator like bootmem, though, so move it over to sparsemem.

As __alloc_bootmem_node_nopanic() already retries failed allocations
with relaxed area constraints, the fallback code in sparsemem.c can be
removed and the code becomes a bit more compact overall.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 include/linux/bootmem.h |    3 ---
 mm/bootmem.c            |   22 ----------------------
 mm/nobootmem.c          |   22 ----------------------
 mm/sparse.c             |   25 ++++++++++++-------------
 4 files changed, 12 insertions(+), 60 deletions(-)

diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 66d3e95..04e30dc 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -135,9 +135,6 @@ extern void *__alloc_bootmem_low_node(pg_data_t *pgdat,
 extern int reserve_bootmem_generic(unsigned long addr, unsigned long size,
 				   int flags);
 
-extern void *alloc_bootmem_section(unsigned long size,
-				   unsigned long section_nr);
-
 #ifdef CONFIG_HAVE_ARCH_ALLOC_REMAP
 extern void *alloc_remap(int nid, unsigned long size);
 #else
diff --git a/mm/bootmem.c b/mm/bootmem.c
index 9d0f266..d1c7a79 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -803,28 +803,6 @@ void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
 
 }
 
-#ifdef CONFIG_SPARSEMEM
-/**
- * alloc_bootmem_section - allocate boot memory from a specific section
- * @size: size of the request in bytes
- * @section_nr: sparse map section to allocate from
- *
- * Return NULL on failure.
- */
-void * __init alloc_bootmem_section(unsigned long size,
-				    unsigned long section_nr)
-{
-	bootmem_data_t *bdata;
-	unsigned long pfn, goal;
-
-	pfn = section_nr_to_pfn(section_nr);
-	goal = pfn << PAGE_SHIFT;
-	bdata = &bootmem_node_data[early_pfn_to_nid(pfn)];
-
-	return alloc_bootmem_bdata(bdata, size, SMP_CACHE_BYTES, goal, 0);
-}
-#endif
-
 #ifndef ARCH_LOW_ADDRESS_LIMIT
 #define ARCH_LOW_ADDRESS_LIMIT	0xffffffffUL
 #endif
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 77069bb..58e8205 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -356,28 +356,6 @@ void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
 	return __alloc_bootmem_node(pgdat, size, align, goal);
 }
 
-#ifdef CONFIG_SPARSEMEM
-/**
- * alloc_bootmem_section - allocate boot memory from a specific section
- * @size: size of the request in bytes
- * @section_nr: sparse map section to allocate from
- *
- * Return NULL on failure.
- */
-void * __init alloc_bootmem_section(unsigned long size,
-				    unsigned long section_nr)
-{
-	unsigned long pfn, goal, limit;
-
-	pfn = section_nr_to_pfn(section_nr);
-	goal = pfn << PAGE_SHIFT;
-	limit = section_nr_to_pfn(section_nr + 1) << PAGE_SHIFT;
-
-	return __alloc_memory_core_early(early_pfn_to_nid(pfn), size,
-					 SMP_CACHE_BYTES, goal, limit);
-}
-#endif
-
 #ifndef ARCH_LOW_ADDRESS_LIMIT
 #define ARCH_LOW_ADDRESS_LIMIT	0xffffffffUL
 #endif
diff --git a/mm/sparse.c b/mm/sparse.c
index a8bc7d3..2612b59 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -273,10 +273,10 @@ static unsigned long *__kmalloc_section_usemap(void)
 #ifdef CONFIG_MEMORY_HOTREMOVE
 static unsigned long * __init
 sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat,
-					 unsigned long count)
+					 unsigned long size)
 {
-	unsigned long section_nr;
-
+	pg_data_t *host_pgdat;
+	unsigned long goal;
 	/*
 	 * A page may contain usemaps for other sections preventing the
 	 * page being freed and making a section unremovable while
@@ -287,8 +287,10 @@ sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat,
 	 * from the same section as the pgdat where possible to avoid
 	 * this problem.
 	 */
-	section_nr = pfn_to_section_nr(__pa(pgdat) >> PAGE_SHIFT);
-	return alloc_bootmem_section(usemap_size() * count, section_nr);
+	goal = __pa(pgdat) & PAGE_SECTION_MASK;
+	host_pgdat = NODE_DATA(early_pfn_to_nid(goal));
+	return __alloc_bootmem_node_nopanic(host_pgdat, size,
+					    SMP_CACHE_BYTES, goal);
 }
 
 static void __init check_usemap_section_nr(int nid, unsigned long *usemap)
@@ -332,9 +334,9 @@ static void __init check_usemap_section_nr(int nid, unsigned long *usemap)
 #else
 static unsigned long * __init
 sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat,
-					 unsigned long count)
+					 unsigned long size)
 {
-	return NULL;
+	return alloc_bootmem_node_nopanic(pgdat, size)
 }
 
 static void __init check_usemap_section_nr(int nid, unsigned long *usemap)
@@ -352,13 +354,10 @@ static void __init sparse_early_usemaps_alloc_node(unsigned long**usemap_map,
 	int size = usemap_size();
 
 	usemap = sparse_early_usemaps_alloc_pgdat_section(NODE_DATA(nodeid),
-								 usemap_count);
+							  size * usemap_count);
 	if (!usemap) {
-		usemap = alloc_bootmem_node(NODE_DATA(nodeid), size * usemap_count);
-		if (!usemap) {
-			printk(KERN_WARNING "%s: allocation failed\n", __func__);
-			return;
-		}
+		printk(KERN_WARNING "%s: allocation failed\n", __func__);
+		return;
 	}
 
 	for (pnum = pnum_begin; pnum < pnum_end; pnum++) {
-- 
1.7.10


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

* [patch 10/10] mm: remove sparsemem allocation details from the bootmem allocator
@ 2012-05-07 11:37   ` Johannes Weiner
  0 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-07 11:37 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

alloc_bootmem_section() derives allocation area constraints from the
specified sparsemem section.  This is a bit specific for a generic
memory allocator like bootmem, though, so move it over to sparsemem.

As __alloc_bootmem_node_nopanic() already retries failed allocations
with relaxed area constraints, the fallback code in sparsemem.c can be
removed and the code becomes a bit more compact overall.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 include/linux/bootmem.h |    3 ---
 mm/bootmem.c            |   22 ----------------------
 mm/nobootmem.c          |   22 ----------------------
 mm/sparse.c             |   25 ++++++++++++-------------
 4 files changed, 12 insertions(+), 60 deletions(-)

diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 66d3e95..04e30dc 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -135,9 +135,6 @@ extern void *__alloc_bootmem_low_node(pg_data_t *pgdat,
 extern int reserve_bootmem_generic(unsigned long addr, unsigned long size,
 				   int flags);
 
-extern void *alloc_bootmem_section(unsigned long size,
-				   unsigned long section_nr);
-
 #ifdef CONFIG_HAVE_ARCH_ALLOC_REMAP
 extern void *alloc_remap(int nid, unsigned long size);
 #else
diff --git a/mm/bootmem.c b/mm/bootmem.c
index 9d0f266..d1c7a79 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -803,28 +803,6 @@ void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
 
 }
 
-#ifdef CONFIG_SPARSEMEM
-/**
- * alloc_bootmem_section - allocate boot memory from a specific section
- * @size: size of the request in bytes
- * @section_nr: sparse map section to allocate from
- *
- * Return NULL on failure.
- */
-void * __init alloc_bootmem_section(unsigned long size,
-				    unsigned long section_nr)
-{
-	bootmem_data_t *bdata;
-	unsigned long pfn, goal;
-
-	pfn = section_nr_to_pfn(section_nr);
-	goal = pfn << PAGE_SHIFT;
-	bdata = &bootmem_node_data[early_pfn_to_nid(pfn)];
-
-	return alloc_bootmem_bdata(bdata, size, SMP_CACHE_BYTES, goal, 0);
-}
-#endif
-
 #ifndef ARCH_LOW_ADDRESS_LIMIT
 #define ARCH_LOW_ADDRESS_LIMIT	0xffffffffUL
 #endif
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 77069bb..58e8205 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -356,28 +356,6 @@ void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
 	return __alloc_bootmem_node(pgdat, size, align, goal);
 }
 
-#ifdef CONFIG_SPARSEMEM
-/**
- * alloc_bootmem_section - allocate boot memory from a specific section
- * @size: size of the request in bytes
- * @section_nr: sparse map section to allocate from
- *
- * Return NULL on failure.
- */
-void * __init alloc_bootmem_section(unsigned long size,
-				    unsigned long section_nr)
-{
-	unsigned long pfn, goal, limit;
-
-	pfn = section_nr_to_pfn(section_nr);
-	goal = pfn << PAGE_SHIFT;
-	limit = section_nr_to_pfn(section_nr + 1) << PAGE_SHIFT;
-
-	return __alloc_memory_core_early(early_pfn_to_nid(pfn), size,
-					 SMP_CACHE_BYTES, goal, limit);
-}
-#endif
-
 #ifndef ARCH_LOW_ADDRESS_LIMIT
 #define ARCH_LOW_ADDRESS_LIMIT	0xffffffffUL
 #endif
diff --git a/mm/sparse.c b/mm/sparse.c
index a8bc7d3..2612b59 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -273,10 +273,10 @@ static unsigned long *__kmalloc_section_usemap(void)
 #ifdef CONFIG_MEMORY_HOTREMOVE
 static unsigned long * __init
 sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat,
-					 unsigned long count)
+					 unsigned long size)
 {
-	unsigned long section_nr;
-
+	pg_data_t *host_pgdat;
+	unsigned long goal;
 	/*
 	 * A page may contain usemaps for other sections preventing the
 	 * page being freed and making a section unremovable while
@@ -287,8 +287,10 @@ sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat,
 	 * from the same section as the pgdat where possible to avoid
 	 * this problem.
 	 */
-	section_nr = pfn_to_section_nr(__pa(pgdat) >> PAGE_SHIFT);
-	return alloc_bootmem_section(usemap_size() * count, section_nr);
+	goal = __pa(pgdat) & PAGE_SECTION_MASK;
+	host_pgdat = NODE_DATA(early_pfn_to_nid(goal));
+	return __alloc_bootmem_node_nopanic(host_pgdat, size,
+					    SMP_CACHE_BYTES, goal);
 }
 
 static void __init check_usemap_section_nr(int nid, unsigned long *usemap)
@@ -332,9 +334,9 @@ static void __init check_usemap_section_nr(int nid, unsigned long *usemap)
 #else
 static unsigned long * __init
 sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat,
-					 unsigned long count)
+					 unsigned long size)
 {
-	return NULL;
+	return alloc_bootmem_node_nopanic(pgdat, size)
 }
 
 static void __init check_usemap_section_nr(int nid, unsigned long *usemap)
@@ -352,13 +354,10 @@ static void __init sparse_early_usemaps_alloc_node(unsigned long**usemap_map,
 	int size = usemap_size();
 
 	usemap = sparse_early_usemaps_alloc_pgdat_section(NODE_DATA(nodeid),
-								 usemap_count);
+							  size * usemap_count);
 	if (!usemap) {
-		usemap = alloc_bootmem_node(NODE_DATA(nodeid), size * usemap_count);
-		if (!usemap) {
-			printk(KERN_WARNING "%s: allocation failed\n", __func__);
-			return;
-		}
+		printk(KERN_WARNING "%s: allocation failed\n", __func__);
+		return;
 	}
 
 	for (pnum = pnum_begin; pnum < pnum_end; pnum++) {
-- 
1.7.10

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [patch 01/10] mm: bootmem: fix checking the bitmap when finally freeing bootmem
  2012-05-07 11:37   ` Johannes Weiner
@ 2012-05-07 18:07     ` Tejun Heo
  -1 siblings, 0 replies; 50+ messages in thread
From: Tejun Heo @ 2012-05-07 18:07 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Gavin Shan, David Miller, Yinghai Lu, linux-mm,
	linux-kernel

On Mon, May 07, 2012 at 01:37:43PM +0200, Johannes Weiner wrote:
> From: Gavin Shan <shangw@linux.vnet.ibm.com>
> 
> When bootmem releases an unaligned chunk of memory at the beginning of
> a node to the page allocator, it iterates from that unaligned PFN but
> checks an aligned word of the page bitmap.  The checked bits do not
> correspond to the PFNs and, as a result, reserved pages can be freed.
> 
> Properly shift the bitmap word so that the lowest bit corresponds to
> the starting PFN before entering the freeing loop.
> 
> This bug has been around since 41546c1 "bootmem: clean up
> free_all_bootmem_core" (2.6.27) without known reports.
> 
> Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

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

* Re: [patch 01/10] mm: bootmem: fix checking the bitmap when finally freeing bootmem
@ 2012-05-07 18:07     ` Tejun Heo
  0 siblings, 0 replies; 50+ messages in thread
From: Tejun Heo @ 2012-05-07 18:07 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Gavin Shan, David Miller, Yinghai Lu, linux-mm,
	linux-kernel

On Mon, May 07, 2012 at 01:37:43PM +0200, Johannes Weiner wrote:
> From: Gavin Shan <shangw@linux.vnet.ibm.com>
> 
> When bootmem releases an unaligned chunk of memory at the beginning of
> a node to the page allocator, it iterates from that unaligned PFN but
> checks an aligned word of the page bitmap.  The checked bits do not
> correspond to the PFNs and, as a result, reserved pages can be freed.
> 
> Properly shift the bitmap word so that the lowest bit corresponds to
> the starting PFN before entering the freeing loop.
> 
> This bug has been around since 41546c1 "bootmem: clean up
> free_all_bootmem_core" (2.6.27) without known reports.
> 
> Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [patch 02/10] mm: bootmem: remove redundant offset check when finally freeing bootmem
  2012-05-07 11:37   ` Johannes Weiner
@ 2012-05-07 18:08     ` Tejun Heo
  -1 siblings, 0 replies; 50+ messages in thread
From: Tejun Heo @ 2012-05-07 18:08 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Gavin Shan, David Miller, Yinghai Lu, linux-mm,
	linux-kernel

On Mon, May 07, 2012 at 01:37:44PM +0200, Johannes Weiner wrote:
> When bootmem releases an unaligned BITS_PER_LONG pages chunk of memory
> to the page allocator, it checks the bitmap if there are still
> unreserved pages in the chunk (set bits), but also if the offset in
> the chunk indicates BITS_PER_LONG loop iterations already.
> 
> But since the consulted bitmap is only a one-word-excerpt of the full
> per-node bitmap, there can not be more than BITS_PER_LONG bits set in
> it.  The additional offset check is unnecessary.
> 
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

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

* Re: [patch 02/10] mm: bootmem: remove redundant offset check when finally freeing bootmem
@ 2012-05-07 18:08     ` Tejun Heo
  0 siblings, 0 replies; 50+ messages in thread
From: Tejun Heo @ 2012-05-07 18:08 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Gavin Shan, David Miller, Yinghai Lu, linux-mm,
	linux-kernel

On Mon, May 07, 2012 at 01:37:44PM +0200, Johannes Weiner wrote:
> When bootmem releases an unaligned BITS_PER_LONG pages chunk of memory
> to the page allocator, it checks the bitmap if there are still
> unreserved pages in the chunk (set bits), but also if the offset in
> the chunk indicates BITS_PER_LONG loop iterations already.
> 
> But since the consulted bitmap is only a one-word-excerpt of the full
> per-node bitmap, there can not be more than BITS_PER_LONG bits set in
> it.  The additional offset check is unnecessary.
> 
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [patch 10/10] mm: remove sparsemem allocation details from the bootmem allocator
  2012-05-07 11:37   ` Johannes Weiner
@ 2012-05-07 18:19     ` Tejun Heo
  -1 siblings, 0 replies; 50+ messages in thread
From: Tejun Heo @ 2012-05-07 18:19 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Gavin Shan, David Miller, Yinghai Lu, linux-mm,
	linux-kernel

On Mon, May 07, 2012 at 01:37:52PM +0200, Johannes Weiner wrote:
> alloc_bootmem_section() derives allocation area constraints from the
> specified sparsemem section.  This is a bit specific for a generic
> memory allocator like bootmem, though, so move it over to sparsemem.
> 
> As __alloc_bootmem_node_nopanic() already retries failed allocations
> with relaxed area constraints, the fallback code in sparsemem.c can be
> removed and the code becomes a bit more compact overall.
> 
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

For 03-10

 Acked-by: Tejun Heo <tj@kernel.org>

Thanks for doing this.  While at it, maybe we can clear up the naming
mess there?  I don't hate __s too much but the bootmem allocator
brings it to a whole new level.  :(

-- 
tejun

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

* Re: [patch 10/10] mm: remove sparsemem allocation details from the bootmem allocator
@ 2012-05-07 18:19     ` Tejun Heo
  0 siblings, 0 replies; 50+ messages in thread
From: Tejun Heo @ 2012-05-07 18:19 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Gavin Shan, David Miller, Yinghai Lu, linux-mm,
	linux-kernel

On Mon, May 07, 2012 at 01:37:52PM +0200, Johannes Weiner wrote:
> alloc_bootmem_section() derives allocation area constraints from the
> specified sparsemem section.  This is a bit specific for a generic
> memory allocator like bootmem, though, so move it over to sparsemem.
> 
> As __alloc_bootmem_node_nopanic() already retries failed allocations
> with relaxed area constraints, the fallback code in sparsemem.c can be
> removed and the code becomes a bit more compact overall.
> 
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

For 03-10

 Acked-by: Tejun Heo <tj@kernel.org>

Thanks for doing this.  While at it, maybe we can clear up the naming
mess there?  I don't hate __s too much but the bootmem allocator
brings it to a whole new level.  :(

-- 
tejun

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [patch 10/10] mm: remove sparsemem allocation details from the bootmem allocator
  2012-05-07 18:19     ` Tejun Heo
@ 2012-05-07 18:21       ` David Miller
  -1 siblings, 0 replies; 50+ messages in thread
From: David Miller @ 2012-05-07 18:21 UTC (permalink / raw)
  To: tj; +Cc: hannes, akpm, shangw, yinghai, linux-mm, linux-kernel

From: Tejun Heo <tj@kernel.org>
Date: Mon, 7 May 2012 11:19:41 -0700

> On Mon, May 07, 2012 at 01:37:52PM +0200, Johannes Weiner wrote:
>> alloc_bootmem_section() derives allocation area constraints from the
>> specified sparsemem section.  This is a bit specific for a generic
>> memory allocator like bootmem, though, so move it over to sparsemem.
>> 
>> As __alloc_bootmem_node_nopanic() already retries failed allocations
>> with relaxed area constraints, the fallback code in sparsemem.c can be
>> removed and the code becomes a bit more compact overall.
>> 
>> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
> 
> For 03-10
> 
>  Acked-by: Tejun Heo <tj@kernel.org>
> 
> Thanks for doing this.  While at it, maybe we can clear up the naming
> mess there?  I don't hate __s too much but the bootmem allocator
> brings it to a whole new level.  :(

+1  And you can add my Ack to this series too, thanks Johannes:

Acked-by: David S. Miller <davem@davemloft.net>

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

* Re: [patch 10/10] mm: remove sparsemem allocation details from the bootmem allocator
@ 2012-05-07 18:21       ` David Miller
  0 siblings, 0 replies; 50+ messages in thread
From: David Miller @ 2012-05-07 18:21 UTC (permalink / raw)
  To: tj; +Cc: hannes, akpm, shangw, yinghai, linux-mm, linux-kernel

From: Tejun Heo <tj@kernel.org>
Date: Mon, 7 May 2012 11:19:41 -0700

> On Mon, May 07, 2012 at 01:37:52PM +0200, Johannes Weiner wrote:
>> alloc_bootmem_section() derives allocation area constraints from the
>> specified sparsemem section.  This is a bit specific for a generic
>> memory allocator like bootmem, though, so move it over to sparsemem.
>> 
>> As __alloc_bootmem_node_nopanic() already retries failed allocations
>> with relaxed area constraints, the fallback code in sparsemem.c can be
>> removed and the code becomes a bit more compact overall.
>> 
>> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
> 
> For 03-10
> 
>  Acked-by: Tejun Heo <tj@kernel.org>
> 
> Thanks for doing this.  While at it, maybe we can clear up the naming
> mess there?  I don't hate __s too much but the bootmem allocator
> brings it to a whole new level.  :(

+1  And you can add my Ack to this series too, thanks Johannes:

Acked-by: David S. Miller <davem@davemloft.net>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [patch 07/10] mm: nobootmem: panic on node-specific allocation failure
  2012-05-07 11:37   ` Johannes Weiner
@ 2012-05-07 19:17     ` Yinghai Lu
  -1 siblings, 0 replies; 50+ messages in thread
From: Yinghai Lu @ 2012-05-07 19:17 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Gavin Shan, David Miller, Tejun Heo, linux-mm,
	linux-kernel

On Mon, May 7, 2012 at 4:37 AM, Johannes Weiner <hannes@cmpxchg.org> wrote:
> __alloc_bootmem_node and __alloc_bootmem_low_node documentation claims
> the functions panic on allocation failure.  Do it.
>
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
> ---
>  mm/nobootmem.c |   20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/mm/nobootmem.c b/mm/nobootmem.c
> index e53bb8a..b078ff8 100644
> --- a/mm/nobootmem.c
> +++ b/mm/nobootmem.c
> @@ -306,11 +306,17 @@ again:
>
>        ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
>                                        goal, -1ULL);
> -       if (!ptr && goal) {
> +       if (ptr)
> +               return ptr;
> +
> +       if (goal) {
>                goal = 0;
>                goto again;
>        }
> -       return ptr;
> +
> +       printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
> +       panic("Out of memory");
> +       return NULL;
>  }
>
>  void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
> @@ -408,6 +414,12 @@ void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, unsigned long size,
>        if (ptr)
>                return ptr;
>
> -       return  __alloc_memory_core_early(MAX_NUMNODES, size, align,
> -                               goal, ARCH_LOW_ADDRESS_LIMIT);
> +       ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
> +                                       goal, ARCH_LOW_ADDRESS_LIMIT);
> +       if (ptr)
> +               return ptr;
> +
> +       printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
> +       panic("Out of memory");
> +       return NULL;
>  }

Acked-by: Yinghai Lu <yinghai@kernel.org>

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

* Re: [patch 07/10] mm: nobootmem: panic on node-specific allocation failure
@ 2012-05-07 19:17     ` Yinghai Lu
  0 siblings, 0 replies; 50+ messages in thread
From: Yinghai Lu @ 2012-05-07 19:17 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Gavin Shan, David Miller, Tejun Heo, linux-mm,
	linux-kernel

On Mon, May 7, 2012 at 4:37 AM, Johannes Weiner <hannes@cmpxchg.org> wrote:
> __alloc_bootmem_node and __alloc_bootmem_low_node documentation claims
> the functions panic on allocation failure.  Do it.
>
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
> ---
>  mm/nobootmem.c |   20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/mm/nobootmem.c b/mm/nobootmem.c
> index e53bb8a..b078ff8 100644
> --- a/mm/nobootmem.c
> +++ b/mm/nobootmem.c
> @@ -306,11 +306,17 @@ again:
>
>        ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
>                                        goal, -1ULL);
> -       if (!ptr && goal) {
> +       if (ptr)
> +               return ptr;
> +
> +       if (goal) {
>                goal = 0;
>                goto again;
>        }
> -       return ptr;
> +
> +       printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
> +       panic("Out of memory");
> +       return NULL;
>  }
>
>  void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
> @@ -408,6 +414,12 @@ void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, unsigned long size,
>        if (ptr)
>                return ptr;
>
> -       return  __alloc_memory_core_early(MAX_NUMNODES, size, align,
> -                               goal, ARCH_LOW_ADDRESS_LIMIT);
> +       ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
> +                                       goal, ARCH_LOW_ADDRESS_LIMIT);
> +       if (ptr)
> +               return ptr;
> +
> +       printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
> +       panic("Out of memory");
> +       return NULL;
>  }

Acked-by: Yinghai Lu <yinghai@kernel.org>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [patch 08/10] mm: nobootmem: unify allocation policy of (non-)panicking node allocations
  2012-05-07 11:37   ` Johannes Weiner
@ 2012-05-07 19:23     ` Yinghai Lu
  -1 siblings, 0 replies; 50+ messages in thread
From: Yinghai Lu @ 2012-05-07 19:23 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Gavin Shan, David Miller, Tejun Heo, linux-mm,
	linux-kernel

On Mon, May 7, 2012 at 4:37 AM, Johannes Weiner <hannes@cmpxchg.org> wrote:
> While the panicking node-specific allocation function tries to satisfy
> node+goal, goal, node, anywhere, the non-panicking function still does
> node+goal, goal, anywhere.
>
> Make it simpler: define the panicking version in terms of the
> non-panicking one, like the node-agnostic interface, so they always
> behave the same way apart from how to deal with allocation failure.
>
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
> ---
>  mm/nobootmem.c |  106 +++++++++++++++++++++++++++++---------------------------
>  1 file changed, 54 insertions(+), 52 deletions(-)
>
> diff --git a/mm/nobootmem.c b/mm/nobootmem.c
> index b078ff8..77069bb 100644
> --- a/mm/nobootmem.c
> +++ b/mm/nobootmem.c
> @@ -275,6 +275,57 @@ void * __init __alloc_bootmem(unsigned long size, unsigned long align,
>        return ___alloc_bootmem(size, align, goal, limit);
>  }
>
> +static void * __init ___alloc_bootmem_node_nopanic(pg_data_t *pgdat,
> +                                                  unsigned long size,
> +                                                  unsigned long align,
> +                                                  unsigned long goal,
> +                                                  unsigned long limit)
> +{
> +       void *ptr;
> +
> +again:
> +       ptr = __alloc_memory_core_early(pgdat->node_id, size, align,
> +                                       goal, limit);
> +       if (ptr)
> +               return ptr;
> +
> +       ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
> +                                       goal, limit);
> +       if (ptr)
> +               return ptr;
> +
> +       if (goal) {
> +               goal = 0;
> +               goto again;
> +       }
> +
> +       return NULL;
> +}
> +
> +void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size,
> +                                  unsigned long align, unsigned long goal)
> +{
> +       if (WARN_ON_ONCE(slab_is_available()))
> +               return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
> +
> +       return ___alloc_bootmem_node_nopanic(pgdat, size, align, goal, 0);
> +}
> +
> +void * __init ___alloc_bootmem_node(pg_data_t *pgdat, unsigned long size,
> +                                   unsigned long align, unsigned long goal,
> +                                   unsigned long limit)
> +{
> +       void *ptr;
> +
> +       ptr = ___alloc_bootmem_node_nopanic(pgdat, size, align, goal, limit);
> +       if (ptr)
> +               return ptr;
> +
> +       printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
> +       panic("Out of memory");
> +       return NULL;
> +}
> +
>  /**
>  * __alloc_bootmem_node - allocate boot memory from a specific node
>  * @pgdat: node to allocate from
> @@ -293,30 +344,10 @@ void * __init __alloc_bootmem(unsigned long size, unsigned long align,
>  void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size,
>                                   unsigned long align, unsigned long goal)
>  {
> -       void *ptr;
> -
>        if (WARN_ON_ONCE(slab_is_available()))
>                return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
>
> -again:
> -       ptr = __alloc_memory_core_early(pgdat->node_id, size, align,
> -                                        goal, -1ULL);
> -       if (ptr)
> -               return ptr;
> -
> -       ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
> -                                       goal, -1ULL);
> -       if (ptr)
> -               return ptr;
> -
> -       if (goal) {
> -               goal = 0;
> -               goto again;
> -       }
> -
> -       printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
> -       panic("Out of memory");
> -       return NULL;
> +       return ___alloc_bootmem_node(pgdat, size, align, goal, 0);
>  }
>
>  void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
> @@ -347,22 +378,6 @@ void * __init alloc_bootmem_section(unsigned long size,
>  }
>  #endif
>
> -void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size,
> -                                  unsigned long align, unsigned long goal)
> -{
> -       void *ptr;
> -
> -       if (WARN_ON_ONCE(slab_is_available()))
> -               return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
> -
> -       ptr =  __alloc_memory_core_early(pgdat->node_id, size, align,
> -                                                goal, -1ULL);
> -       if (ptr)
> -               return ptr;
> -
> -       return __alloc_bootmem_nopanic(size, align, goal);
> -}
> -
>  #ifndef ARCH_LOW_ADDRESS_LIMIT
>  #define ARCH_LOW_ADDRESS_LIMIT 0xffffffffUL
>  #endif
> @@ -404,22 +419,9 @@ void * __init __alloc_bootmem_low(unsigned long size, unsigned long align,
>  void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, unsigned long size,
>                                       unsigned long align, unsigned long goal)
>  {
> -       void *ptr;
> -
>        if (WARN_ON_ONCE(slab_is_available()))
>                return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
>
> -       ptr = __alloc_memory_core_early(pgdat->node_id, size, align,
> -                               goal, ARCH_LOW_ADDRESS_LIMIT);
> -       if (ptr)
> -               return ptr;
> -
> -       ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
> -                                       goal, ARCH_LOW_ADDRESS_LIMIT);
> -       if (ptr)
> -               return ptr;
> -
> -       printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
> -       panic("Out of memory");
> -       return NULL;
> +       return ___alloc_bootmem_node(pgdat, size, align, goal,
> +                                    ARCH_LOW_ADDRESS_LIMIT);
>  }
> --

Acked-by: Yinghai Lu <yinghai@kernel.org>

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

* Re: [patch 08/10] mm: nobootmem: unify allocation policy of (non-)panicking node allocations
@ 2012-05-07 19:23     ` Yinghai Lu
  0 siblings, 0 replies; 50+ messages in thread
From: Yinghai Lu @ 2012-05-07 19:23 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Gavin Shan, David Miller, Tejun Heo, linux-mm,
	linux-kernel

On Mon, May 7, 2012 at 4:37 AM, Johannes Weiner <hannes@cmpxchg.org> wrote:
> While the panicking node-specific allocation function tries to satisfy
> node+goal, goal, node, anywhere, the non-panicking function still does
> node+goal, goal, anywhere.
>
> Make it simpler: define the panicking version in terms of the
> non-panicking one, like the node-agnostic interface, so they always
> behave the same way apart from how to deal with allocation failure.
>
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
> ---
>  mm/nobootmem.c |  106 +++++++++++++++++++++++++++++---------------------------
>  1 file changed, 54 insertions(+), 52 deletions(-)
>
> diff --git a/mm/nobootmem.c b/mm/nobootmem.c
> index b078ff8..77069bb 100644
> --- a/mm/nobootmem.c
> +++ b/mm/nobootmem.c
> @@ -275,6 +275,57 @@ void * __init __alloc_bootmem(unsigned long size, unsigned long align,
>        return ___alloc_bootmem(size, align, goal, limit);
>  }
>
> +static void * __init ___alloc_bootmem_node_nopanic(pg_data_t *pgdat,
> +                                                  unsigned long size,
> +                                                  unsigned long align,
> +                                                  unsigned long goal,
> +                                                  unsigned long limit)
> +{
> +       void *ptr;
> +
> +again:
> +       ptr = __alloc_memory_core_early(pgdat->node_id, size, align,
> +                                       goal, limit);
> +       if (ptr)
> +               return ptr;
> +
> +       ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
> +                                       goal, limit);
> +       if (ptr)
> +               return ptr;
> +
> +       if (goal) {
> +               goal = 0;
> +               goto again;
> +       }
> +
> +       return NULL;
> +}
> +
> +void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size,
> +                                  unsigned long align, unsigned long goal)
> +{
> +       if (WARN_ON_ONCE(slab_is_available()))
> +               return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
> +
> +       return ___alloc_bootmem_node_nopanic(pgdat, size, align, goal, 0);
> +}
> +
> +void * __init ___alloc_bootmem_node(pg_data_t *pgdat, unsigned long size,
> +                                   unsigned long align, unsigned long goal,
> +                                   unsigned long limit)
> +{
> +       void *ptr;
> +
> +       ptr = ___alloc_bootmem_node_nopanic(pgdat, size, align, goal, limit);
> +       if (ptr)
> +               return ptr;
> +
> +       printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
> +       panic("Out of memory");
> +       return NULL;
> +}
> +
>  /**
>  * __alloc_bootmem_node - allocate boot memory from a specific node
>  * @pgdat: node to allocate from
> @@ -293,30 +344,10 @@ void * __init __alloc_bootmem(unsigned long size, unsigned long align,
>  void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size,
>                                   unsigned long align, unsigned long goal)
>  {
> -       void *ptr;
> -
>        if (WARN_ON_ONCE(slab_is_available()))
>                return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
>
> -again:
> -       ptr = __alloc_memory_core_early(pgdat->node_id, size, align,
> -                                        goal, -1ULL);
> -       if (ptr)
> -               return ptr;
> -
> -       ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
> -                                       goal, -1ULL);
> -       if (ptr)
> -               return ptr;
> -
> -       if (goal) {
> -               goal = 0;
> -               goto again;
> -       }
> -
> -       printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
> -       panic("Out of memory");
> -       return NULL;
> +       return ___alloc_bootmem_node(pgdat, size, align, goal, 0);
>  }
>
>  void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
> @@ -347,22 +378,6 @@ void * __init alloc_bootmem_section(unsigned long size,
>  }
>  #endif
>
> -void * __init __alloc_bootmem_node_nopanic(pg_data_t *pgdat, unsigned long size,
> -                                  unsigned long align, unsigned long goal)
> -{
> -       void *ptr;
> -
> -       if (WARN_ON_ONCE(slab_is_available()))
> -               return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
> -
> -       ptr =  __alloc_memory_core_early(pgdat->node_id, size, align,
> -                                                goal, -1ULL);
> -       if (ptr)
> -               return ptr;
> -
> -       return __alloc_bootmem_nopanic(size, align, goal);
> -}
> -
>  #ifndef ARCH_LOW_ADDRESS_LIMIT
>  #define ARCH_LOW_ADDRESS_LIMIT 0xffffffffUL
>  #endif
> @@ -404,22 +419,9 @@ void * __init __alloc_bootmem_low(unsigned long size, unsigned long align,
>  void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, unsigned long size,
>                                       unsigned long align, unsigned long goal)
>  {
> -       void *ptr;
> -
>        if (WARN_ON_ONCE(slab_is_available()))
>                return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
>
> -       ptr = __alloc_memory_core_early(pgdat->node_id, size, align,
> -                               goal, ARCH_LOW_ADDRESS_LIMIT);
> -       if (ptr)
> -               return ptr;
> -
> -       ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
> -                                       goal, ARCH_LOW_ADDRESS_LIMIT);
> -       if (ptr)
> -               return ptr;
> -
> -       printk(KERN_ALERT "bootmem alloc of %lu bytes failed!\n", size);
> -       panic("Out of memory");
> -       return NULL;
> +       return ___alloc_bootmem_node(pgdat, size, align, goal,
> +                                    ARCH_LOW_ADDRESS_LIMIT);
>  }
> --

Acked-by: Yinghai Lu <yinghai@kernel.org>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [patch 00/10] (no)bootmem bits for 3.5
  2012-05-07 11:37 ` Johannes Weiner
@ 2012-05-07 20:41   ` Sam Ravnborg
  -1 siblings, 0 replies; 50+ messages in thread
From: Sam Ravnborg @ 2012-05-07 20:41 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Gavin Shan, David Miller, Yinghai Lu, Tejun Heo,
	linux-mm, linux-kernel

Hi Johannes.

> here are some (no)bootmem fixes and cleanups for 3.5.  Most of it is
> unifying allocation behaviour across bootmem and nobootmem when it
> comes to respecting the specified allocation address goal and numa.
> 
> But also refactoring the codebases of the two bootmem APIs so that we
> can think about sharing code between them again.

Could you check up on CONFIG_HAVE_ARCH_BOOTMEM use in bootmem.c too?
x86 no longer uses bootmem.c
avr define it - but to n.

So no-one is actually using this anymore.
I have sent patches to remove it from Kconfig for both x86 and avr.

I looked briefly at cleaning up bootmem.c myslef - but I felt not
familiar enough with the code to do the cleanup.

I did not check your patchset - but based on the shortlog you
did not kill HAVE_ARCH_BOOTMEM.

	Sam

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

* Re: [patch 00/10] (no)bootmem bits for 3.5
@ 2012-05-07 20:41   ` Sam Ravnborg
  0 siblings, 0 replies; 50+ messages in thread
From: Sam Ravnborg @ 2012-05-07 20:41 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Gavin Shan, David Miller, Yinghai Lu, Tejun Heo,
	linux-mm, linux-kernel

Hi Johannes.

> here are some (no)bootmem fixes and cleanups for 3.5.  Most of it is
> unifying allocation behaviour across bootmem and nobootmem when it
> comes to respecting the specified allocation address goal and numa.
> 
> But also refactoring the codebases of the two bootmem APIs so that we
> can think about sharing code between them again.

Could you check up on CONFIG_HAVE_ARCH_BOOTMEM use in bootmem.c too?
x86 no longer uses bootmem.c
avr define it - but to n.

So no-one is actually using this anymore.
I have sent patches to remove it from Kconfig for both x86 and avr.

I looked briefly at cleaning up bootmem.c myslef - but I felt not
familiar enough with the code to do the cleanup.

I did not check your patchset - but based on the shortlog you
did not kill HAVE_ARCH_BOOTMEM.

	Sam

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [patch 00/10] (no)bootmem bits for 3.5
  2012-05-07 20:41   ` Sam Ravnborg
@ 2012-05-07 22:01     ` Johannes Weiner
  -1 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-07 22:01 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Andrew Morton, Gavin Shan, David Miller, Yinghai Lu, Tejun Heo,
	linux-mm, linux-kernel

On Mon, May 07, 2012 at 10:41:13PM +0200, Sam Ravnborg wrote:
> Hi Johannes.
> 
> > here are some (no)bootmem fixes and cleanups for 3.5.  Most of it is
> > unifying allocation behaviour across bootmem and nobootmem when it
> > comes to respecting the specified allocation address goal and numa.
> > 
> > But also refactoring the codebases of the two bootmem APIs so that we
> > can think about sharing code between them again.
> 
> Could you check up on CONFIG_HAVE_ARCH_BOOTMEM use in bootmem.c too?
> x86 no longer uses bootmem.c
> avr define it - but to n.
> 
> So no-one is actually using this anymore.
> I have sent patches to remove it from Kconfig for both x86 and avr.
> 
> I looked briefly at cleaning up bootmem.c myslef - but I felt not
> familiar enough with the code to do the cleanup.
> 
> I did not check your patchset - but based on the shortlog you
> did not kill HAVE_ARCH_BOOTMEM.

It was used on x86-32 numa to try all bootmem allocations from node 0
first (see only remaining definition of bootmem_arch_preferred_node),
which AFAICS nobootmem no longer respects.

Shouldn't this be fixed instead?

But yeah, we can remove the bootmem.c parts, I think.

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

* Re: [patch 00/10] (no)bootmem bits for 3.5
@ 2012-05-07 22:01     ` Johannes Weiner
  0 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-07 22:01 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Andrew Morton, Gavin Shan, David Miller, Yinghai Lu, Tejun Heo,
	linux-mm, linux-kernel

On Mon, May 07, 2012 at 10:41:13PM +0200, Sam Ravnborg wrote:
> Hi Johannes.
> 
> > here are some (no)bootmem fixes and cleanups for 3.5.  Most of it is
> > unifying allocation behaviour across bootmem and nobootmem when it
> > comes to respecting the specified allocation address goal and numa.
> > 
> > But also refactoring the codebases of the two bootmem APIs so that we
> > can think about sharing code between them again.
> 
> Could you check up on CONFIG_HAVE_ARCH_BOOTMEM use in bootmem.c too?
> x86 no longer uses bootmem.c
> avr define it - but to n.
> 
> So no-one is actually using this anymore.
> I have sent patches to remove it from Kconfig for both x86 and avr.
> 
> I looked briefly at cleaning up bootmem.c myslef - but I felt not
> familiar enough with the code to do the cleanup.
> 
> I did not check your patchset - but based on the shortlog you
> did not kill HAVE_ARCH_BOOTMEM.

It was used on x86-32 numa to try all bootmem allocations from node 0
first (see only remaining definition of bootmem_arch_preferred_node),
which AFAICS nobootmem no longer respects.

Shouldn't this be fixed instead?

But yeah, we can remove the bootmem.c parts, I think.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [patch 00/10] (no)bootmem bits for 3.5
  2012-05-07 22:01     ` Johannes Weiner
@ 2012-05-08 17:57       ` Sam Ravnborg
  -1 siblings, 0 replies; 50+ messages in thread
From: Sam Ravnborg @ 2012-05-08 17:57 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Gavin Shan, David Miller, Yinghai Lu, Tejun Heo,
	linux-mm, linux-kernel

On Tue, May 08, 2012 at 12:01:42AM +0200, Johannes Weiner wrote:
> On Mon, May 07, 2012 at 10:41:13PM +0200, Sam Ravnborg wrote:
> > Hi Johannes.
> > 
> > > here are some (no)bootmem fixes and cleanups for 3.5.  Most of it is
> > > unifying allocation behaviour across bootmem and nobootmem when it
> > > comes to respecting the specified allocation address goal and numa.
> > > 
> > > But also refactoring the codebases of the two bootmem APIs so that we
> > > can think about sharing code between them again.
> > 
> > Could you check up on CONFIG_HAVE_ARCH_BOOTMEM use in bootmem.c too?
> > x86 no longer uses bootmem.c
> > avr define it - but to n.
> > 
> > So no-one is actually using this anymore.
> > I have sent patches to remove it from Kconfig for both x86 and avr.
> > 
> > I looked briefly at cleaning up bootmem.c myslef - but I felt not
> > familiar enough with the code to do the cleanup.
> > 
> > I did not check your patchset - but based on the shortlog you
> > did not kill HAVE_ARCH_BOOTMEM.
> 
> It was used on x86-32 numa to try all bootmem allocations from node 0
> first (see only remaining definition of bootmem_arch_preferred_node),
> which AFAICS nobootmem no longer respects.
> 
> Shouldn't this be fixed instead?
I do not know. Tejun / Yinghai?

	Sam

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

* Re: [patch 00/10] (no)bootmem bits for 3.5
@ 2012-05-08 17:57       ` Sam Ravnborg
  0 siblings, 0 replies; 50+ messages in thread
From: Sam Ravnborg @ 2012-05-08 17:57 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Andrew Morton, Gavin Shan, David Miller, Yinghai Lu, Tejun Heo,
	linux-mm, linux-kernel

On Tue, May 08, 2012 at 12:01:42AM +0200, Johannes Weiner wrote:
> On Mon, May 07, 2012 at 10:41:13PM +0200, Sam Ravnborg wrote:
> > Hi Johannes.
> > 
> > > here are some (no)bootmem fixes and cleanups for 3.5.  Most of it is
> > > unifying allocation behaviour across bootmem and nobootmem when it
> > > comes to respecting the specified allocation address goal and numa.
> > > 
> > > But also refactoring the codebases of the two bootmem APIs so that we
> > > can think about sharing code between them again.
> > 
> > Could you check up on CONFIG_HAVE_ARCH_BOOTMEM use in bootmem.c too?
> > x86 no longer uses bootmem.c
> > avr define it - but to n.
> > 
> > So no-one is actually using this anymore.
> > I have sent patches to remove it from Kconfig for both x86 and avr.
> > 
> > I looked briefly at cleaning up bootmem.c myslef - but I felt not
> > familiar enough with the code to do the cleanup.
> > 
> > I did not check your patchset - but based on the shortlog you
> > did not kill HAVE_ARCH_BOOTMEM.
> 
> It was used on x86-32 numa to try all bootmem allocations from node 0
> first (see only remaining definition of bootmem_arch_preferred_node),
> which AFAICS nobootmem no longer respects.
> 
> Shouldn't this be fixed instead?
I do not know. Tejun / Yinghai?

	Sam

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [patch 00/10] (no)bootmem bits for 3.5
  2012-05-08 17:57       ` Sam Ravnborg
@ 2012-05-09 17:35         ` Tejun Heo
  -1 siblings, 0 replies; 50+ messages in thread
From: Tejun Heo @ 2012-05-09 17:35 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Johannes Weiner, Andrew Morton, Gavin Shan, David Miller,
	Yinghai Lu, linux-mm, linux-kernel, H. Peter Anvin,
	Thomas Gleixner, Ingo Molnar

Hello,

On Tue, May 08, 2012 at 07:57:48PM +0200, Sam Ravnborg wrote:
> > It was used on x86-32 numa to try all bootmem allocations from node 0
> > first (see only remaining definition of bootmem_arch_preferred_node),
> > which AFAICS nobootmem no longer respects.
> > 
> > Shouldn't this be fixed instead?
> I do not know. Tejun / Yinghai?

Indeed, preferring node 0 for bootmem allocation on x86_32 got lost
across the nobootmem changes.  I followed the git history and
preferring NODE_DATA(0) goes back to the initial git branch creation
time (2.6.12) and I couldn't find any explanation, and nobody
complained about the changed behavior.  hpa, do you know why the code
to prefer node 0 for bootmem allocations was added in the first place?
Maybe we can just remove it?

Thanks.

-- 
tejun

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

* Re: [patch 00/10] (no)bootmem bits for 3.5
@ 2012-05-09 17:35         ` Tejun Heo
  0 siblings, 0 replies; 50+ messages in thread
From: Tejun Heo @ 2012-05-09 17:35 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Johannes Weiner, Andrew Morton, Gavin Shan, David Miller,
	Yinghai Lu, linux-mm, linux-kernel, H. Peter Anvin,
	Thomas Gleixner, Ingo Molnar

Hello,

On Tue, May 08, 2012 at 07:57:48PM +0200, Sam Ravnborg wrote:
> > It was used on x86-32 numa to try all bootmem allocations from node 0
> > first (see only remaining definition of bootmem_arch_preferred_node),
> > which AFAICS nobootmem no longer respects.
> > 
> > Shouldn't this be fixed instead?
> I do not know. Tejun / Yinghai?

Indeed, preferring node 0 for bootmem allocation on x86_32 got lost
across the nobootmem changes.  I followed the git history and
preferring NODE_DATA(0) goes back to the initial git branch creation
time (2.6.12) and I couldn't find any explanation, and nobody
complained about the changed behavior.  hpa, do you know why the code
to prefer node 0 for bootmem allocations was added in the first place?
Maybe we can just remove it?

Thanks.

-- 
tejun

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [patch 00/10] (no)bootmem bits for 3.5
  2012-05-09 17:35         ` Tejun Heo
@ 2012-05-09 17:54           ` Christoph Lameter
  -1 siblings, 0 replies; 50+ messages in thread
From: Christoph Lameter @ 2012-05-09 17:54 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Sam Ravnborg, Johannes Weiner, Andrew Morton, Gavin Shan,
	David Miller, Yinghai Lu, linux-mm, linux-kernel, H. Peter Anvin,
	Thomas Gleixner, Ingo Molnar

On Wed, 9 May 2012, Tejun Heo wrote:

> Indeed, preferring node 0 for bootmem allocation on x86_32 got lost
> across the nobootmem changes.  I followed the git history and
> preferring NODE_DATA(0) goes back to the initial git branch creation
> time (2.6.12) and I couldn't find any explanation, and nobody
> complained about the changed behavior.  hpa, do you know why the code
> to prefer node 0 for bootmem allocations was added in the first place?
> Maybe we can just remove it?

On some early 32 bit NUMA platforms only node 0 had ZONE_NORMAL memory.
There is just no other ZONE_NORMAL memory available on other nodes on that
hardware. But that is ancient history.

Wondering if 32 bit numa machines still exist. If so how do they partition
memory below 1G?


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

* Re: [patch 00/10] (no)bootmem bits for 3.5
@ 2012-05-09 17:54           ` Christoph Lameter
  0 siblings, 0 replies; 50+ messages in thread
From: Christoph Lameter @ 2012-05-09 17:54 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Sam Ravnborg, Johannes Weiner, Andrew Morton, Gavin Shan,
	David Miller, Yinghai Lu, linux-mm, linux-kernel, H. Peter Anvin,
	Thomas Gleixner, Ingo Molnar

On Wed, 9 May 2012, Tejun Heo wrote:

> Indeed, preferring node 0 for bootmem allocation on x86_32 got lost
> across the nobootmem changes.  I followed the git history and
> preferring NODE_DATA(0) goes back to the initial git branch creation
> time (2.6.12) and I couldn't find any explanation, and nobody
> complained about the changed behavior.  hpa, do you know why the code
> to prefer node 0 for bootmem allocations was added in the first place?
> Maybe we can just remove it?

On some early 32 bit NUMA platforms only node 0 had ZONE_NORMAL memory.
There is just no other ZONE_NORMAL memory available on other nodes on that
hardware. But that is ancient history.

Wondering if 32 bit numa machines still exist. If so how do they partition
memory below 1G?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [patch 00/10] (no)bootmem bits for 3.5
  2012-05-09 17:54           ` Christoph Lameter
@ 2012-05-09 18:08             ` Tejun Heo
  -1 siblings, 0 replies; 50+ messages in thread
From: Tejun Heo @ 2012-05-09 18:08 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: Sam Ravnborg, Johannes Weiner, Andrew Morton, Gavin Shan,
	David Miller, Yinghai Lu, linux-mm, linux-kernel, H. Peter Anvin,
	Thomas Gleixner, Ingo Molnar

Hello, Christoph.

On Wed, May 09, 2012 at 12:54:37PM -0500, Christoph Lameter wrote:
> On some early 32 bit NUMA platforms only node 0 had ZONE_NORMAL memory.
> There is just no other ZONE_NORMAL memory available on other nodes on that
> hardware. But that is ancient history.

I see, but that shouldn't matter (at least anymore), the allocator can
fall back to other nodes just fine and there's no reason to
preemptively prefer node 0.

Thanks.

-- 
tejun

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

* Re: [patch 00/10] (no)bootmem bits for 3.5
@ 2012-05-09 18:08             ` Tejun Heo
  0 siblings, 0 replies; 50+ messages in thread
From: Tejun Heo @ 2012-05-09 18:08 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: Sam Ravnborg, Johannes Weiner, Andrew Morton, Gavin Shan,
	David Miller, Yinghai Lu, linux-mm, linux-kernel, H. Peter Anvin,
	Thomas Gleixner, Ingo Molnar

Hello, Christoph.

On Wed, May 09, 2012 at 12:54:37PM -0500, Christoph Lameter wrote:
> On some early 32 bit NUMA platforms only node 0 had ZONE_NORMAL memory.
> There is just no other ZONE_NORMAL memory available on other nodes on that
> hardware. But that is ancient history.

I see, but that shouldn't matter (at least anymore), the allocator can
fall back to other nodes just fine and there's no reason to
preemptively prefer node 0.

Thanks.

-- 
tejun

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [patch 10/10] mm: remove sparsemem allocation details from the bootmem allocator
  2012-05-07 11:37   ` Johannes Weiner
@ 2012-05-10 21:44     ` Andrew Morton
  -1 siblings, 0 replies; 50+ messages in thread
From: Andrew Morton @ 2012-05-10 21:44 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

On Mon,  7 May 2012 13:37:52 +0200
Johannes Weiner <hannes@cmpxchg.org> wrote:

> alloc_bootmem_section() derives allocation area constraints from the
> specified sparsemem section.  This is a bit specific for a generic
> memory allocator like bootmem, though, so move it over to sparsemem.
> 
> As __alloc_bootmem_node_nopanic() already retries failed allocations
> with relaxed area constraints, the fallback code in sparsemem.c can be
> removed and the code becomes a bit more compact overall.
> 
> ...
>
> @@ -332,9 +334,9 @@ static void __init check_usemap_section_nr(int nid, unsigned long *usemap)
>  #else
>  static unsigned long * __init
>  sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat,
> -					 unsigned long count)
> +					 unsigned long size)
>  {
> -	return NULL;
> +	return alloc_bootmem_node_nopanic(pgdat, size)

You've been bad.   Your penance is to runtime test this code with
CONFIG_MEMORY_HOTREMOVE=n!

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

* Re: [patch 10/10] mm: remove sparsemem allocation details from the bootmem allocator
@ 2012-05-10 21:44     ` Andrew Morton
  0 siblings, 0 replies; 50+ messages in thread
From: Andrew Morton @ 2012-05-10 21:44 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

On Mon,  7 May 2012 13:37:52 +0200
Johannes Weiner <hannes@cmpxchg.org> wrote:

> alloc_bootmem_section() derives allocation area constraints from the
> specified sparsemem section.  This is a bit specific for a generic
> memory allocator like bootmem, though, so move it over to sparsemem.
> 
> As __alloc_bootmem_node_nopanic() already retries failed allocations
> with relaxed area constraints, the fallback code in sparsemem.c can be
> removed and the code becomes a bit more compact overall.
> 
> ...
>
> @@ -332,9 +334,9 @@ static void __init check_usemap_section_nr(int nid, unsigned long *usemap)
>  #else
>  static unsigned long * __init
>  sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat,
> -					 unsigned long count)
> +					 unsigned long size)
>  {
> -	return NULL;
> +	return alloc_bootmem_node_nopanic(pgdat, size)

You've been bad.   Your penance is to runtime test this code with
CONFIG_MEMORY_HOTREMOVE=n!

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [patch 10/10] mm: remove sparsemem allocation details from the bootmem allocator
  2012-05-10 21:44     ` Andrew Morton
@ 2012-05-15 11:47       ` Johannes Weiner
  -1 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-15 11:47 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

On Thu, May 10, 2012 at 02:44:39PM -0700, Andrew Morton wrote:
> On Mon,  7 May 2012 13:37:52 +0200
> Johannes Weiner <hannes@cmpxchg.org> wrote:
> 
> > alloc_bootmem_section() derives allocation area constraints from the
> > specified sparsemem section.  This is a bit specific for a generic
> > memory allocator like bootmem, though, so move it over to sparsemem.
> > 
> > As __alloc_bootmem_node_nopanic() already retries failed allocations
> > with relaxed area constraints, the fallback code in sparsemem.c can be
> > removed and the code becomes a bit more compact overall.
> > 
> > ...
> >
> > @@ -332,9 +334,9 @@ static void __init check_usemap_section_nr(int nid, unsigned long *usemap)
> >  #else
> >  static unsigned long * __init
> >  sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat,
> > -					 unsigned long count)
> > +					 unsigned long size)
> >  {
> > -	return NULL;
> > +	return alloc_bootmem_node_nopanic(pgdat, size)
> 
> You've been bad.   Your penance is to runtime test this code with
> CONFIG_MEMORY_HOTREMOVE=n!

I did now.

See, but I DID test the =y case, missed an obvious bug and even
considered the particular node-section dependency warnings to be
expected in the setup configuration.  Testing is no way around being a
cretin :(

So here is another fix:

---
From: Johannes Weiner <hannes@cmpxchg.org>
Subject: [patch] mm: remove sparsemem allocation details from the bootmem
 allocator fix

Don't confuse an address with a pfn.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/sparse.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/sparse.c b/mm/sparse.c
index 2192b67..66d1845 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -288,7 +288,7 @@ sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat,
 	 * this problem.
 	 */
 	goal = __pa(pgdat) & PAGE_SECTION_MASK;
-	host_pgdat = NODE_DATA(early_pfn_to_nid(goal));
+	host_pgdat = NODE_DATA(early_pfn_to_nid(goal >> PAGE_SHIFT));
 	printk("allocating usemap for node %d on node %d (goal=%lu)\n",
 	       pgdat->node_id, host_pgdat->node_id, goal);
 	return __alloc_bootmem_node_nopanic(host_pgdat, size,
-- 
1.7.10.1


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

* Re: [patch 10/10] mm: remove sparsemem allocation details from the bootmem allocator
@ 2012-05-15 11:47       ` Johannes Weiner
  0 siblings, 0 replies; 50+ messages in thread
From: Johannes Weiner @ 2012-05-15 11:47 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Gavin Shan, David Miller, Yinghai Lu, Tejun Heo, linux-mm, linux-kernel

On Thu, May 10, 2012 at 02:44:39PM -0700, Andrew Morton wrote:
> On Mon,  7 May 2012 13:37:52 +0200
> Johannes Weiner <hannes@cmpxchg.org> wrote:
> 
> > alloc_bootmem_section() derives allocation area constraints from the
> > specified sparsemem section.  This is a bit specific for a generic
> > memory allocator like bootmem, though, so move it over to sparsemem.
> > 
> > As __alloc_bootmem_node_nopanic() already retries failed allocations
> > with relaxed area constraints, the fallback code in sparsemem.c can be
> > removed and the code becomes a bit more compact overall.
> > 
> > ...
> >
> > @@ -332,9 +334,9 @@ static void __init check_usemap_section_nr(int nid, unsigned long *usemap)
> >  #else
> >  static unsigned long * __init
> >  sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat,
> > -					 unsigned long count)
> > +					 unsigned long size)
> >  {
> > -	return NULL;
> > +	return alloc_bootmem_node_nopanic(pgdat, size)
> 
> You've been bad.   Your penance is to runtime test this code with
> CONFIG_MEMORY_HOTREMOVE=n!

I did now.

See, but I DID test the =y case, missed an obvious bug and even
considered the particular node-section dependency warnings to be
expected in the setup configuration.  Testing is no way around being a
cretin :(

So here is another fix:

---
From: Johannes Weiner <hannes@cmpxchg.org>
Subject: [patch] mm: remove sparsemem allocation details from the bootmem
 allocator fix

Don't confuse an address with a pfn.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/sparse.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/sparse.c b/mm/sparse.c
index 2192b67..66d1845 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -288,7 +288,7 @@ sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat,
 	 * this problem.
 	 */
 	goal = __pa(pgdat) & PAGE_SECTION_MASK;
-	host_pgdat = NODE_DATA(early_pfn_to_nid(goal));
+	host_pgdat = NODE_DATA(early_pfn_to_nid(goal >> PAGE_SHIFT));
 	printk("allocating usemap for node %d on node %d (goal=%lu)\n",
 	       pgdat->node_id, host_pgdat->node_id, goal);
 	return __alloc_bootmem_node_nopanic(host_pgdat, size,
-- 
1.7.10.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2012-05-15 11:47 UTC | newest]

Thread overview: 50+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-07 11:37 [patch 00/10] (no)bootmem bits for 3.5 Johannes Weiner
2012-05-07 11:37 ` Johannes Weiner
2012-05-07 11:37 ` [patch 01/10] mm: bootmem: fix checking the bitmap when finally freeing bootmem Johannes Weiner
2012-05-07 11:37   ` Johannes Weiner
2012-05-07 18:07   ` Tejun Heo
2012-05-07 18:07     ` Tejun Heo
2012-05-07 11:37 ` [patch 02/10] mm: bootmem: remove redundant offset check " Johannes Weiner
2012-05-07 11:37   ` Johannes Weiner
2012-05-07 18:08   ` Tejun Heo
2012-05-07 18:08     ` Tejun Heo
2012-05-07 11:37 ` [patch 03/10] mm: bootmem: rename alloc_bootmem_core to alloc_bootmem_bdata Johannes Weiner
2012-05-07 11:37   ` Johannes Weiner
2012-05-07 11:37 ` [patch 04/10] mm: bootmem: split out goal-to-node mapping from goal dropping Johannes Weiner
2012-05-07 11:37   ` Johannes Weiner
2012-05-07 11:37 ` [patch 05/10] mm: bootmem: allocate in order node+goal, goal, node, anywhere Johannes Weiner
2012-05-07 11:37   ` Johannes Weiner
2012-05-07 11:37 ` [patch 06/10] mm: bootmem: unify allocation policy of (non-)panicking node allocations Johannes Weiner
2012-05-07 11:37   ` Johannes Weiner
2012-05-07 11:37 ` [patch 07/10] mm: nobootmem: panic on node-specific allocation failure Johannes Weiner
2012-05-07 11:37   ` Johannes Weiner
2012-05-07 19:17   ` Yinghai Lu
2012-05-07 19:17     ` Yinghai Lu
2012-05-07 11:37 ` [patch 08/10] mm: nobootmem: unify allocation policy of (non-)panicking node allocations Johannes Weiner
2012-05-07 11:37   ` Johannes Weiner
2012-05-07 19:23   ` Yinghai Lu
2012-05-07 19:23     ` Yinghai Lu
2012-05-07 11:37 ` [patch 09/10] mm: bootmem: pass pgdat instead of pgdat->bdata down the stack Johannes Weiner
2012-05-07 11:37   ` Johannes Weiner
2012-05-07 11:37 ` [patch 10/10] mm: remove sparsemem allocation details from the bootmem allocator Johannes Weiner
2012-05-07 11:37   ` Johannes Weiner
2012-05-07 18:19   ` Tejun Heo
2012-05-07 18:19     ` Tejun Heo
2012-05-07 18:21     ` David Miller
2012-05-07 18:21       ` David Miller
2012-05-10 21:44   ` Andrew Morton
2012-05-10 21:44     ` Andrew Morton
2012-05-15 11:47     ` Johannes Weiner
2012-05-15 11:47       ` Johannes Weiner
2012-05-07 20:41 ` [patch 00/10] (no)bootmem bits for 3.5 Sam Ravnborg
2012-05-07 20:41   ` Sam Ravnborg
2012-05-07 22:01   ` Johannes Weiner
2012-05-07 22:01     ` Johannes Weiner
2012-05-08 17:57     ` Sam Ravnborg
2012-05-08 17:57       ` Sam Ravnborg
2012-05-09 17:35       ` Tejun Heo
2012-05-09 17:35         ` Tejun Heo
2012-05-09 17:54         ` Christoph Lameter
2012-05-09 17:54           ` Christoph Lameter
2012-05-09 18:08           ` Tejun Heo
2012-05-09 18:08             ` Tejun Heo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.