From: Adam Litke Date: Tue, 16 Oct 2007 08:26:25 +0000 (-0700) Subject: hugetlb: fix dynamic pool resize failure case X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=af767cbdd78f293485c294113885d95e7f1da123;p=openwrt%2Fstaging%2Fblogic.git 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 Acked-by: Dave Hansen Cc: David Gibson Cc: William Lee Irwin III Cc: Badari Pulavarty Cc: Ken Chen Cc: Lee Schermerhorn Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- 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: list_del(&page->lru); if ((--needed) >= 0) enqueue_huge_page(page); - else - update_and_free_page(page); + else { + /* + * Decrement the refcount and free the page using its + * destructor. This must be done with hugetlb_lock + * unlocked which is safe because free_huge_page takes + * hugetlb_lock before deciding how to free the page. + */ + spin_unlock(&hugetlb_lock); + put_page(page); + spin_lock(&hugetlb_lock); + } } return ret;