diff options
Diffstat (limited to 'mm/hugetlb.c')
| -rw-r--r-- | mm/hugetlb.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 74c1b6b0b37b..51c9e2c01640 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c | |||
| @@ -401,12 +401,20 @@ static void return_unused_surplus_pages(unsigned long unused_resv_pages) | |||
| 401 | struct page *page; | 401 | struct page *page; |
| 402 | unsigned long nr_pages; | 402 | unsigned long nr_pages; |
| 403 | 403 | ||
| 404 | /* | ||
| 405 | * We want to release as many surplus pages as possible, spread | ||
| 406 | * evenly across all nodes. Iterate across all nodes until we | ||
| 407 | * can no longer free unreserved surplus pages. This occurs when | ||
| 408 | * the nodes with surplus pages have no free pages. | ||
| 409 | */ | ||
| 410 | unsigned long remaining_iterations = num_online_nodes(); | ||
| 411 | |||
| 404 | /* Uncommit the reservation */ | 412 | /* Uncommit the reservation */ |
| 405 | resv_huge_pages -= unused_resv_pages; | 413 | resv_huge_pages -= unused_resv_pages; |
| 406 | 414 | ||
| 407 | nr_pages = min(unused_resv_pages, surplus_huge_pages); | 415 | nr_pages = min(unused_resv_pages, surplus_huge_pages); |
| 408 | 416 | ||
| 409 | while (nr_pages) { | 417 | while (remaining_iterations-- && nr_pages) { |
| 410 | nid = next_node(nid, node_online_map); | 418 | nid = next_node(nid, node_online_map); |
| 411 | if (nid == MAX_NUMNODES) | 419 | if (nid == MAX_NUMNODES) |
| 412 | nid = first_node(node_online_map); | 420 | nid = first_node(node_online_map); |
| @@ -424,6 +432,7 @@ static void return_unused_surplus_pages(unsigned long unused_resv_pages) | |||
| 424 | surplus_huge_pages--; | 432 | surplus_huge_pages--; |
| 425 | surplus_huge_pages_node[nid]--; | 433 | surplus_huge_pages_node[nid]--; |
| 426 | nr_pages--; | 434 | nr_pages--; |
| 435 | remaining_iterations = num_online_nodes(); | ||
| 427 | } | 436 | } |
| 428 | } | 437 | } |
| 429 | } | 438 | } |
| @@ -671,9 +680,11 @@ int hugetlb_report_node_meminfo(int nid, char *buf) | |||
| 671 | { | 680 | { |
| 672 | return sprintf(buf, | 681 | return sprintf(buf, |
| 673 | "Node %d HugePages_Total: %5u\n" | 682 | "Node %d HugePages_Total: %5u\n" |
| 674 | "Node %d HugePages_Free: %5u\n", | 683 | "Node %d HugePages_Free: %5u\n" |
| 684 | "Node %d HugePages_Surp: %5u\n", | ||
| 675 | nid, nr_huge_pages_node[nid], | 685 | nid, nr_huge_pages_node[nid], |
| 676 | nid, free_huge_pages_node[nid]); | 686 | nid, free_huge_pages_node[nid], |
| 687 | nid, surplus_huge_pages_node[nid]); | ||
| 677 | } | 688 | } |
| 678 | 689 | ||
| 679 | /* Return the number pages of memory we physically have, in PAGE_SIZE units. */ | 690 | /* Return the number pages of memory we physically have, in PAGE_SIZE units. */ |
