Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753730AbbD2P4Q (ORCPT ); Wed, 29 Apr 2015 11:56:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44411 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753669AbbD2P4M (ORCPT ); Wed, 29 Apr 2015 11:56:12 -0400 Message-ID: <5540FF16.1040302@redhat.com> Date: Wed, 29 Apr 2015 17:56:06 +0200 From: Jerome Marchand User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: "Kirill A. Shutemov" , Andrew Morton , Andrea Arcangeli , Hugh Dickins CC: Dave Hansen , Mel Gorman , Rik van Riel , Vlastimil Babka , Christoph Lameter , Naoya Horiguchi , Steve Capper , "Aneesh Kumar K.V" , Johannes Weiner , Michal Hocko , Sasha Levin , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCHv5 06/28] mm: handle PTE-mapped tail pages in gerneric fast gup implementaiton References: <1429823043-157133-1-git-send-email-kirill.shutemov@linux.intel.com> <1429823043-157133-7-git-send-email-kirill.shutemov@linux.intel.com> In-Reply-To: <1429823043-157133-7-git-send-email-kirill.shutemov@linux.intel.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Mr4KAS709sCE3X8HEOfGWFv2nUxsuwWOP" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3020 Lines: 89 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Mr4KAS709sCE3X8HEOfGWFv2nUxsuwWOP Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 04/23/2015 11:03 PM, Kirill A. Shutemov wrote: > With new refcounting we are going to see THP tail pages mapped with PTE= =2E > 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. >=20 > Let's handle tail pages in gup_pte_range(). >=20 > 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. >=20 > Signed-off-by: Kirill A. Shutemov > Tested-by: Sasha Levin Acked-by: Jerome Marchand > --- > mm/gup.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) >=20 > diff --git a/mm/gup.c b/mm/gup.c > index ebdb39b3e820..eaeeae15006b 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 =3D READ_ONCE(*ptep); > - struct page *page; > + struct page *head, *page; > =20 > /* > * Similar to the PMD case below, NUMA hinting must take slow > @@ -1063,15 +1063,17 @@ static int gup_pte_range(pmd_t pmd, unsigned lo= ng addr, unsigned long end, > =20 > VM_BUG_ON(!pfn_valid(pte_pfn(pte))); > page =3D pte_page(pte); > + head =3D compound_head(page); > =20 > - if (!page_cache_get_speculative(page)) > + if (!page_cache_get_speculative(head)) > goto pte_unmap; > =20 > if (unlikely(pte_val(pte) !=3D pte_val(*ptep))) { > - put_page(page); > + put_page(head); > goto pte_unmap; > } > =20 > + VM_BUG_ON_PAGE(compound_head(page) !=3D head, page); > pages[*nr] =3D page; > (*nr)++; > =20 >=20 --Mr4KAS709sCE3X8HEOfGWFv2nUxsuwWOP Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJVQP8WAAoJEHTzHJCtsuoCXBcH/iaIMxM2NinYqfL+c/kHezYB gt82/+WhQHkU0meCMreKPnc30c+xO7H8nTvipflj7s7qzoulmGuUSipOwkIXmQs+ ecOMqpaZYrNFl0JJ7MjrHVJKOZS6UKXT3vKxxfxX6uJLGmLB0ZkgutMZmPTGC30G z83PYfkXa2ySdclFnNDhxjljc+ltN/WtE8qDHttQlWBho2/NJFQgzQlwt/qmSCDt UWBA2LP4Oqe8OvkluGwLW9Z23qbPkK4NJ0SrLeKr6yCDVV5aD5QwckxAo18pjESl qgy0BKHKKWRk1l16xRccONMWLKKjSfSCK2YVl2ZHU8W37uC94DIGRFvdLBTpyFo= =5ibC -----END PGP SIGNATURE----- --Mr4KAS709sCE3X8HEOfGWFv2nUxsuwWOP-- -- 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/