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.8 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 A890BC4727E for ; Mon, 21 Sep 2020 22:18:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2AAB223A62 for ; Mon, 21 Sep 2020 22:18:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="Jlbe/oAI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2AAB223A62 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 5CC7E900008; Mon, 21 Sep 2020 18:18:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 57BB5900007; Mon, 21 Sep 2020 18:18:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 49205900008; Mon, 21 Sep 2020 18:18:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0090.hostedemail.com [216.40.44.90]) by kanga.kvack.org (Postfix) with ESMTP id 32D71900007 for ; Mon, 21 Sep 2020 18:18:31 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E8C0F8249980 for ; Mon, 21 Sep 2020 22:18:30 +0000 (UTC) X-FDA: 77288483580.14.dime02_361758c27148 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id C73AD18229818 for ; Mon, 21 Sep 2020 22:18:30 +0000 (UTC) X-HE-Tag: dime02_361758c27148 X-Filterd-Recvd-Size: 4093 Received: from hqnvemgate25.nvidia.com (hqnvemgate25.nvidia.com [216.228.121.64]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Mon, 21 Sep 2020 22:18:29 +0000 (UTC) Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Mon, 21 Sep 2020 15:17:42 -0700 Received: from [10.2.52.174] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 21 Sep 2020 22:18:28 +0000 Subject: Re: [PATCH 4/5] mm: Do early cow for pinned pages during fork() for ptes To: Jann Horn , Peter Xu CC: Linux-MM , kernel list , Linus Torvalds , Michal Hocko , Kirill Shutemov , Oleg Nesterov , Kirill Tkhai , Hugh Dickins , Leon Romanovsky , Jan Kara , Christoph Hellwig , Andrew Morton , Jason Gunthorpe , Andrea Arcangeli References: <20200921211744.24758-1-peterx@redhat.com> <20200921212028.25184-1-peterx@redhat.com> From: John Hubbard Message-ID: <07bc5f59-74ae-73e8-2616-f11712c27b58@nvidia.com> Date: Mon, 21 Sep 2020 15:18:27 -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: 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=1600726662; bh=yvFjZz5H7WJdvFOL+iOamQqOLsJG+P+1YgKrthibJWM=; 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=Jlbe/oAIF+Kj+XdyMgOu1fzzwVqxzP6YSa+FhzI/LeRGryj6jbi5EsnFIF4MozCJz ZEpfKqKXugxSAEnkwrn9rUu6wuAH18JrTIm3IjCdCIFTn92m+3D9HIoaUVGxFz3fhk VkN/mvruLCKBcMYTMFXwWwF1TxacefRBANYRCfx9OZn8B/qabtAsMTpUKUAWc45FOA 4Ev8zS0pDd2K9wLkbXz2dDY95GhjmVqVMCp5+Q/6bfLv7du9Hle7kp55hSpvvAlFxH vYyHTKupTIqLqykWwBlfdZbkxJM6QMWqJczZ5Lv27mV3+/723UySFDJ82T131Q1hhh RZRxTGS6Dn4zw== 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/21/20 2:55 PM, Jann Horn wrote: > On Mon, Sep 21, 2020 at 11:20 PM Peter Xu wrote: ... > I dislike the whole pin_user_pages() concept because (as far as I > understand) it fundamentally tries to fix a problem in the subset of > cases that are more likely to occur in practice (long-term pins > overlapping with things like writeback), and ignores the rarer cases > ("short-term" GUP). > Well, no, that's not really fair. pin_user_pages() provides a key prerequisite to fixing *all* of the bugs in that area, not just a subset. The 5 cases in Documentation/core-api/pin_user_pages.rst cover this pretty well. Or if they don't, let me know and I'll have another pass at it. The case for a "pin count" that is (logically) separate from a page->_refcount is real, and it fixes real problems. An elevated refcount can be caused by a lot of things, but it can normally be waited for and/or retried. The FOLL_PIN pages cannot. Of course, a valid remaining criticism of the situation is, "why not just *always* mark any of these pages as "dma-pinned"? In other words, why even have a separate gup/pup API? And in fact, perhaps eventually we'll just get rid of the get_user_pages*() side of it. But the pin count will need to remain, in order to discern between DMA pins and temporary refcount boosts. thanks, -- John Hubbard NVIDIA