hugetlb: correct page count for surplus huge pages
authorAdam Litke <agl@us.ibm.com>
Mon, 10 Mar 2008 18:43:50 +0000 (11:43 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 11 Mar 2008 01:01:19 +0000 (18:01 -0700)
commit2668db9111bb1a6ab5a54f41f703179f35c7d098
treebde940cfd298321663cf988b607151513c801a1a
parent842078054da2d754c6b998b116d7c468abbfaaca
hugetlb: correct page count for surplus huge pages

Free pages in the hugetlb pool are free and as such have a reference count of
zero.  Regular allocations into the pool from the buddy are "freed" into the
pool which results in their page_count dropping to zero.  However, surplus
pages can be directly utilized by the caller without first being freed to the
pool.  Therefore, a call to put_page_testzero() is in order so that such a
page will be handed to the caller with a correct count.

This has not affected end users because the bad page count is reset before the
page is handed off.  However, under CONFIG_DEBUG_VM this triggers a BUG when
the page count is validated.

Thanks go to Mel for first spotting this issue and providing an initial fix.

Signed-off-by: Adam Litke <agl@us.ibm.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Dave Hansen <haveblue@us.ibm.com>
Cc: William Lee Irwin III <wli@holomorphy.com>
Cc: Andy Whitcroft <apw@shadowen.org>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/hugetlb.c