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=-4.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 C208CC433E0 for ; Tue, 11 Aug 2020 15:06:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7C24F20771 for ; Tue, 11 Aug 2020 15:06:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="cPvbvK0q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C24F20771 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 041016B000C; Tue, 11 Aug 2020 11:06:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F339E6B000D; Tue, 11 Aug 2020 11:06:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E22916B000E; Tue, 11 Aug 2020 11:06:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0108.hostedemail.com [216.40.44.108]) by kanga.kvack.org (Postfix) with ESMTP id CA34A6B000C for ; Tue, 11 Aug 2020 11:06:09 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5522D180AD81F for ; Tue, 11 Aug 2020 15:06:09 +0000 (UTC) X-FDA: 77138613258.10.pump32_1f16abe26fe3 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id 427DD1698EC for ; Tue, 11 Aug 2020 15:06:03 +0000 (UTC) X-HE-Tag: pump32_1f16abe26fe3 X-Filterd-Recvd-Size: 5181 Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Tue, 11 Aug 2020 15:05:42 +0000 (UTC) Received: by mail-lj1-f195.google.com with SMTP id t23so13916893ljc.3 for ; Tue, 11 Aug 2020 08:05:42 -0700 (PDT) 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=TaPumgxPjnd+MZwdU/KPpO4ZkCcirToPKuAM/OHOrZ8=; b=cPvbvK0qtt0DSX98ByGWOqz50YA0tE0K8uuQ4uIsZWUOR9+u7UiyblnJaV4/MELZ+g AT6cJeqrtn5NAjcKmPQHIeMYzwSvlfiiQ7WGKy/sPmFsMDF0sruzmYzPL37JWz8JlzX8 l9KTUnxhv8BD7fRwIsdDwW7mzuiDF7KkaPvz8= 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=TaPumgxPjnd+MZwdU/KPpO4ZkCcirToPKuAM/OHOrZ8=; b=ge1puUNuI4xo+nLpPQeu6wV24/yfZFN2vOzwm9gaiqcqS5rqOazXOylJzBJqzg4htB eEw9eMFikyOmVdn8REBEx70iEVH6l8Be+gzgB4gHG436QxPoCotrS+XI198BAO1vzI2S SYT7zgJy/yfVthyZUlnhX49kiQC8ShR14IgYjDp3CpN1Ex1lxqfTANw5dh0zVC+u304v gWmTFyZPVSOxpY6Vv9Qc0q4/xhk1uLl0XMbaYSzvah5RSK9jEPgtY//3P7W5SLfGT6Dy LBqk3Pd9qsXGddrKsYzIyyURTmxPCsaWOvqVK2wrDufMSHF9utYfjM3G0YhJDbdm1QUQ yuAw== X-Gm-Message-State: AOAM531lb0YD4Oe/R2nG6DWNp3mkw5/+gLBR1exAC5e/XfvPg868oOLK hofXN75A4AAyfZJEdbwXO4VNvrH3pDU= X-Google-Smtp-Source: ABdhPJwTKlZd7FLy1vAi4fGzI6X6cYvD/Jq1gJIN2/ORhzfTTRF8NM2Cb7710UBW1npq13iVKBi8fA== X-Received: by 2002:a2e:b61c:: with SMTP id r28mr3020977ljn.23.1597158340783; Tue, 11 Aug 2020 08:05:40 -0700 (PDT) Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com. [209.85.167.54]) by smtp.gmail.com with ESMTPSA id g6sm11744154lfr.51.2020.08.11.08.05.39 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Aug 2020 08:05:39 -0700 (PDT) Received: by mail-lf1-f54.google.com with SMTP id b11so6836776lfe.10 for ; Tue, 11 Aug 2020 08:05:39 -0700 (PDT) X-Received: by 2002:a19:c206:: with SMTP id l6mr3385024lfc.152.1597158338674; Tue, 11 Aug 2020 08:05:38 -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: Linus Torvalds Date: Tue, 11 Aug 2020 08:05:22 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] mm/gup: Allow real explicit breaking of COW To: Jann Horn 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: 427DD1698EC X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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 Mon, Aug 10, 2020 at 4:39 PM Jann Horn wrote: > > 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. Ahh. A light goes on. Thank you. And apologies to Peter - I misread that patch entirely. That said, now that I (finally) understand what Peter wants to do, I don't think the patch does what you say. Because the GUP will now indeed avoid userfaultfd-wp unless it's _actually_ a write, but then any reads will cause a COW that turns things writable. There is no second fault. So now later writes will never cause any userfaultfd-wp notifications at all. Which for all I know might be acceptable and ok, but it seems to be against userfaultfd rules, and against the whole synchronization idea. So I think the patch is broken, but I'm less fundamentally concerned about it. Because at that point, it's "only" userfaultfd that might break. Linus