summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Rientjes <rientjes@google.com>2012-01-10 15:07:38 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-10 16:30:43 -0800
commitf6d7e0cb3ecc248e98fa11d83253f6174bd7e085 (patch)
tree0925b5b584c8ed6718a54e6e56202686fb5b9468
parentad8a1b558e6c76fb53901956d3c8f29b82a4ccfa (diff)
downloadlinux-stable-f6d7e0cb3ecc248e98fa11d83253f6174bd7e085.tar.gz
linux-stable-f6d7e0cb3ecc248e98fa11d83253f6174bd7e085.tar.bz2
linux-stable-f6d7e0cb3ecc248e98fa11d83253f6174bd7e085.zip
mm, debug: test for online nid when allocating on single node
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> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/gfp.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 91812df1351a..66f172fdf5fe 100644
--- 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));
}