Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3406532pxk; Mon, 28 Sep 2020 17:22:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKEHJWzg8aqkLuDVqY6idFUSBUUBML+AC3DCpy2Ka6u6d3Z7RWZvR7KP3JiCy5IMFsJQyD X-Received: by 2002:a05:6402:b72:: with SMTP id cb18mr517977edb.299.1601338926028; Mon, 28 Sep 2020 17:22:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601338926; cv=none; d=google.com; s=arc-20160816; b=hjuURv7L9omT9ZjnZYxHvHe4LUfyoBGXLRhZUPjagNAwWym7CMZ8KJu0EHHkyWLlJ/ gXhsjz1c3bt0K2KiAR1nAJLl4BBQe83cFbchEGS985+JXIAyrglBYDp7I8xlnlmqlnlT OaWj9aIkqqk/H9uBOfSc84p5HTdQU5Hu9aWAilvqzP8jboacxYyCSS60GcPvDzext2L0 uo633jpW2KO1W0yfUjctxEeHmb4j7JVOlTM78s9GiEbVqNBE570BrzUIKkl0MW9JOlXw vkA1BsBYFnTuccpVqJ6a+KS1zjDRYVz1iIiDp2eq9lmNjiyIaTDu6Cxt9SxGNahbj+R1 osYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=jmpEGsoMCEZFctwNCe64tE1wCWqRXRFpjk0kPlELp9U=; b=o8OA3oija4kNwXV6HDU0O/9obr+xyBzKCSFYBMeDd6zseEGZSdsNwCs2F3MhBqCDTM EBGhiilPTpJZ/uFyXNapNd9yJ8nKoEC38ARDuXqOFl0HeugfSR4+k7apwp6RiVkOEsjQ jCAou/uzkUWiOzyMj7K9TXdNb1JgTAkzFMyLukiaijlp3OT2gDXBEBQUXTINkNtHDqwX PwULfdVw4awWSljC5e+P/VWcyu7n0m+rLvLjABq9sC9c1hlqVYGiatn1UXkluU8q+UfM UVtq5dTcYP2Z4Y0SYNIlHzoD4sPzLpjU4n+pLM6OnRvr4MqBrXIbYvsmIz7onNNUiPwQ FFgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=Ip0+ASZj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id n23si1623927edv.598.2020.09.28.17.21.37; Mon, 28 Sep 2020 17:22:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=Ip0+ASZj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1727210AbgI2ASv (ORCPT + 99 others); Mon, 28 Sep 2020 20:18:51 -0400 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:13610 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727201AbgI2ASt (ORCPT ); Mon, 28 Sep 2020 20:18:49 -0400 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== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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