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=-11.6 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 2E798C433E0 for ; Mon, 10 Aug 2020 23:39:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DBC7F206DA for ; Mon, 10 Aug 2020 23:39:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="DGpBsWq2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DBC7F206DA Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 56CC56B0003; Mon, 10 Aug 2020 19:39:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F6826B0005; Mon, 10 Aug 2020 19:39:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3E5FA6B0006; Mon, 10 Aug 2020 19:39:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0128.hostedemail.com [216.40.44.128]) by kanga.kvack.org (Postfix) with ESMTP id 24F806B0003 for ; Mon, 10 Aug 2020 19:39:16 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E4049181AEF09 for ; Mon, 10 Aug 2020 23:39:15 +0000 (UTC) X-FDA: 77136277470.26.pump08_4a11ea926fde Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id AAAA91804B670 for ; Mon, 10 Aug 2020 23:39:15 +0000 (UTC) X-HE-Tag: pump08_4a11ea926fde X-Filterd-Recvd-Size: 4728 Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Mon, 10 Aug 2020 23:39:15 +0000 (UTC) Received: by mail-lj1-f196.google.com with SMTP id t6so11495673ljk.9 for ; Mon, 10 Aug 2020 16:39:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=C/34YJbMeuxWiZIVphuGmT7O/HjPJjpnAOf2BK75EVc=; b=DGpBsWq243vsUYKMEHEDWzu7OHyMBIK8OO8Z0buizN5PDvd0+2TMQbVGGSBkofbQn6 dmPWNOZLkQVI78dLEEUF/VoLSgmSLwfI/KExoe/IAjD0yB09Qhni5tkTNZ2P6iZ+yvj7 A74k/ruNuFdoO83D2rCDyGeGDxmjrUI4jm9RPof2grq5Ax5VhwAc4EtVe9TipUuYBEdV urui9crtYhOFpD7HlXvAPzggE3XHNqSM0+jQbqTWme/Ro819+/tfymwCIRFPXpcEGW5h LjQ41GLIioCpVBMlfaOVNWSankPi4FUfGrZMgge6E71PaMwhIe3BRTvypNVpIU5rpdUX tukg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=C/34YJbMeuxWiZIVphuGmT7O/HjPJjpnAOf2BK75EVc=; b=tNCpFXDkgYk0uCuMt1HxN1OJImq7PtM57sxyPjLc+Pwd3D8Deh3e+881K3gRw6i5XY y34hdWkyCRUAmxaEnzD4ooZpdN2ER9VkbgUpPoUHVi/XZisRIwQM1B4P60/QrhXTcHHc sXagD5T6ETEw7fp1YaYraUku0u7mDT7VSNAsugbmM3OpLRPgFvFqOn/5cV6jfbmkoQU5 OqS3qI+WAoi+YOEcuxNugLIN/3S76XRKs3Q8pAOkVKRSw/HhIA0wTETYMJ5Bd6BRMI7g TCn6EahO+Paxu33btwu3WrEtem/ljgITyCZt7hCUOIolqpjXCEz2T53zUGd/NpsAc+J+ aNog== X-Gm-Message-State: AOAM530DpIFFLd96SVqTR3u+6kHNoPOlzxfOYSPiptGSZIzlqwcGaEQI FyS2nxIL55P/A059dMERbymQ+KMf1BuujITrPnb8RX38 X-Google-Smtp-Source: ABdhPJxfAch9eYuc+NxjABHWfnfS36mTYJMIpeGvT82zKgxW/uWxIqTqOjffHoFeWSQhc8vTBiat+LOEd7zDkn3pa1c= X-Received: by 2002:a2e:b058:: with SMTP id d24mr1737055ljl.265.1597102753674; Mon, 10 Aug 2020 16:39:13 -0700 (PDT) MIME-Version: 1.0 References: <20200810145701.129228-1-peterx@redhat.com> <20200810191520.GA132381@xz-x1> <20200810215734.GB132381@xz-x1> In-Reply-To: From: Jann Horn Date: Tue, 11 Aug 2020 01:38:47 +0200 Message-ID: Subject: Re: [PATCH v2] mm/gup: Allow real explicit breaking of COW To: Linus Torvalds Cc: Peter Xu , Linux-MM , Linux Kernel Mailing List , Andrew Morton , Marty Mcfadden , Andrea Arcangeli , Christoph Hellwig , Oleg Nesterov , Kirill Shutemov , Jan Kara Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: AAAA91804B670 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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 Tue, Aug 11, 2020 at 1:19 AM Linus Torvalds wrote: > On Mon, Aug 10, 2020 at 2:57 PM Peter Xu wrote: > > > > Yeah, that's why I totally agree we need to do enforced COW even for a read gup > > as long as the page can be further referenced (GET|PIN). However frankly > > speaking I didn't follow the rest on what's wrong with "Userfaultfd-wp should > > not care about this because it's not a write operation" that I mentiond. Is > > that the major part of the objection? > > You didn't _explain_ why it's ok. > > You said "it's only reading". > > And I told you why "only reading" is not an argument against COW. The way I understand Peter, he doesn't want to avoid doing COW; he wants to decouple userfaultfd-WP's fault handling from COW, so that userfaultfd-wp notifies only when a previously-write-protected page is actually written to. In other words, he wants the COW to basically happen as it happens now, but it should only create a readonly PTE; and if someone later triggers a real write fault, the fault handling path would run again, and this time userfaultfd-wp would be notified before that readonly PTE is turned into a writable one. The FOLL flag would only be generated by the GUP path, not passed in by any callers. It would cause the PTEs generated by breaking COW to be read-only (I think this part is missing from the patch?), and it would cause userfaultfd-WP to not synchronously block the fault. I hope I summarized Peter's idea correctly?