aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/mm/hugetlbpage.c
diff options
context:
space:
mode:
authorAndrea Arcangeli <aarcange@redhat.com>2011-11-02 16:37:15 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-11-02 19:06:57 -0400
commit3526741f0964c88bc2ce511e1078359052bf225b (patch)
treed651d4826523ffeebc92e7863a918de955c15840 /arch/powerpc/mm/hugetlbpage.c
parent8596468487e2062cae2aad56e973784e03959245 (diff)
powerpc: gup_hugepte() support THP based tail recounting
Up to this point the code assumed old refcounting for hugepages (pre-thp). This updates the code directly to the thp mapcount tail page refcounting. Signed-off-by: Andrea Arcangeli <aarcange@redhat.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Hugh Dickins <hughd@google.com> Cc: Johannes Weiner <jweiner@redhat.com> Cc: Rik van Riel <riel@redhat.com> Cc: Mel Gorman <mgorman@suse.de> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/powerpc/mm/hugetlbpage.c')
-rw-r--r--arch/powerpc/mm/hugetlbpage.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index 78b14abded65..a618ef01bfad 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -385,12 +385,23 @@ follow_huge_pmd(struct mm_struct *mm, unsigned long address,
385 return NULL; 385 return NULL;
386} 386}
387 387
388static inline void get_huge_page_tail(struct page *page)
389{
390 /*
391 * __split_huge_page_refcount() cannot run
392 * from under us.
393 */
394 VM_BUG_ON(page_mapcount(page) < 0);
395 VM_BUG_ON(atomic_read(&page->_count) != 0);
396 atomic_inc(&page->_mapcount);
397}
398
388static noinline int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr, 399static noinline int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr,
389 unsigned long end, int write, struct page **pages, int *nr) 400 unsigned long end, int write, struct page **pages, int *nr)
390{ 401{
391 unsigned long mask; 402 unsigned long mask;
392 unsigned long pte_end; 403 unsigned long pte_end;
393 struct page *head, *page; 404 struct page *head, *page, *tail;
394 pte_t pte; 405 pte_t pte;
395 int refs; 406 int refs;
396 407
@@ -413,6 +424,7 @@ static noinline int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long add
413 head = pte_page(pte); 424 head = pte_page(pte);
414 425
415 page = head + ((addr & (sz-1)) >> PAGE_SHIFT); 426 page = head + ((addr & (sz-1)) >> PAGE_SHIFT);
427 tail = page;
416 do { 428 do {
417 VM_BUG_ON(compound_head(page) != head); 429 VM_BUG_ON(compound_head(page) != head);
418 pages[*nr] = page; 430 pages[*nr] = page;
@@ -431,6 +443,16 @@ static noinline int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long add
431 *nr -= refs; 443 *nr -= refs;
432 while (refs--) 444 while (refs--)
433 put_page(head); 445 put_page(head);
446 } else {
447 /*
448 * Any tail page need their mapcount reference taken
449 * before we return.
450 */
451 while (refs--) {
452 if (PageTail(tail))
453 get_huge_page_tail(tail);
454 tail++;
455 }
434 } 456 }
435 457
436 return 1; 458 return 1;