linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mm/thp/pagecache: Only withdraw page table after a successful deposit
@ 2016-12-12 16:34 Aneesh Kumar K.V
  2016-12-12 16:34 ` [PATCH 2/2] mm/thp/pagecache/collapse: Free the pte page table on collapse for thp page cache Aneesh Kumar K.V
  2016-12-12 21:01 ` [PATCH 1/2] mm/thp/pagecache: Only withdraw page table after a successful deposit Kirill A. Shutemov
  0 siblings, 2 replies; 4+ messages in thread
From: Aneesh Kumar K.V @ 2016-12-12 16:34 UTC (permalink / raw)
  To: akpm, Kirill A . Shutemov, mpe; +Cc: linux-mm, linux-kernel, Aneesh Kumar K.V

The current code wrongly called withdraw in the error path. But we
haven't depoisted the page table yet in the only error path in that
function. So for now remove that withdraw completely. If we take
that "out:" branch, we should have vmf->prealloc_pte already pointing
to the allocated page table.

Fixes: "mm: THP page cache support for ppc64"

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 mm/memory.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index 455c3e628d52..36c774f9259e 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3008,13 +3008,6 @@ static int do_set_pmd(struct vm_fault *vmf, struct page *page)
 	ret = 0;
 	count_vm_event(THP_FILE_MAPPED);
 out:
-	/*
-	 * If we are going to fallback to pte mapping, do a
-	 * withdraw with pmd lock held.
-	 */
-	if (arch_needs_pgtable_deposit() && ret == VM_FAULT_FALLBACK)
-		vmf->prealloc_pte = pgtable_trans_huge_withdraw(vma->vm_mm,
-								vmf->pmd);
 	spin_unlock(vmf->ptl);
 	return ret;
 }
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] mm/thp/pagecache/collapse: Free the pte page table on collapse for thp page cache.
  2016-12-12 16:34 [PATCH 1/2] mm/thp/pagecache: Only withdraw page table after a successful deposit Aneesh Kumar K.V
@ 2016-12-12 16:34 ` Aneesh Kumar K.V
  2016-12-12 21:02   ` Kirill A. Shutemov
  2016-12-12 21:01 ` [PATCH 1/2] mm/thp/pagecache: Only withdraw page table after a successful deposit Kirill A. Shutemov
  1 sibling, 1 reply; 4+ messages in thread
From: Aneesh Kumar K.V @ 2016-12-12 16:34 UTC (permalink / raw)
  To: akpm, Kirill A . Shutemov, mpe; +Cc: linux-mm, linux-kernel, Aneesh Kumar K.V

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:"mm: THP page cache support for ppc64"

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 mm/khugepaged.c | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 7434a63cac94..4e0914849e55 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1242,7 +1242,6 @@ static void retract_page_tables(struct address_space *mapping, pgoff_t pgoff)
 	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 address_space *mapping, pgoff_t pgoff)
 			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);
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] mm/thp/pagecache: Only withdraw page table after a successful deposit
  2016-12-12 16:34 [PATCH 1/2] mm/thp/pagecache: Only withdraw page table after a successful deposit Aneesh Kumar K.V
  2016-12-12 16:34 ` [PATCH 2/2] mm/thp/pagecache/collapse: Free the pte page table on collapse for thp page cache Aneesh Kumar K.V
@ 2016-12-12 21:01 ` Kirill A. Shutemov
  1 sibling, 0 replies; 4+ messages in thread
From: Kirill A. Shutemov @ 2016-12-12 21:01 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: akpm, Kirill A . Shutemov, mpe, linux-mm, linux-kernel

On Mon, Dec 12, 2016 at 10:04:27PM +0530, Aneesh Kumar K.V wrote:
> The current code wrongly called withdraw in the error path. But we
> haven't depoisted the page table yet in the only error path in that
> function. So for now remove that withdraw completely. If we take
> that "out:" branch, we should have vmf->prealloc_pte already pointing
> to the allocated page table.
> 
> Fixes: "mm: THP page cache support for ppc64"
> 
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

Reported-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

-- 
 Kirill A. Shutemov

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] mm/thp/pagecache/collapse: Free the pte page table on collapse for thp page cache.
  2016-12-12 16:34 ` [PATCH 2/2] mm/thp/pagecache/collapse: Free the pte page table on collapse for thp page cache Aneesh Kumar K.V
@ 2016-12-12 21:02   ` Kirill A. Shutemov
  0 siblings, 0 replies; 4+ messages in thread
From: Kirill A. Shutemov @ 2016-12-12 21:02 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: akpm, Kirill A . Shutemov, mpe, linux-mm, linux-kernel

On Mon, Dec 12, 2016 at 10:04:28PM +0530, Aneesh Kumar K.V wrote:
> 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:"mm: THP page cache support for ppc64"
> 
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

-- 
 Kirill A. Shutemov

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-12-12 21:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-12 16:34 [PATCH 1/2] mm/thp/pagecache: Only withdraw page table after a successful deposit Aneesh Kumar K.V
2016-12-12 16:34 ` [PATCH 2/2] mm/thp/pagecache/collapse: Free the pte page table on collapse for thp page cache Aneesh Kumar K.V
2016-12-12 21:02   ` Kirill A. Shutemov
2016-12-12 21:01 ` [PATCH 1/2] mm/thp/pagecache: Only withdraw page table after a successful deposit Kirill A. Shutemov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).