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=-2.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no 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 2903BCA9EB5 for ; Mon, 4 Nov 2019 21:02:09 +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 C564E20717 for ; Mon, 4 Nov 2019 21:02:08 +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="lpq+hNDu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C564E20717 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 bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 476QGN1VwmzF1QY for ; Tue, 5 Nov 2019 08:02:04 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nvidia.com (client-ip=216.228.121.64; helo=hqemgate15.nvidia.com; envelope-from=jhubbard@nvidia.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=nvidia.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=nvidia.com header.i=@nvidia.com header.b="lpq+hNDu"; dkim-atps=neutral Received: from hqemgate15.nvidia.com (hqemgate15.nvidia.com [216.228.121.64]) (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 476Q9m5yh1zF3S3 for ; Tue, 5 Nov 2019 07:58:04 +1100 (AEDT) Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 04 Nov 2019 12:58:05 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Mon, 04 Nov 2019 12:58:00 -0800 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Mon, 04 Nov 2019 12:58:00 -0800 Received: from [10.110.48.28] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 4 Nov 2019 20:57:59 +0000 Subject: Re: [PATCH v2 05/18] mm/gup: introduce pin_user_pages*() and FOLL_PIN To: Jason Gunthorpe , Jerome Glisse References: <20191103211813.213227-1-jhubbard@nvidia.com> <20191103211813.213227-6-jhubbard@nvidia.com> <20191104173325.GD5134@redhat.com> <20191104191811.GI5134@redhat.com> <20191104195248.GA7731@redhat.com> <25ec4bc0-caaa-2a01-2ae7-2d79663a40e1@nvidia.com> <20191104203153.GB7731@redhat.com> <20191104203702.GG30938@ziepe.ca> From: John Hubbard X-Nvconfidentiality: public Message-ID: Date: Mon, 4 Nov 2019 12:57:59 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20191104203702.GG30938@ziepe.ca> 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" Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1572901085; bh=EeK8bqsNfSA5i7MZV/85JI1lVmfCUv+TJ9yPJIg8GiI=; 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=lpq+hNDuPjPGBUnT+FF2AdBK4cieUl5iRoSXMbtLj+P8mC+Low0gZFUsCOCxgU9/5 DdN9/T6chOJfP5oOBc8usBmdwuRtBNEQH4F7VlCn14TGG0/SlwreoVfvdvj6xqa7/3 xeHneHSfMu5jFDq4HQuon77rSHBRD8GfWw0oGJaIFrobzmVoV/9zRJnxBAubrZjXN1 WRTqAeLXVE2rRthei7hHQyxBdSu2WAGq/7R/BGkZOAo7GutRRc+/9GEeCURW6eoDae GFMlg2H2OK77XEEdt9PJrYvhIFYSBbOCAEQEdwBZOgkHGbaoMuenGmkX8oXc5haoCl DibI+5WsHAIGw== 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 , Jan Kara , kvm@vger.kernel.org, linux-doc@vger.kernel.org, David Airlie , Dave Chinner , dri-devel@lists.freedesktop.org, linux-mm@kvack.org, Paul Mackerras , linux-kselftest@vger.kernel.org, Shuah Khan , Jonathan Corbet , linux-rdma@vger.kernel.org, Christoph Hellwig , Vlastimil Babka , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , linux-media@vger.kernel.org, Ira Weiny , linux-block@vger.kernel.org, Alex Williamson , Al Viro , Dan Williams , Mauro Carvalho Chehab , bpf@vger.kernel.org, Magnus Karlsson , Jens Axboe , netdev@vger.kernel.org, LKML , Daniel Vetter , linux-fsdevel@vger.kernel.org, Andrew Morton , linuxppc-dev@lists.ozlabs.org, "David S . Miller" , Mike Kravetz Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On 11/4/19 12:37 PM, Jason Gunthorpe wrote: > On Mon, Nov 04, 2019 at 03:31:53PM -0500, Jerome Glisse wrote: >>> Note for Jason: the (a) or (b) items are talking about the vfio case, which is >>> one of the two call sites that now use pin_longterm_pages_remote(), and the >>> other one is infiniband: >>> >>> drivers/infiniband/core/umem_odp.c:646: npages = pin_longterm_pages_remote(owning_process, owning_mm, >>> drivers/vfio/vfio_iommu_type1.c:353: ret = pin_longterm_pages_remote(NULL, mm, vaddr, 1, >> >> vfio should be reverted until it can be properly implemented. >> The issue is that when you fix the implementation you might >> break vfio existing user and thus regress the kernel from user >> point of view. So i rather have the change to vfio reverted, >> i believe it was not well understood when it got upstream, >> between in my 5.4 tree it is still gup_remote not longterm. > > It is clearly a bug, vfio must use LONGTERM, and does right above this > remote call: > > if (mm == current->mm) { > ret = get_user_pages(vaddr, 1, flags | FOLL_LONGTERM, page, > vmas); > } else { > ret = get_user_pages_remote(NULL, mm, vaddr, 1, flags, page, > vmas, NULL); > > > I'm not even sure that it really makes any sense to build a 'if' like > that, surely just always call remote?? > Right, and I thought about this when converting, and realized that the above code is working around the current gup.c limitations, which are "cannot support gup remote with FOLL_LONGTERM". Given that observation, the code is getting itself some FOLL_LONGTERM support for the non-remote case, and only hitting the limitation if the mm really is non-current. And if you look at my patch, it keeps the same behavior, while adding in the new wrapper calls. So...thoughts, preferences? thanks, John Hubbard NVIDIA