diff options
author | Adam Litke <agl@us.ibm.com> | 2007-10-16 04:26:25 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-16 12:43:03 -0400 |
commit | af767cbdd78f293485c294113885d95e7f1da123 (patch) | |
tree | 934d5c6180e808ee2062d8d2ef2ed758c452286d | |
parent | 63b4613c3f0d4b724ba259dc6c201bb68b884e1a (diff) |
hugetlb: fix dynamic pool resize failure case
When gather_surplus_pages() fails to allocate enough huge pages to satisfy
the requested reservation, it frees what it did allocate back to the buddy
allocator. put_page() should be called instead of update_and_free_page()
to ensure that pool counters are updated as appropriate and the page's
refcount is decremented.
Signed-off-by: Adam Litke <agl@us.ibm.com>
Acked-by: Dave Hansen <haveblue@us.ibm.com>
Cc: David Gibson <hermes@gibson.dropbear.id.au>
Cc: William Lee Irwin III <wli@holomorphy.com>
Cc: Badari Pulavarty <pbadari@us.ibm.com>
Cc: Ken Chen <kenchen@google.com>
Cc: Lee Schermerhorn <lee.schermerhorn@hp.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | mm/hugetlb.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 82efecbab96f..ae2959bb59cb 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c | |||
@@ -302,8 +302,17 @@ free: | |||
302 | list_del(&page->lru); | 302 | list_del(&page->lru); |
303 | if ((--needed) >= 0) | 303 | if ((--needed) >= 0) |
304 | enqueue_huge_page(page); | 304 | enqueue_huge_page(page); |
305 | else | 305 | else { |
306 | update_and_free_page(page); | 306 | /* |
307 | * Decrement the refcount and free the page using its | ||
308 | * destructor. This must be done with hugetlb_lock | ||
309 | * unlocked which is safe because free_huge_page takes | ||
310 | * hugetlb_lock before deciding how to free the page. | ||
311 | */ | ||
312 | spin_unlock(&hugetlb_lock); | ||
313 | put_page(page); | ||
314 | spin_lock(&hugetlb_lock); | ||
315 | } | ||
307 | } | 316 | } |
308 | 317 | ||
309 | return ret; | 318 | return ret; |