From 4e9062d481c7909b119d8184dee10e4e6e6139c6 Mon Sep 17 00:00:00 2001 From: Hillf Danton Date: Wed, 21 Mar 2012 16:34:00 -0700 Subject: [PATCH] --- yaml --- r: 292639 b: refs/heads/master c: 28073b02bfaaed1e3278acfb8e6e7c9f76d9f2b6 h: refs/heads/master i: 292637: 425f7c5a200d1e390279f0a396a7569d557312e4 292635: ebe428cf97bf2ffda4854477440274776e18f6d8 292631: 98df1c15ea2ce33e7860b85f17756ec49f648bd2 292623: 04ea745a5a38d8992d841afa306a4761901b23ac 292607: e60f2bab68f4e9d74d5650fdf6520cd34cc996cb v: v3 --- [refs] | 2 +- trunk/mm/hugetlb.c | 30 +++++++++++++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/[refs] b/[refs] index 97e0bbbb7e21..aa309330e436 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: cc715d99e529d470dde2f33a6614f255adea71f3 +refs/heads/master: 28073b02bfaaed1e3278acfb8e6e7c9f76d9f2b6 diff --git a/trunk/mm/hugetlb.c b/trunk/mm/hugetlb.c index a876871f6be5..afe3e1ff919b 100644 --- a/trunk/mm/hugetlb.c +++ b/trunk/mm/hugetlb.c @@ -852,6 +852,7 @@ static int gather_surplus_pages(struct hstate *h, int delta) struct page *page, *tmp; int ret, i; int needed, allocated; + bool alloc_ok = true; needed = (h->resv_huge_pages + delta) - h->free_huge_pages; if (needed <= 0) { @@ -867,17 +868,13 @@ static int gather_surplus_pages(struct hstate *h, int delta) spin_unlock(&hugetlb_lock); for (i = 0; i < needed; i++) { page = alloc_buddy_huge_page(h, NUMA_NO_NODE); - if (!page) - /* - * We were not able to allocate enough pages to - * satisfy the entire reservation so we free what - * we've allocated so far. - */ - goto free; - + if (!page) { + alloc_ok = false; + break; + } list_add(&page->lru, &surplus_list); } - allocated += needed; + allocated += i; /* * After retaking hugetlb_lock, we need to recalculate 'needed' @@ -886,9 +883,16 @@ static int gather_surplus_pages(struct hstate *h, int delta) spin_lock(&hugetlb_lock); needed = (h->resv_huge_pages + delta) - (h->free_huge_pages + allocated); - if (needed > 0) - goto retry; - + if (needed > 0) { + if (alloc_ok) + goto retry; + /* + * We were not able to allocate enough pages to + * satisfy the entire reservation so we free what + * we've allocated so far. + */ + goto free; + } /* * The surplus_list now contains _at_least_ the number of extra pages * needed to accommodate the reservation. Add the appropriate number @@ -914,10 +918,10 @@ static int gather_surplus_pages(struct hstate *h, int delta) VM_BUG_ON(page_count(page)); enqueue_huge_page(h, page); } +free: spin_unlock(&hugetlb_lock); /* Free unnecessary surplus pages to the buddy allocator */ -free: if (!list_empty(&surplus_list)) { list_for_each_entry_safe(page, tmp, &surplus_list, lru) { list_del(&page->lru);