Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1157920

[PATCHv6 06/36] mm: handle PTE-mapped tail pages in gerneric fast gup implementaiton

From "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Newsgroups linux.kernel
Subject [PATCHv6 06/36] mm: handle PTE-mapped tail pages in gerneric fast gup implementaiton
Date 2015-06-03 19:20 +0200
Message-ID <pxkuF-7Ey-73@gated-at.bofh.it> (permalink)
References <pxkkW-7sr-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


With new refcounting we are going to see THP tail pages mapped with PTE.
Generic fast GUP rely on page_cache_get_speculative() to obtain
reference on page. page_cache_get_speculative() always fails on tail
pages, because ->_count on tail pages is always zero.

Let's handle tail pages in gup_pte_range().

New split_huge_page() will rely on migration entries to freeze page's
counts. Recheck PTE value after page_cache_get_speculative() on head
page should be enough to serialize against split.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Tested-by: Sasha Levin <sasha.levin@oracle.com>
Acked-by: Jerome Marchand <jmarchan@redhat.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
---
 mm/gup.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mm/gup.c b/mm/gup.c
index 2dd6706ea29f..d975bdc2465f 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1051,7 +1051,7 @@ static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end,
 		 * for an example see gup_get_pte in arch/x86/mm/gup.c
 		 */
 		pte_t pte = READ_ONCE(*ptep);
-		struct page *page;
+		struct page *head, *page;
 
 		/*
 		 * Similar to the PMD case below, NUMA hinting must take slow
@@ -1063,15 +1063,17 @@ static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end,
 
 		VM_BUG_ON(!pfn_valid(pte_pfn(pte)));
 		page = pte_page(pte);
+		head = compound_head(page);
 
-		if (!page_cache_get_speculative(page))
+		if (!page_cache_get_speculative(head))
 			goto pte_unmap;
 
 		if (unlikely(pte_val(pte) != pte_val(*ptep))) {
-			put_page(page);
+			put_page(head);
 			goto pte_unmap;
 		}
 
+		VM_BUG_ON_PAGE(compound_head(page) != head, page);
 		pages[*nr] = page;
 		(*nr)++;
 
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCHv6 00/36] THP refcounting redesign "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:10 +0200
  [PATCHv6 12/36] thp: drop all split_huge_page()-related code "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:10 +0200
  [PATCHv6 18/36] arm, thp: remove infrastructure for handling splitting PMDs "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:10 +0200
  [PATCHv6 01/36] mm, proc: adjust PSS calculation "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:10 +0200
  [PATCHv6 28/36] mm, numa: skip PTE-mapped THP on numa fault "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:10 +0200
  [PATCHv6 02/36] rmap: add argument to charge compound page "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:10 +0200
  [PATCHv6 24/36] x86, thp: remove infrastructure for handling splitting PMDs "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:20 +0200
  [PATCHv6 08/36] khugepaged: ignore pmd tables with THP mapped with ptes "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:20 +0200
  [PATCHv6 19/36] mips, thp: remove infrastructure for handling splitting PMDs "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:20 +0200
  [PATCHv6 33/36] migrate_pages: try to split pages on qeueuing "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:20 +0200
  [PATCHv6 13/36] mm: drop tail page refcounting "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:20 +0200
  [PATCHv6 27/36] mm: differentiate page_mapped() from page_mapcount() for compound pages "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:20 +0200
  [PATCHv6 32/36] thp: reintroduce split_huge_page() "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:20 +0200
  [PATCHv6 21/36] s390, thp: remove infrastructure for handling splitting PMDs "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:20 +0200
  [PATCHv6 29/36] thp: implement split_huge_pmd() "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:20 +0200
  [PATCHv6 20/36] powerpc, thp: remove infrastructure for handling splitting PMDs "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:20 +0200
  [PATCHv6 17/36] arm64, thp: remove infrastructure for handling splitting PMDs "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:20 +0200
  [PATCHv6 34/36] thp: introduce deferred_split_huge_page() "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:20 +0200
  [PATCHv6 30/36] thp: add option to setup migration entiries during PMD split "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:20 +0200
  [PATCHv6 10/36] mm, vmstats: new THP splitting event "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:20 +0200
  [PATCHv6 23/36] tile, thp: remove infrastructure for handling splitting PMDs "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:20 +0200
  [PATCHv6 06/36] mm: handle PTE-mapped tail pages in gerneric fast gup implementaiton "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:20 +0200
  [PATCHv6 31/36] thp, mm: split_huge_page(): caller need to lock page "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:20 +0200
  [PATCHv6 35/36] mm: re-enable THP "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:20 +0200
  [PATCHv6 16/36] mm, thp: remove compound_lock "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-06-03 19:20 +0200

csiph-web