The patch titled Subject: mm/thp/pagecache/collapse: free the pte page table on collapse for thp page cache. has been added to the -mm tree. Its filename is mm-thp-pagecache-collapse-free-the-pte-page-table-on-collapse-for-thp-page-cache.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-thp-pagecache-collapse-free-the-pte-page-table-on-collapse-for-thp-page-cache.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-thp-pagecache-collapse-free-the-pte-page-table-on-collapse-for-thp-page-cache.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: "Aneesh Kumar K.V" <aneesh.kumar@xxxxxxxxxxxxxxxxxx> Subject: mm/thp/pagecache/collapse: free the pte page table on collapse for thp page cache. With THP page cache, when trying to build a huge page from regular pte pages, we just clear the pmd entry. We will take another fault and at that point we will find the huge page in the radix tree, thereby using the huge page to complete the page fault The second fault path will allocate the needed pgtable_t page for archs like ppc64. So no need to deposit the same in collapse path. Depositing them in the collapse path resulting in a pgtable_t memory leak also giving errors like "[ 2362.021762] BUG: non-zero nr_ptes on freeing mm: 3" Fixes: 953c66c2b22a304d ("mm: THP page cache support for ppc64") Link: http://lkml.kernel.org/r/20161212163428.6780-2-aneesh.kumar@xxxxxxxxxxxxxxxxxx Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@xxxxxxxxxxxxxxxxxx> Acked-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> Cc: Michael Ellerman <mpe@xxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/khugepaged.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff -puN mm/khugepaged.c~mm-thp-pagecache-collapse-free-the-pte-page-table-on-collapse-for-thp-page-cache mm/khugepaged.c --- a/mm/khugepaged.c~mm-thp-pagecache-collapse-free-the-pte-page-table-on-collapse-for-thp-page-cache +++ a/mm/khugepaged.c @@ -1242,7 +1242,6 @@ static void retract_page_tables(struct a struct vm_area_struct *vma; unsigned long addr; pmd_t *pmd, _pmd; - bool deposited = false; i_mmap_lock_write(mapping); vma_interval_tree_foreach(vma, &mapping->i_mmap, pgoff, pgoff) { @@ -1267,26 +1266,10 @@ static void retract_page_tables(struct a spinlock_t *ptl = pmd_lock(vma->vm_mm, pmd); /* assume page table is clear */ _pmd = pmdp_collapse_flush(vma, addr, pmd); - /* - * now deposit the pgtable for arch that need it - * otherwise free it. - */ - if (arch_needs_pgtable_deposit()) { - /* - * The deposit should be visibile only after - * collapse is seen by others. - */ - smp_wmb(); - pgtable_trans_huge_deposit(vma->vm_mm, pmd, - pmd_pgtable(_pmd)); - deposited = true; - } spin_unlock(ptl); up_write(&vma->vm_mm->mmap_sem); - if (!deposited) { - atomic_long_dec(&vma->vm_mm->nr_ptes); - pte_free(vma->vm_mm, pmd_pgtable(_pmd)); - } + atomic_long_dec(&vma->vm_mm->nr_ptes); + pte_free(vma->vm_mm, pmd_pgtable(_pmd)); } } i_mmap_unlock_write(mapping); _ Patches currently in -mm which might be from aneesh.kumar@xxxxxxxxxxxxxxxxxx are mm-thp-pagecache-only-withdraw-page-table-after-a-successful-deposit.patch mm-thp-pagecache-collapse-free-the-pte-page-table-on-collapse-for-thp-page-cache.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html