linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] __GFP_THISNODE is not always honored
@ 2008-08-15 22:01 Adam Litke
  2008-08-18 10:59 ` Mel Gorman
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Adam Litke @ 2008-08-15 22:01 UTC (permalink / raw)
  To: linux-mm; +Cc: linux-kernel, Andrew Morton, nacc, mel, apw, agl

While running the libhugetlbfs test suite on a NUMA machine with 2.6.27-rc3, I
discovered some strange behavior with __GFP_THISNODE.  The hugetlb function
alloc_fresh_huge_page_node() calls alloc_pages_node() with __GFP_THISNODE but
occasionally a page that is not on the requested node is returned.  Since the
hugetlb code assumes that the page will be on the requested node, badness follows
when the page is added to the wrong node's free_list.

There is clearly something wrong with the buddy allocator since __GFP_THISNODE
cannot be trusted.  Until that is fixed, the hugetlb code should not assume
that the newly allocated page is on the node asked for.  This patch prevents
the hugetlb pool counters from being corrupted and allows the code to cope with
unbalanced numa allocations.

So far my debugging has led me to get_page_from_freelist() inside the
for_each_zone_zonelist() loop.  When buffered_rmqueue() returns a page I
compare the value of page_to_nid(page), zone->node and the node that the
hugetlb code requested with __GFP_THISNODE.  These all match -- except when the
problem triggers.  In that case, zone->node matches the node we asked for but
page_to_nid() does not.

Workaround patch:
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 67a7119..7a30a61 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -568,7 +568,7 @@ static struct page *alloc_fresh_huge_page_node(struct hstate *h, int nid)
 			__free_pages(page, huge_page_order(h));
 			return NULL;
 		}
-		prep_new_huge_page(h, page, nid);
+		prep_new_huge_page(h, page, page_to_nid(page));
 	}
 
 	return page;

-- 
Adam Litke - (agl at us.ibm.com)
IBM Linux Technology Center


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

end of thread, other threads:[~2008-08-26  9:29 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-15 22:01 [BUG] __GFP_THISNODE is not always honored Adam Litke
2008-08-18 10:59 ` Mel Gorman
2008-08-18 18:16   ` Adam Litke
2008-08-18 19:57     ` Mel Gorman
2008-08-18 19:14   ` Christoph Lameter
2008-08-18 19:21 ` Christoph Lameter
2008-08-18 19:52   ` Mel Gorman
2008-08-20 17:08 ` [BUG] Make setup_zone_migrate_reserve() aware of overlapping nodes Adam Litke
2008-08-20 18:11   ` Dave Hansen
2008-08-20 19:55     ` [BUG] [PATCH v2] " Adam Litke
2008-08-21 11:33       ` Mel Gorman
2008-08-26  9:29         ` Andy Whitcroft

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).