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=-11.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,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 B8C3EC4727D for ; Fri, 2 Oct 2020 22:39:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 42CFE206C9 for ; Fri, 2 Oct 2020 22:39:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="CkmG7p3e" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 42CFE206C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 52AEF6B0092; Fri, 2 Oct 2020 18:39:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DB876B0093; Fri, 2 Oct 2020 18:39:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C9516B0095; Fri, 2 Oct 2020 18:39:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 10EA56B0092 for ; Fri, 2 Oct 2020 18:39:24 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 9CBD9824999B for ; Fri, 2 Oct 2020 22:39:23 +0000 (UTC) X-FDA: 77328453006.06.wine25_0013ca4271a7 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id 75B99100D96D8 for ; Fri, 2 Oct 2020 22:39:23 +0000 (UTC) X-HE-Tag: wine25_0013ca4271a7 X-Filterd-Recvd-Size: 5186 Received: from hqnvemgate26.nvidia.com (hqnvemgate26.nvidia.com [216.228.121.65]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Fri, 2 Oct 2020 22:39:22 +0000 (UTC) Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Fri, 02 Oct 2020 15:39:08 -0700 Received: from [10.2.58.214] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 2 Oct 2020 22:39:19 +0000 Subject: Re: [PATCH 2/2] mm/frame-vec: use FOLL_LONGTERM To: Daniel Vetter , DRI Development CC: LKML , Daniel Vetter , Andrew Morton , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Jan Kara , Dan Williams , , , , References: <20201002175303.390363-1-daniel.vetter@ffwll.ch> <20201002175303.390363-2-daniel.vetter@ffwll.ch> From: John Hubbard Message-ID: Date: Fri, 2 Oct 2020 15:39:18 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20201002175303.390363-2-daniel.vetter@ffwll.ch> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1601678348; bh=qTcrCkJDzdT8SfyK7qNOOJqSlCcdoBOSPBld3HipaxE=; h=Subject:To:CC:References:From:Message-ID:Date:User-Agent: MIME-Version:In-Reply-To:Content-Type:Content-Language: Content-Transfer-Encoding:X-Originating-IP:X-ClientProxiedBy; b=CkmG7p3e1gAyMtXXHaHX1wOW1NQeTx5EUso+tbSgFhrSp+8QrJgqKgpGph1U/WlJ9 qjs7wfNjzCdFazLpm35kI8ryUb4HAhQGO1YhRDZHuawuF1n/XklWptr0Oh+AMQAUjy jneLP0a9LWrTfebX3/q5vKRWI7xVqEgLJba7x3/ynwdacCPjlPBn92WcwSu6Cw0YiT eKgU9+6RSW0XQZenBoBjewsXMxc+aP2u4J0XqZOj1Y5gz6t/S5sXbW56buv0moU6ab JNDEx6uK4fFAQ92xLXRbzenGuHOo4jN8MNmfnLJi/k09pKguinMXh3euJYAOLgkYOa zfT3EJXtIkeRQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 10/2/20 10:53 AM, Daniel Vetter wrote: > For $reasons I've stumbled over this code and I'm not sure the change > to the new gup functions in 55a650c35fea ("mm/gup: frame_vector: > convert get_user_pages() --> pin_user_pages()") was entirely correct. >=20 > This here is used for long term buffers (not just quick I/O) like > RDMA, and John notes this in his patch. But I thought the rule for > these is that they need to add FOLL_LONGTERM, which John's patch > didn't do. Yep. The earlier gup --> pup conversion patches were intended to not have any noticeable behavior changes, and FOLL_LONGTERM, with it's special cases and such, added some risk that I wasn't ready to take on yet. Also, FOLL_LONGTERM rules are only *recently* getting firmed up. So there was some doubt at least in my mind, about which sites should have it. But now that we're here, I think it's really good that you've brought this up. It's definitely time to add FOLL_LONGTERM wherever it's missing. thanks, --=20 John Hubbard NVIDIA >=20 > There is already a dax specific check (added in b7f0554a56f2 ("mm: > fail get_vaddr_frames() for filesystem-dax mappings")), so this seems > like the prudent thing to do. >=20 > Signed-off-by: Daniel Vetter > Cc: Andrew Morton > Cc: John Hubbard > Cc: J=C3=A9r=C3=B4me Glisse > Cc: Jan Kara > Cc: Dan Williams > Cc: linux-mm@kvack.org > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-samsung-soc@vger.kernel.org > Cc: linux-media@vger.kernel.org > --- > Hi all, >=20 > I stumbled over this and figured typing this patch can't hurt. Really > just to maybe learn a few things about how gup/pup is supposed to be > used (we have a bit of that in drivers/gpu), this here isn't really > ralated to anything I'm doing. >=20 > I'm also wondering whether the explicit dax check should be removed, > since FOLL_LONGTERM should take care of that already. > -Daniel > --- > mm/frame_vector.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/mm/frame_vector.c b/mm/frame_vector.c > index 5d34c9047e9c..3507e09cb3ff 100644 > --- a/mm/frame_vector.c > +++ b/mm/frame_vector.c > @@ -35,7 +35,7 @@ int get_vaddr_frames(unsigned long start, unsigned int = nr_frames, > { > struct mm_struct *mm =3D current->mm; > struct vm_area_struct *vma; > - unsigned int gup_flags =3D FOLL_WRITE | FOLL_FORCE; > + unsigned int gup_flags =3D FOLL_WRITE | FOLL_FORCE | FOLL_LONGTERM; > int ret =3D 0; > int err; > int locked; >=20