diff options
Diffstat (limited to 'mm/hugetlb.c')
-rw-r--r-- | mm/hugetlb.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index efd78527ad1e..8fb86ba452b0 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c | |||
@@ -403,14 +403,14 @@ static void try_to_free_low(unsigned long count) | |||
403 | for (i = 0; i < MAX_NUMNODES; ++i) { | 403 | for (i = 0; i < MAX_NUMNODES; ++i) { |
404 | struct page *page, *next; | 404 | struct page *page, *next; |
405 | list_for_each_entry_safe(page, next, &hugepage_freelists[i], lru) { | 405 | list_for_each_entry_safe(page, next, &hugepage_freelists[i], lru) { |
406 | if (count >= nr_huge_pages) | ||
407 | return; | ||
406 | if (PageHighMem(page)) | 408 | if (PageHighMem(page)) |
407 | continue; | 409 | continue; |
408 | list_del(&page->lru); | 410 | list_del(&page->lru); |
409 | update_and_free_page(page); | 411 | update_and_free_page(page); |
410 | free_huge_pages--; | 412 | free_huge_pages--; |
411 | free_huge_pages_node[page_to_nid(page)]--; | 413 | free_huge_pages_node[page_to_nid(page)]--; |
412 | if (count >= nr_huge_pages) | ||
413 | return; | ||
414 | } | 414 | } |
415 | } | 415 | } |
416 | } | 416 | } |
@@ -450,8 +450,6 @@ static unsigned long set_max_huge_pages(unsigned long count) | |||
450 | goto out; | 450 | goto out; |
451 | 451 | ||
452 | } | 452 | } |
453 | if (count >= persistent_huge_pages) | ||
454 | goto out; | ||
455 | 453 | ||
456 | /* | 454 | /* |
457 | * Decrease the pool size | 455 | * Decrease the pool size |
@@ -460,7 +458,8 @@ static unsigned long set_max_huge_pages(unsigned long count) | |||
460 | * pages into surplus state as needed so the pool will shrink | 458 | * pages into surplus state as needed so the pool will shrink |
461 | * to the desired size as pages become free. | 459 | * to the desired size as pages become free. |
462 | */ | 460 | */ |
463 | min_count = max(count, resv_huge_pages); | 461 | min_count = resv_huge_pages + nr_huge_pages - free_huge_pages; |
462 | min_count = max(count, min_count); | ||
464 | try_to_free_low(min_count); | 463 | try_to_free_low(min_count); |
465 | while (min_count < persistent_huge_pages) { | 464 | while (min_count < persistent_huge_pages) { |
466 | struct page *page = dequeue_huge_page(NULL, 0); | 465 | struct page *page = dequeue_huge_page(NULL, 0); |