Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4448874ybx; Mon, 4 Nov 2019 13:35:11 -0800 (PST) X-Google-Smtp-Source: APXvYqxYvfAzDlCtp/UzHovR+DlHdPIDZQyhHuOO1ZdsuE0CnnuRyh0i4P6wcaNmLuPG54F+3NRQ X-Received: by 2002:aa7:c34c:: with SMTP id j12mr31702695edr.175.1572903311102; Mon, 04 Nov 2019 13:35:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572903311; cv=none; d=google.com; s=arc-20160816; b=y8DqlsuvVLhDY2sdGzUO3OkS6RNMQrAAEgcoYnxLVEMtUklQaTxkpiMdflEp7XbbMK AiKUhYvg+tWPrbnubbx+Iq6vzGtZIqMckdFsH22HIhBTScumylnrOqhfifP6Ve+Hgksb /oq/HQheKQNQ/0tOY2H7cbtVDAdlH3daJfO+hGQ2Lq5jmP2HE9ehy9laAJGcuO7K28fF PhthbLftJoVy5h6jGh0Ke4hVBD2EAyPiJRh3mcyLHWRxYa04lnWv6NKwrLjDCiDbxcvb kTJ72rHclBrmGgbS8xbF6F3eAoCJfYBgJWTkNSsUlXvrwJ6obepX47/YcGKvAU0X1wH1 TMbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=vbo/OzrYq7woOdeOQXzDRocZ8qkmDZ2GrWck8Ge0GIw=; b=L0ieNu+EAk2lo7zNVw7DZsJmV3EexX60fgxVVMogPpqzPM9TnaRVUOlRm2UFIuXp3k LGva+gIsh+2gOhkktDzskUvLHVEVQhxYnN+reJK6H1sK4EHSDqMzb2ifWRoO4s1YG5W0 RT1/8cr+fpnmAj3uZXE+6DV+7hCilMWDmdHYfwBi8Lv6G872p5fC+8OwbTuhoCls3Kok Da3sNcsaVMTxtGCSjB+xKda/BvBYRdeg+UvnQmNnz1l0zXCGDCczmw4rduPHadwhZAdK +3+vjCFE5nPas0q0ySkZJX7zx1hf/oE3vycPqON4COCv2jDhukZAxfIQPs6O/8K6AXLi X4XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=qKL2SABn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m20si9822797ejb.302.2019.11.04.13.34.46; Mon, 04 Nov 2019 13:35:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=qKL2SABn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729689AbfKDVeL (ORCPT + 99 others); Mon, 4 Nov 2019 16:34:11 -0500 Received: from hqemgate15.nvidia.com ([216.228.121.64]:10442 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728602AbfKDVeK (ORCPT ); Mon, 4 Nov 2019 16:34:10 -0500 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 13:34:10 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Mon, 04 Nov 2019 13:34:05 -0800 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Mon, 04 Nov 2019 13:34:05 -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 21:34:05 +0000 Subject: Re: [PATCH v2 05/18] mm/gup: introduce pin_user_pages*() and FOLL_PIN To: Jason Gunthorpe CC: Jerome Glisse , Andrew Morton , Al Viro , Alex Williamson , Benjamin Herrenschmidt , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Christoph Hellwig , Dan Williams , Daniel Vetter , Dave Chinner , David Airlie , "David S . Miller" , Ira Weiny , Jan Kara , Jens Axboe , Jonathan Corbet , Magnus Karlsson , Mauro Carvalho Chehab , Michael Ellerman , Michal Hocko , Mike Kravetz , Paul Mackerras , Shuah Khan , Vlastimil Babka , , , , , , , , , , , , , LKML References: <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> <20191104211525.GJ30938@ziepe.ca> From: John Hubbard X-Nvconfidentiality: public Message-ID: Date: Mon, 4 Nov 2019 13:34:04 -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: <20191104211525.GJ30938@ziepe.ca> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) 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=1572903250; bh=vbo/OzrYq7woOdeOQXzDRocZ8qkmDZ2GrWck8Ge0GIw=; 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=qKL2SABndBuE0IlTwGECBEmaXKNt9+NUVq+WFlqtOQFVTiU7nDI02BQTOx0obKarz gpxOM5Y6JautiKfOu0FtwOKOgDIpCUi5YMn9VF5RbTl9cVhlQsO6c44+kqa1Gmkh8J VEKyKNOG6Vqk5nkQbEsBguPgBI2Ja3iUp52oe4dwNevVkVV3ApvpTePgu21U23nzfu yfLLAmDkD5PCoZMaxqbgr1s6DM7hOxhvmTI1aiChbyJF4tpKtWS0fJG0BnHlBMS2gJ uFSIwTdydwTYYvW23EYrvHjEOYVqNSM3f00rEJ3//HPrJcaJAle1+bmyry6JSVv/h0 e3DYAyiBVB40w== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/4/19 1:15 PM, Jason Gunthorpe wrote: ... >> 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". > > But AFAICT it doesn't have a problem, the protection test is just too > strict, and I guess the control flow needs a bit of fixing.. > > The issue is this: > > static __always_inline long __get_user_pages_locked(): > { > if (locked) { > /* if VM_FAULT_RETRY can be returned, vmas become invalid */ > BUG_ON(vmas); > /* check caller initialized locked */ > BUG_ON(*locked != 1); > } > > > so remote could be written as: > > if (gup_flags & FOLL_LONGTERM) { > if (WARN_ON_ONCE(locked)) > return -EINVAL; > return __gup_longterm_locked(...) > } > > return __get_user_pages_locked(...) > > ?? Yes, that loosens it up just enough for the vfio case (which doesn't set "locked") to get through, great! OK, I'll put that (the above plus corresponding vfio fix) in a separate patch first. This should clear things up nicely. thanks, -- John Hubbard NVIDIA