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=-6.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,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 9036DC4727F for ; Tue, 29 Sep 2020 00:18:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1D1292075A for ; Tue, 29 Sep 2020 00:18:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="Ip0+ASZj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1D1292075A 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 3FFB76B005C; Mon, 28 Sep 2020 20:18:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3B0CD6B005D; Mon, 28 Sep 2020 20:18:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A0486B0062; Mon, 28 Sep 2020 20:18:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0008.hostedemail.com [216.40.44.8]) by kanga.kvack.org (Postfix) with ESMTP id 116346B005C for ; Mon, 28 Sep 2020 20:18:51 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id CBB5745B3 for ; Tue, 29 Sep 2020 00:18:50 +0000 (UTC) X-FDA: 77314188420.23.brake26_5a01ecd27185 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id A57A837606 for ; Tue, 29 Sep 2020 00:18:50 +0000 (UTC) X-HE-Tag: brake26_5a01ecd27185 X-Filterd-Recvd-Size: 4945 Received: from hqnvemgate26.nvidia.com (hqnvemgate26.nvidia.com [216.228.121.65]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Tue, 29 Sep 2020 00:18:50 +0000 (UTC) Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Mon, 28 Sep 2020 17:18:36 -0700 Received: from [10.2.53.30] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 29 Sep 2020 00:18:48 +0000 Subject: Re: [PATCH 1/5] mm: Introduce mm_struct.has_pinned To: Jason Gunthorpe , Linus Torvalds CC: Peter Xu , Leon Romanovsky , Linux-MM , Linux Kernel Mailing List , Andrew Morton , Jan Kara , Michal Hocko , Kirill Tkhai , Kirill Shutemov , Hugh Dickins , Christoph Hellwig , Andrea Arcangeli , Oleg Nesterov , Jann Horn References: <20200927062337.GE2280698@unreal> <20200928124937.GN9916@ziepe.ca> <20200928172256.GB59869@xz-x1> <20200928183928.GR9916@ziepe.ca> <20200928235739.GU9916@ziepe.ca> From: John Hubbard Message-ID: <6c1292e6-11f0-811c-6cdd-cfc1f4bccbc2@nvidia.com> Date: Mon, 28 Sep 2020 17:18:47 -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: <20200928235739.GU9916@ziepe.ca> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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=1601338716; bh=jmpEGsoMCEZFctwNCe64tE1wCWqRXRFpjk0kPlELp9U=; 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=Ip0+ASZj36jbq8s5v/IRZrxCWxN7x9Ajr9pKiIngaoMWvezVaC+2qD1ODDIaqoAZM 3c4N8uS+/i2iohuT+Xo9cXMyOlM0UgLf31nnbgUJ/kf5zWp/8DYtIkZXQYNy9vGcVp kIH9y6/2LnfRWNs+j8p3ccNk5rKULE9A7/s5iNEwZV+7nTQE8E/YFL4BVzIEbSnQNy l52c4dfm475LxdYswpYaGNs9znw/AA3hqQTBBSxrhGO2qasfHkAuf9gFoA9na/Y/aS RtZdcAu/RlRBVcdKhQfV0XV9CpY+uvVdbHtnatZHcL7Vmr6Owys6x6maLO3Vt8DGnG edzvpmBLkJRJw== 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 9/28/20 4:57 PM, Jason Gunthorpe wrote: > On Mon, Sep 28, 2020 at 12:29:55PM -0700, Linus Torvalds wrote: ... > I think this is really hard to use and ugly. My thinking has been to > just stick: > > if (flags & FOLL_LONGTERM) > flags |= FOLL_FORCE | FOLL_WRITE > > In pin_user_pages(). It would make the driver API cleaner. If we can +1, yes. The other choices so far are, as you say, really difficult to figure out. > do a bit better somehow by not COW'ing for certain VMA's as you > explained then all the better, but not my primary goal.. > > Basically, I think if a driver is using FOLL_LONGTERM | FOLL_PIN we > should guarentee that driver a consistent MM and take the gup_fast > performance hit to do it. > > AFAICT the giant wack of other cases not using FOLL_LONGTERM really > shouldn't care about read-decoherence. For those cases the user should > really not be racing write's with data under read-only pin, and the > new COW logic looks like it solves the other issues with this. I hope this doesn't kill the seqcount() idea, though. That was my favorite part of the discussion, because it neatly separates out the two racing domains (fork, gup/pup) and allows easy reasoning about them--without really impacting performance. Truly elegant. We should go there. > > I know Jann/John have been careful to not have special behaviors for > the DMA case, but I think it makes sense here. It is actually different. > I think that makes sense. Everyone knew that DMA/FOLL_LONGTERM call sites were at least potentially special, despite the spirited debates in at least two conferences about the meaning and implications of "long term". :) And here we are seeing an example of such a special case, which I think is natural enough. thanks, -- John Hubbard NVIDIA