linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [patch] mm, debug: test for online nid when allocating on single node
@ 2011-11-23  1:26 David Rientjes
  2011-11-24  9:52 ` Mel Gorman
  0 siblings, 1 reply; 3+ messages in thread
From: David Rientjes @ 2011-11-23  1:26 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Mel Gorman, linux-mm

Calling alloc_pages_exact_node() means the allocation only passes the
zonelist of a single node into the page allocator.  If that node isn't
online, it's zonelist may never have been initialized causing a strange
oops that may not immediately be clear.

I recently debugged an issue where node 0 wasn't online and an allocator
was passing 0 to alloc_pages_exact_node() and it resulted in a NULL
pointer on zonelist->_zoneref.  If CONFIG_DEBUG_VM is enabled, though, it
would be nice to catch this a bit earlier.

Signed-off-by: David Rientjes <rientjes@google.com>
---
 include/linux/gfp.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/linux/gfp.h b/include/linux/gfp.h
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -313,7 +313,7 @@ static inline struct page *alloc_pages_node(int nid, gfp_t gfp_mask,
 static inline struct page *alloc_pages_exact_node(int nid, gfp_t gfp_mask,
 						unsigned int order)
 {
-	VM_BUG_ON(nid < 0 || nid >= MAX_NUMNODES);
+	VM_BUG_ON(nid < 0 || nid >= MAX_NUMNODES || !node_online(nid));
 
 	return __alloc_pages(gfp_mask, order, node_zonelist(nid, gfp_mask));
 }

--
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] 3+ messages in thread

* Re: [patch] mm, debug: test for online nid when allocating on single node
  2011-11-23  1:26 [patch] mm, debug: test for online nid when allocating on single node David Rientjes
@ 2011-11-24  9:52 ` Mel Gorman
  2011-11-28 10:15   ` David Rientjes
  0 siblings, 1 reply; 3+ messages in thread
From: Mel Gorman @ 2011-11-24  9:52 UTC (permalink / raw)
  To: David Rientjes; +Cc: Andrew Morton, linux-mm

On Tue, Nov 22, 2011 at 05:26:05PM -0800, David Rientjes wrote:
> Calling alloc_pages_exact_node() means the allocation only passes the
> zonelist of a single node into the page allocator.  If that node isn't
> online, it's zonelist may never have been initialized causing a strange
> oops that may not immediately be clear.
> 
> I recently debugged an issue where node 0 wasn't online and an allocator
> was passing 0 to alloc_pages_exact_node() and it resulted in a NULL
> pointer on zonelist->_zoneref.  If CONFIG_DEBUG_VM is enabled, though, it
> would be nice to catch this a bit earlier.
> 
> Signed-off-by: David Rientjes <rientjes@google.com>

Acked-by: Mel Gorman <mgorman@suse.de>

Out of curiousity, who was passing in the ID of an offline node to
alloc_pages_exact_node() ?

-- 
Mel Gorman
SUSE Labs

--
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] 3+ messages in thread

* Re: [patch] mm, debug: test for online nid when allocating on single node
  2011-11-24  9:52 ` Mel Gorman
@ 2011-11-28 10:15   ` David Rientjes
  0 siblings, 0 replies; 3+ messages in thread
From: David Rientjes @ 2011-11-28 10:15 UTC (permalink / raw)
  To: Mel Gorman; +Cc: Andrew Morton, linux-mm

On Thu, 24 Nov 2011, Mel Gorman wrote:

> > Calling alloc_pages_exact_node() means the allocation only passes the
> > zonelist of a single node into the page allocator.  If that node isn't
> > online, it's zonelist may never have been initialized causing a strange
> > oops that may not immediately be clear.
> > 
> > I recently debugged an issue where node 0 wasn't online and an allocator
> > was passing 0 to alloc_pages_exact_node() and it resulted in a NULL
> > pointer on zonelist->_zoneref.  If CONFIG_DEBUG_VM is enabled, though, it
> > would be nice to catch this a bit earlier.
> > 
> > Signed-off-by: David Rientjes <rientjes@google.com>
> 
> Acked-by: Mel Gorman <mgorman@suse.de>
> 
> Out of curiousity, who was passing in the ID of an offline node to
> alloc_pages_exact_node() ?
> 

It was the block layer in blk_throtl_init() because it passes the ->node 
field of request_queue to the slab layer which uses 
alloc_pages_exact_node() and requeue_queue is allocated with __GFP_ZERO 
and ->node isn't initialized until later.  At the same time, the machine 
only has a single node online, node 1, where the crashkernel was 
allocated.  My analysis is at 
http://marc.info/?l=linux-kernel&m=132195611123426

I've worked with kernels without a node 0 very successfully since about 
2.6.18 so the VM appears pretty stable in that regard, too, which is good 
news.

--
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] 3+ messages in thread

end of thread, other threads:[~2011-11-28 10:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-23  1:26 [patch] mm, debug: test for online nid when allocating on single node David Rientjes
2011-11-24  9:52 ` Mel Gorman
2011-11-28 10:15   ` David Rientjes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).