Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1400776rwb; Wed, 7 Dec 2022 12:34:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf5T59BdLe82raqhlKPDl/YxQGYys+hlbtwEPwEu3PLfbVepPGIQg5fxs6Tq9mcq1uI0OQBp X-Received: by 2002:a17:906:1844:b0:77a:4bfe:d6df with SMTP id w4-20020a170906184400b0077a4bfed6dfmr79177998eje.396.1670445276053; Wed, 07 Dec 2022 12:34:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670445276; cv=none; d=google.com; s=arc-20160816; b=d7zE0DBeMEfuEXQz23433UFzayef+jZc1T/00qOpuos6HqsbyjkP8OlorrDwNzfcnZ eVXr7WeHSBjnhdbssF1vcnuDLMPbk4OugMYY1nENaYw0OLcuJ8eFuDhoJnwIY0bKO2sb Dash6EqcQFZsz0N7jaVKz/FCkqo1Mt6g9LSQLo3cZaRdjMCF1GdBgebvD/qH7qYFgabs i3lzyNHlC48MGWcSqZTTvepzuESwn7meJbkGPE7uNGOvItNfevfja5k3zwv4U1sY7Jwe qLoohkg/sCI+FXm7O8yMVNd4kMlGCCsnuBEpYnKVnlyq8Lcpc2deCmOynoFwsWK8bsCI Tljw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=NwhTHbbeviWH0KrB78oH/LTS3J/aYRYFLjpGDACvYxQ=; b=GxoSsgViQ/iPwKnnZQ11g8tzcDwzQIAuyW5lDhVagd+I9U0O9xN4CETlI87RM7ZO8K cd/4vdmYQhIIdm15RbcuGhRlFwfYNaLigzdeVIYf4GSuUUjpd6uOzpJFGE/QbdL4SEO4 7alWlzuZv7l8fPDqhELsDQPx9ybQpkixj+b1VLKC6alg++0k/5q1ya2IBWlszfwIrEGF Ed7FrxfM+h/VoNROZ3z348pYTut7wSMYmtp7bxPOSha+1BF4TmHM1+zOeLWdbwq12HA1 wooZlrk8Z7dIeeFd3FjhnPZ+yX9IPHcyU1lvDjjVH6YymwyBLh5sbSUuQpDIN/Oj0xxw 4ldQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="jN/ba4on"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m9-20020a170906848900b007bff09aec4bsi13816689ejx.599.2022.12.07.12.34.18; Wed, 07 Dec 2022 12:34:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="jN/ba4on"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229650AbiLGUP2 (ORCPT + 74 others); Wed, 7 Dec 2022 15:15:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229586AbiLGUP0 (ORCPT ); Wed, 7 Dec 2022 15:15:26 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE4CE6DCF2 for ; Wed, 7 Dec 2022 12:14:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670444066; h=from:from:reply-to:subject:subject: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=NwhTHbbeviWH0KrB78oH/LTS3J/aYRYFLjpGDACvYxQ=; b=jN/ba4onri330YoCiFckZBHnXuaQWrj1XMffCbziL52MGSjsmKELFiyy5vp2M//B5+CKQ3 6breuLRQ3prE8OQ9oGQ+1R11Ka8ZjCaQo6EgLV0BWmHRoPCLXYSxeFpYtXBi8bXc+xRLUQ /9NfarbG40nLtwwZn8GjOtQTve/1Iw8= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-411-0-yPqorCOiaSdYjxgbu6sA-1; Wed, 07 Dec 2022 15:14:24 -0500 X-MC-Unique: 0-yPqorCOiaSdYjxgbu6sA-1 Received: by mail-qk1-f198.google.com with SMTP id m3-20020a05620a24c300b006fee2294e97so4704878qkn.11 for ; Wed, 07 Dec 2022 12:14:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=NwhTHbbeviWH0KrB78oH/LTS3J/aYRYFLjpGDACvYxQ=; b=D4LYldDE1Pss5bQkKWNwZGulHIjmkwrXzVrt2FtioKxUsYqSQlUmZ1pRgeSUIgAR/g PHzTl4hRv/wNQFuGAEY5tqZ/29cAMttLsbwuDpcy69ESpL/rGQ1PXgamtpYJcxCL9I+I 0OBgl93AXOmhtShf7OikdQbiSNBrQcrBPzJY5xBnlTCR8TASouKDaNhlGBj2VJHTTM+x 5UkgkFZ080V1i/s8DKJE/pvWu5DpviKDREBO9KG9nOAJHu6zuiaYcplAkrhAtyRM8+Fq N1oUrS/yxyknsEi52DgFep1XIkqyLLadLtdByYVuqhsvElllRzLXgc31Qni82dhmQH06 RNSQ== X-Gm-Message-State: ANoB5plwbvCuQFJVVQBdsOBH5fAtB7EdIsm7NQvp/mESx5d5TpL/x2Ee wo7XpEW9TRMIFySKSTDbna9/ZRrKg6do4MhH6xok8tMqJy5YI7AG0e+WDkQGxHHj5U5LsCzoA40 gsRXSkwxRKJxS84OgAhHH3GJh X-Received: by 2002:a05:622a:418e:b0:3a6:50d6:9d83 with SMTP id cd14-20020a05622a418e00b003a650d69d83mr1603202qtb.65.1670444064223; Wed, 07 Dec 2022 12:14:24 -0800 (PST) X-Received: by 2002:a05:622a:418e:b0:3a6:50d6:9d83 with SMTP id cd14-20020a05622a418e00b003a650d69d83mr1603193qtb.65.1670444063944; Wed, 07 Dec 2022 12:14:23 -0800 (PST) Received: from x1n (bras-base-aurron9127w-grc-46-70-31-27-79.dsl.bell.ca. [70.31.27.79]) by smtp.gmail.com with ESMTPSA id x16-20020ac87a90000000b003a5fb681ae7sm13845182qtr.3.2022.12.07.12.14.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 12:14:23 -0800 (PST) Date: Wed, 7 Dec 2022 15:14:22 -0500 From: Peter Xu To: David Hildenbrand Cc: Hugh Dickins , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ives van Hoorne , Andrew Morton , Alistair Popple , Mike Rapoport , Nadav Amit , Andrea Arcangeli Subject: Re: [PATCH RFC] mm/userfaultfd: enable writenotify while userfaultfd-wp is enabled for a VMA Message-ID: References: <690afe0f-c9a0-9631-b365-d11d98fdf56f@redhat.com> <19800718-9cb6-9355-da1c-c7961b01e922@redhat.com> <92173bad-caa3-6b43-9d1e-9a471fdbc184@redhat.com> <22d8e8ac-d75-a66-2650-b4d59f89855e@google.com> <37a9442e-f6e5-35f5-0d51-669d60936b5f@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <37a9442e-f6e5-35f5-0d51-669d60936b5f@redhat.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 07, 2022 at 08:53:36PM +0100, David Hildenbrand wrote: > Once user space successfully placed an uffd-wp marker, and e.g., verified > using pagemap that it is indeed placed, the system should not silently drop > it. Note that the anon path doesn't use pte markers. We won't lose a pte marker, hopefully, if we do that's a more severe one. > > The behavior between an ordinary THP and a huge zeropage differs. For THP, > we handle the split correctly and don't lose the marker. Assuming the huge > zeropage woud be disabled, the behavior would be (IMHO) correct. The test > case would pass. > > For example, QEMU with uffd-wp based snapshotting will make sure that all > virtual addresses are populated (e.g., mapping the shared, eventually the > huge zeropage -- populate_read_range()), before protecting using uffd-wp. > Losing a uffd-wp marker would be problematic. > > The good news is that we barely will end up PTE-mapping the huge zeropage > unless there is real user-space interaction (mprotect(), mremap(), mmap()), > so this shouldn't trigger in the QEMU use-case. Ah yes, I forgot that part. If it's not affected then it's better. > > > Anyhow, I'll send a patch in a couple of days and we can discuss further. > It's independent of the other discussion, just wanted to report my findings > after staring at that code for way too long today. Thanks, that works for me. -- Peter Xu