Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75A17C4332F for ; Tue, 21 Dec 2021 18:07:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240857AbhLUSHO (ORCPT ); Tue, 21 Dec 2021 13:07:14 -0500 Received: from smtp-out2.suse.de ([195.135.220.29]:46312 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232659AbhLUSHN (ORCPT ); Tue, 21 Dec 2021 13:07:13 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id EAE401F388; Tue, 21 Dec 2021 18:07:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1640110031; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+aHVar+NDv9LhVgPKkE8yVeRcY+l7hvW45ogGvLvZqI=; b=NrRBSTtBkpGrNyBZf9DmkNb9e8BDxusII75XYLrNqgQo1pb7pJ5w6SCGU0UgXF7iumVT0p m0l5ry5Bgl7ncB2YD4osjIjL2RryHzgFtxxDtCVY5im5GJ8V97iouma+3xLsty74dAlf9g c8Likz9rmpEzqcH1Uj/tFeBhgXrgqrM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1640110031; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+aHVar+NDv9LhVgPKkE8yVeRcY+l7hvW45ogGvLvZqI=; b=EQvIag3QDEARwfFqVfScA9TyRwLYYQtJ5j4IJSahIATSGzZfSZtnNNoBXqS5gebwGEhAk8 g8Hpif72xjDR3vDQ== Received: from quack2.suse.cz (unknown [10.163.28.18]) by relay2.suse.de (Postfix) with ESMTP id 8550EA3B8A; Tue, 21 Dec 2021 18:07:11 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id DBFFE1F2CEA; Tue, 21 Dec 2021 19:07:05 +0100 (CET) Date: Tue, 21 Dec 2021 19:07:05 +0100 From: Jan Kara To: David Hildenbrand Cc: Linus Torvalds , Jason Gunthorpe , Nadav Amit , Linux Kernel Mailing List , Andrew Morton , Hugh Dickins , David Rientjes , Shakeel Butt , John Hubbard , Mike Kravetz , Mike Rapoport , Yang Shi , "Kirill A . Shutemov" , Matthew Wilcox , Vlastimil Babka , Jann Horn , Michal Hocko , Rik van Riel , Roman Gushchin , Andrea Arcangeli , Peter Xu , Donald Dutile , Christoph Hellwig , Oleg Nesterov , Jan Kara , Linux-MM , "open list:KERNEL SELFTEST FRAMEWORK" , "open list:DOCUMENTATION" Subject: Re: [PATCH v1 06/11] mm: support GUP-triggered unsharing via FAULT_FLAG_UNSHARE (!hugetlb) Message-ID: <20211221180705.GA32603@quack2.suse.cz> References: <4D97206A-3B32-4818-9980-8F24BC57E289@vmware.com> <5A7D771C-FF95-465E-95F6-CD249FE28381@vmware.com> <20211221010312.GC1432915@nvidia.com> <900b7d4a-a5dc-5c7b-a374-c4a8cc149232@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <900b7d4a-a5dc-5c7b-a374-c4a8cc149232@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 21-12-21 18:40:30, David Hildenbrand wrote: > On 21.12.21 18:05, Linus Torvalds wrote: > > On Tue, Dec 21, 2021 at 12:58 AM David Hildenbrand wrote: > >> Note that I am trying to make also any kind of R/O pins on an anonymous > >> page work as expected as well, to fix any kind of GUP after fork() and > >> GUP before fork(). So taking a R/O pin on an !PageAnonExclusive() page > >> similarly has to make sure that the page is exclusive -- even if it's > >> mapped R/O (!). > > > > I do think the existing "maybe_pinned()" logic is fine for that. The > > "exclusive to this VM" bit can be used to *help* that decision - > > because only an exclusive page can be pinned - bit I don't think it > > should _replace_ that logic. > > The issue is that O_DIRECT uses FOLL_GET and cannot easily be changed to > FOLL_PIN unfortunately. So I'm *trying* to make it more generic such > that such corner cases can be handled as well correctly. But yeah, I'll > see where this goes ... O_DIRECT has to be fixed one way or the other. > > John H. mentioned that he wants to look into converting that to > FOLL_PIN. So maybe that will work eventually. For record we always intended (and still intend) to make O_DIRECT use FOLL_PIN. Just it is tricky because some users mix pages pinned with GUP and pages acquired through get_page() in a single bio (such as zero page) and thus it is non-trivial to do the right thing on IO completion (unpin or just put_page). Honza -- Jan Kara SUSE Labs, CR