From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BC8BC43603 for ; Thu, 12 Dec 2019 05:58:56 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B78EC24654 for ; Thu, 12 Dec 2019 05:58:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="lsWfVOx2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B78EC24654 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (unknown [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 47YNQj3ZcWzDqJt for ; Thu, 12 Dec 2019 16:58:53 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nvidia.com (client-ip=216.228.121.65; helo=hqnvemgate26.nvidia.com; envelope-from=jhubbard@nvidia.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=nvidia.com Received: from hqnvemgate26.nvidia.com (hqnvemgate26.nvidia.com [216.228.121.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 47YNNG3M72zDqsp for ; Thu, 12 Dec 2019 16:56:45 +1100 (AEDT) Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 11 Dec 2019 21:56:29 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Wed, 11 Dec 2019 21:56:36 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 11 Dec 2019 21:56:36 -0800 Received: from [10.2.165.195] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 12 Dec 2019 05:56:35 +0000 Subject: Re: [PATCH v9 23/25] mm/gup: track FOLL_PIN pages To: Jan Kara References: <20191211025318.457113-1-jhubbard@nvidia.com> <20191211025318.457113-24-jhubbard@nvidia.com> <20191211112807.GN1551@quack2.suse.cz> From: John Hubbard X-Nvconfidentiality: public Message-ID: Date: Wed, 11 Dec 2019 21:53:45 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 MIME-Version: 1.0 In-Reply-To: <20191211112807.GN1551@quack2.suse.cz> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1576130189; bh=WUvMFBOwsTbLT+9CzNbxGtAponFsFsmTJOyg8MjL8ds=; h=X-PGP-Universal:Subject:To:CC:References:From:X-Nvconfidentiality: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=lsWfVOx2mYuCSEqMXkqo0p3SpKqw9VwSL+20QlVcuyoMSELQtTCN0YxM6RzLVo9oa uq4Hl9KFn70q6l1bzqmgaiV5HLk4+H2168Aq1l5uWc+mWWgNKPzhftF1QMyxl40GPe nNNgDtbzvAru+MjxE1MbEaMe+90vfqRYKPVuX/JzejQXCe2EVI5eyYy9CwInRuqtjp 2idGFh4dXFAMfDwQiKAN1Pz/TUuUoswEkyfXdQEyWp7z5jAlzfpntkPH8s96FOaimZ 1olYa+8gPiG8ccYKitvEKwCbv3GPr0UXUD+T0zjEzw7D9d6fQ9awWSzCOfMJ4VZl20 16ivttgOjkh4A== X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michal Hocko , kvm@vger.kernel.org, linux-doc@vger.kernel.org, David Airlie , Dave Chinner , dri-devel@lists.freedesktop.org, LKML , linux-mm@kvack.org, Paul Mackerras , linux-kselftest@vger.kernel.org, Ira Weiny , Jonathan Corbet , linux-rdma@vger.kernel.org, Christoph Hellwig , Jason Gunthorpe , Vlastimil Babka , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , linux-media@vger.kernel.org, Shuah Khan , linux-block@vger.kernel.org, =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Al Viro , Dan Williams , Mauro Carvalho Chehab , bpf@vger.kernel.org, Magnus Karlsson , Jens Axboe , netdev@vger.kernel.org, Alex Williamson , Daniel Vetter , linux-fsdevel@vger.kernel.org, Andrew Morton , linuxppc-dev@lists.ozlabs.org, "David S . Miller" , "Kirill A . Shutemov" , Mike Kravetz Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On 12/11/19 3:28 AM, Jan Kara wrote: ... >=20 > The patch looks mostly good to me now. Just a few smaller comments below. >=20 >> Suggested-by: Jan Kara >> Suggested-by: J=C3=A9r=C3=B4me Glisse >> Reviewed-by: Jan Kara >> Reviewed-by: J=C3=A9r=C3=B4me Glisse >> Reviewed-by: Ira Weiny >=20 > I think you inherited here the Reviewed-by tags from the "add flags" patc= h > you've merged into this one but that's not really fair since this patch > does much more... In particular I didn't give my Reviewed-by tag for this > patch yet. OK, I've removed those reviewed-by's. (I felt bad about dropping them, afte= r people had devoted time to reviewing, but I do see that it's wrong to imply that they've reviewed this much much larger thing.) ... >=20 > I somewhat wonder about the asymmetry of try_grab_compound_head() vs > try_grab_page() in the treatment of 'flags'. How costly would it be to ma= ke > them symmetric (i.e., either set FOLL_GET for try_grab_compound_head() > callers or make sure one of FOLL_GET, FOLL_PIN is set for try_grab_page()= )? >=20 > Because this difference looks like a subtle catch in the long run... Done. It is only a modest code-level change, at least the way I've done it,= which is setting FOLL_GET for try_grab_compound_head(). In order to do that, I set it at the top of the internal gup fast calling stacks, which is actually a = good design anyway: gup fast is logically doing FOLL_GET in all cases. So settin= g the flag internally is accurate and consistent with the overall design. > ... >=20 >> @@ -1522,8 +1536,8 @@ struct page *follow_trans_huge_pmd(struct vm_area_= struct *vma, >> skip_mlock: >> page +=3D (addr & ~HPAGE_PMD_MASK) >> PAGE_SHIFT; >> VM_BUG_ON_PAGE(!PageCompound(page) && !is_zone_device_page(page), pag= e); >> - if (flags & FOLL_GET) >> - get_page(page); >> + if (!try_grab_page(page, flags)) >> + page =3D ERR_PTR(-EFAULT); >=20 > I think you need to also move the try_grab_page() earlier in the function= . > At this point the page may be marked as mlocked and you'd need to undo th= at > in case try_grab_page() fails. OK, I've moved it up, adding a "subpage" variable in order to make that wor= k. >=20 >> diff --git a/mm/hugetlb.c b/mm/hugetlb.c >> index ac65bb5e38ac..0aab6fe0072f 100644 >> --- a/mm/hugetlb.c >> +++ b/mm/hugetlb.c >> @@ -4356,7 +4356,13 @@ long follow_hugetlb_page(struct mm_struct *mm, st= ruct vm_area_struct *vma, >> same_page: >> if (pages) { >> pages[i] =3D mem_map_offset(page, pfn_offset); >> - get_page(pages[i]); >> + if (!try_grab_page(pages[i], flags)) { >> + spin_unlock(ptl); >> + remainder =3D 0; >> + err =3D -ENOMEM; >> + WARN_ON_ONCE(1); >> + break; >> + } >> } >=20 > This function does a refcount overflow check early so that it doesn't hav= e > to do try_get_page() here. So that check can be now removed when you do > try_grab_page() here anyway since that early check seems to be just a tin= y > optimization AFAICT. >=20 > Honza >=20 Yes. I've removed it, good spot. thanks, --=20 John Hubbard NVIDIA