Commit caff3a2c333e11a794308bd9a875a09b94fee24a

Authored by Gerald Schaefer
Committed by Linus Torvalds
1 parent 02eb7eeb89

hugetlb: call arch_prepare_hugepage() for surplus pages

The s390 software large page emulation implements shared page tables by
using page->index of the first tail page from a compound large page to
store page table information.  This is set up in arch_prepare_hugepage(),
which is called from alloc_fresh_huge_page_node().

A similar call to arch_prepare_hugepage() is missing for surplus large
pages that are allocated in alloc_buddy_huge_page(), which breaks the
software emulation mode for (surplus) large pages on s390.  This patch
adds the missing call to arch_prepare_hugepage().  It will have no effect
on other architectures where arch_prepare_hugepage() is a nop.

Also, use the correct order in the error path in alloc_fresh_huge_page_node().

Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Acked-by: Nick Piggin <npiggin@suse.de>
Acked-by: Adam Litke <agl@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 6 additions and 1 deletions Side-by-side Diff

... ... @@ -565,7 +565,7 @@
565 565 huge_page_order(h));
566 566 if (page) {
567 567 if (arch_prepare_hugepage(page)) {
568   - __free_pages(page, HUGETLB_PAGE_ORDER);
  568 + __free_pages(page, huge_page_order(h));
569 569 return NULL;
570 570 }
571 571 prep_new_huge_page(h, page, nid);
... ... @@ -664,6 +664,11 @@
664 664 page = alloc_pages(htlb_alloc_mask|__GFP_COMP|
665 665 __GFP_REPEAT|__GFP_NOWARN,
666 666 huge_page_order(h));
  667 +
  668 + if (page && arch_prepare_hugepage(page)) {
  669 + __free_pages(page, huge_page_order(h));
  670 + return NULL;
  671 + }
667 672  
668 673 spin_lock(&hugetlb_lock);
669 674 if (page) {