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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DB6EC433F5 for ; Fri, 17 Dec 2021 20:57:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E3C206B0073; Fri, 17 Dec 2021 15:57:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DC55A6B0074; Fri, 17 Dec 2021 15:57:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C18346B007B; Fri, 17 Dec 2021 15:57:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0214.hostedemail.com [216.40.44.214]) by kanga.kvack.org (Postfix) with ESMTP id AF3E66B0073 for ; Fri, 17 Dec 2021 15:57:01 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 72F43180E1E3B for ; Fri, 17 Dec 2021 20:56:51 +0000 (UTC) X-FDA: 78928495422.01.5387EC4 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) by imf29.hostedemail.com (Postfix) with ESMTP id 9387F12003D for ; Fri, 17 Dec 2021 20:56:48 +0000 (UTC) Received: by mail-lf1-f51.google.com with SMTP id bq20so6052193lfb.4 for ; Fri, 17 Dec 2021 12:56:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=WIi3YNtCblZ4jVB4/T4i8TvZe8jCT7lhPE8MEkAn6qA=; b=KweCUE5QrDRl499PLxNb1SW4WvC7F+yYs+lq1TXYVhwnCNr/xHbEr85r6Nh4D30the 6ZcPcSZ/y3xXiqcADRzs1V4A6WOdZU0S5jheyQb63bFhnnpkhr1bRNaXAtN6df5SvQnE 6g9p5Hkcw8U4Rcyd7Bbo8gbeTEYt9wRBqPCBA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=WIi3YNtCblZ4jVB4/T4i8TvZe8jCT7lhPE8MEkAn6qA=; b=Vk72KCJgS+kEALWEWADJLUfoOI2Vc127eZlYt5uGLiIRq6k36F4/4OdL2F/NLqOADg +gfX1KsrsiDEZSu75OCr+FuwvYsrx7rfyleGk4iU6qw23xvAsYbU57uA3P3w0twAr1Tr 5eqfGx/v0Xl1sKP8mjTHsSI5pnPkrxnRM3ud4deijfjiejR4+LlQn4qa9Kma8Oia5sRB BTqUe3G5Jm0PjoGLQhn6D9mLybKoKLrO3X5wWvneoVI3fijzWPfC9zLTxOmuhFZXrH7W 6dbclhSUF6qAZn/Q5FnqrYJVrZ24Gj7gMzWDH2OxLJs5DE/0szH4VdPBLqtWSlWxwnNL wGfQ== X-Gm-Message-State: AOAM532J9lIxHa6EbM+aMiekswwRqOfiadoGnDkAm2FrvQA7BNhudqfo +cBG5zSYBV7G/PBteeU8NxZBzHNJJQaZIAu9nrE= X-Google-Smtp-Source: ABdhPJxCY9pgdrY1XUytaZs3vcnvsMNGe9Z08rj9271LkN3kApaxlQCBnaCrCTVDwVkRhgFjcow8lw== X-Received: by 2002:a05:6512:114e:: with SMTP id m14mr4286174lfg.418.1639774609393; Fri, 17 Dec 2021 12:56:49 -0800 (PST) Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com. [209.85.208.181]) by smtp.gmail.com with ESMTPSA id 15sm1786316ljs.68.2021.12.17.12.56.48 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Dec 2021 12:56:49 -0800 (PST) Received: by mail-lj1-f181.google.com with SMTP id m12so5245247ljj.6 for ; Fri, 17 Dec 2021 12:56:48 -0800 (PST) X-Received: by 2002:adf:d1a6:: with SMTP id w6mr3777696wrc.274.1639774597825; Fri, 17 Dec 2021 12:56:37 -0800 (PST) MIME-Version: 1.0 References: <20211217113049.23850-1-david@redhat.com> <20211217113049.23850-7-david@redhat.com> <54c492d7-ddcd-dcd0-7209-efb2847adf7c@redhat.com> <20211217204705.GF6385@nvidia.com> In-Reply-To: <20211217204705.GF6385@nvidia.com> From: Linus Torvalds Date: Fri, 17 Dec 2021 12:56:21 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v1 06/11] mm: support GUP-triggered unsharing via FAULT_FLAG_UNSHARE (!hugetlb) To: Jason Gunthorpe Cc: David Hildenbrand , 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 , Nadav Amit , 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" Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 9387F12003D X-Stat-Signature: z6z7sqm4rj15kprd6gozmdwgb9buoa8i Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=KweCUE5Q; spf=pass (imf29.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.167.51 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org; dmarc=none X-HE-Tag: 1639774608-576513 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 Fri, Dec 17, 2021 at 12:47 PM Jason Gunthorpe wrote: > > To remind all, the GUP users, like RDMA, VFIO use > FOLL_FORCE|FOLL_WRITE to get a 'r/o pin' specifically because of the > COW breaking the coherence. In these case 'r/o pin' does not mean > "snapshot the data", but its only a promise not to write to the pages > and still desires coherence with the memory map. > > Eg in RDMA we know of apps asking for a R/O pin of something in .bss > then filling that something with data finally doing the actual > DMA. Breaking COW after pin breaks those apps. I agree. And my argument is that those kinds of things that ask for a R/O pin are broken, and should just make sure to use the shared pins. If the page was already writable, you can just re-use the page directly (marking it pinned, so that any subsequent fork() does the right pre-cow thing) And if the page was *NOT* already writable, you do a COW - which might be sharing the page directly too, if it has no other references. What's the downside of just doing this properly? Again: if a DMA user wants coherent memory, then it should use the coherent pinning. Not some kind of "read-only sharing that looks at crazy mapcounts that have absolutely zero relevance to whether the page is coherent or not". Linus