Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp20054pxk; Tue, 15 Sep 2020 18:52:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfG3ezexKBVc6t5CWqzDUBiiQJLJ4MRH0nyWsncmGJ7yn8COJDNUCOJDci6sBN3E97z9G4 X-Received: by 2002:a50:d61e:: with SMTP id x30mr643665edi.70.1600221167568; Tue, 15 Sep 2020 18:52:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600221167; cv=none; d=google.com; s=arc-20160816; b=zhLqqJW1jjj9hEHh/arIAuuL+QDZCwrF3WKDhXeKsoQwg95Ms95GSUjgccOPnnw/BI enrql0ARRBRZOGk5IHnE8qGl8GPCq8YsowcNB4DLYA6GX/8hpTPH+2F1jkG7sDfSYMuS F+vtHTU3Cd+yz44IVFDmTURQ0punOViAGG6L3DQ3IUkUxkm7CQPdKP2tZZyHapGnEqOR dIS3EohVaj/8xXFJqKJkOIwBJeT4gOWyOebfTCI1KN6/JI4uFkKVpyKKxxeO4y3fvMRo 6leTQb8LWsYx8NBTyeYwzWuCc/pD2qrCVusdMKUNC514PMTM5Fww0K0smTGMGhdQw4c4 TEqA== 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=R8RK6+q/opEu27GaII0hstPQtlgYS8rx6zExB0/RPu4=; b=zg9voh4I8vaK04wTZ3jcMex23xZh+c6EswXpfhWTscQRRq+itt82L2EaLWeZdIEJXE RHaQeGgEtzxhqwsD0Y/LTwGP/55jhyRHAFsMus8pWIAEuztzYLnahWOdx8X4DMqk5fns gocYSTe7N7Ek8aodmrOeSsf1gXiqNdhNzn3FudshhkObuUBJyD2Pz3938DrwnUcqttSg 7Rl4oJjDcuDXZLL163ZfddPS+2PzDZg6p6DVWeeRH/dEaJvTzabh59WFN2WYYwKm6564 CXXogN9B9dLutNJGfXrmzpHzzCRa3BNBHT0bDRFOMnMte0z07ojgUgMbqOS3P3AUCMWb YHmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=r11pzfub; 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 e3si10468943ejt.37.2020.09.15.18.52.24; Tue, 15 Sep 2020 18:52:47 -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=r11pzfub; 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 S1726254AbgIPBuu (ORCPT + 99 others); Tue, 15 Sep 2020 21:50:50 -0400 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:2826 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726023AbgIPBur (ORCPT ); Tue, 15 Sep 2020 21:50:47 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Tue, 15 Sep 2020 18:48:25 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Tue, 15 Sep 2020 18:50:47 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Tue, 15 Sep 2020 18:50:47 -0700 Received: from [10.2.57.195] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 16 Sep 2020 01:50:46 +0000 Subject: Re: [PATCH 1/4] mm: Trial do_wp_page() simplification To: Jason Gunthorpe , Peter Xu CC: Linus Torvalds , Leon Romanovsky , Linux-MM , Linux Kernel Mailing List , "Maya B . Gokhale" , "Yang Shi" , Marty Mcfadden , "Kirill Shutemov" , Oleg Nesterov , Jann Horn , Jan Kara , Kirill Tkhai , Andrea Arcangeli , "Christoph Hellwig" , Andrew Morton References: <20200914211515.GA5901@xz-x1> <20200914225542.GO904879@nvidia.com> <20200914232851.GH1221970@ziepe.ca> <20200915145040.GA2949@xz-x1> <20200915160553.GJ1221970@ziepe.ca> <20200915182933.GM1221970@ziepe.ca> <20200915191346.GD2949@xz-x1> <20200915193838.GN1221970@ziepe.ca> <20200915213330.GE2949@xz-x1> <20200915232238.GO1221970@ziepe.ca> From: John Hubbard Message-ID: Date: Tue, 15 Sep 2020 18:50:46 -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: <20200915232238.GO1221970@ziepe.ca> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1600220905; bh=R8RK6+q/opEu27GaII0hstPQtlgYS8rx6zExB0/RPu4=; h=X-PGP-Universal:Subject:To:CC:References:From:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:X-Originating-IP: X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=r11pzfubxATnhdYAblbr+/r3uMQ7KILDqrF5RvkYhbfCPZuBSgX6mQFkqvsuYBtU+ 8+i+2deMTM0ryZecHkYAitLrG68dubAOEjv6Y5y1FmJ7MjnJTpznBOx3O5RXjzDhsL unFt1AVAIF0b9vqlpiJy8BQJ0q7xBvoCth1/MCRafIuHOtyRh+PNE6NRa6j931nyIm BP5YV2nvbf09+LFdkuHv0jqTQdRvzJrtyIWKSU5j/sC+uMSLClO86jQ/mAEKG4k6mU MlEiT1wU8ZRfonl52gN2eAO776ScAaXhMRiN89N7Q4XVTmwlPUPjoqPH9NE+R8W+qN VLtd/ZaV/bVDA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/15/20 4:22 PM, Jason Gunthorpe wrote: > On Tue, Sep 15, 2020 at 05:33:30PM -0400, Peter Xu wrote: > >>> RDMA doesn't ever use !WRITE >>> >>> I'm guessing #5 is the issue, just with a different ordering. If the >>> #3 pin_user_pages() preceeds the #2 fork, don't we get to the same #5? >> >> Right, but only if without MADV_DONTFORK? > > Yes, results are that MADV_DONTFORK resolves the issue for initial > tests. I should know if a bigger test suite passes in a few days. > >>>> If this is a problem, we may still need the fix patch (maybe not as urgent as >>>> before at least). But I'd like to double confirm, just in case I miss some >>>> obvious facts above. >>> >>> I'm worred that the sudden need to have MAD_DONTFORK is going to be a >>> turn into a huge regression. It already blew up our first level of >>> synthetic test cases. I'm worried what we will see when the >>> application suite is run in a few months :\ >> >> For my own preference I'll consider changing kernel behavior if the impact is >> still under control (the performance report of 30%+ boost is also attractive >> after the simplify-cow patch). The other way is to maintain the old reuse >> logic forever, that'll be another kind of burden. Seems no easy way on either >> side... > > It seems very strange that a physical page exclusively owned by a > process can become copied if pin_user_pages() is active and the > process did fork() at some point. > > Could the new pin_user_pages() logic help here? eg the > GUP_PIN_COUNTING_BIAS stuff? > > Could the COW code consider a refcount of GUP_PIN_COUNTING_BIAS + 1 as > being owned by the current mm and not needing COW? The DMA pin would > be 'invisible' for COW purposes? Please do be careful to use the API, rather than the implementation. The FOLL_PIN refcounting system results in being able to get a "maybe DMA-pinned", or a "definitely not DMA-pinned", via this API call: static inline bool page_maybe_dma_pinned(struct page *page) ...which does *not* always use GUP_PIN_COUNTING_BIAS to provide that answer. thanks, -- John Hubbard NVIDIA