Skip to content

Commit d670ffd

Browse files
kvaneeshtorvalds
authored andcommitted
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 BUG: non-zero nr_ptes on freeing mm: 3 Fixes: 953c66c ("mm: THP page cache support for ppc64") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Aneesh Kumar K.V <[email protected]> Acked-by: Kirill A. Shutemov <[email protected]> Cc: Michael Ellerman <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 965d004 commit d670ffd

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

mm/khugepaged.c

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,6 @@ static void retract_page_tables(struct address_space *mapping, pgoff_t pgoff)
12421242
struct vm_area_struct *vma;
12431243
unsigned long addr;
12441244
pmd_t *pmd, _pmd;
1245-
bool deposited = false;
12461245

12471246
i_mmap_lock_write(mapping);
12481247
vma_interval_tree_foreach(vma, &mapping->i_mmap, pgoff, pgoff) {
@@ -1267,26 +1266,10 @@ static void retract_page_tables(struct address_space *mapping, pgoff_t pgoff)
12671266
spinlock_t *ptl = pmd_lock(vma->vm_mm, pmd);
12681267
/* assume page table is clear */
12691268
_pmd = pmdp_collapse_flush(vma, addr, pmd);
1270-
/*
1271-
* now deposit the pgtable for arch that need it
1272-
* otherwise free it.
1273-
*/
1274-
if (arch_needs_pgtable_deposit()) {
1275-
/*
1276-
* The deposit should be visibile only after
1277-
* collapse is seen by others.
1278-
*/
1279-
smp_wmb();
1280-
pgtable_trans_huge_deposit(vma->vm_mm, pmd,
1281-
pmd_pgtable(_pmd));
1282-
deposited = true;
1283-
}
12841269
spin_unlock(ptl);
12851270
up_write(&vma->vm_mm->mmap_sem);
1286-
if (!deposited) {
1287-
atomic_long_dec(&vma->vm_mm->nr_ptes);
1288-
pte_free(vma->vm_mm, pmd_pgtable(_pmd));
1289-
}
1271+
atomic_long_dec(&vma->vm_mm->nr_ptes);
1272+
pte_free(vma->vm_mm, pmd_pgtable(_pmd));
12901273
}
12911274
}
12921275
i_mmap_unlock_write(mapping);

0 commit comments

Comments
 (0)