Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8143408rwb; Tue, 6 Dec 2022 14:46:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf4t0kNI5GvZVRHG7ael6o27eotcWkI/ljSaaGub1S08crm1qLTsHuqLTW5Tv+Y+URp7pvYj X-Received: by 2002:a05:6a00:e09:b0:575:3e68:ffa0 with SMTP id bq9-20020a056a000e0900b005753e68ffa0mr41830085pfb.12.1670366808528; Tue, 06 Dec 2022 14:46:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670366808; cv=none; d=google.com; s=arc-20160816; b=TvStujOwNmdW8Q3ybkymp6g817EXiuRNCqgcGIpsLh7j4BneNhHPOrnAgsKL0JUUXL 5xk8CfKSSJ6h+T23UPTEfiSUn9LqQ35ijsXxUbV5ZZwAByQw1mpaJSXNw0ytHo1wzpQ6 YVR9nzdwRPULQmd3bF8rfQPvfSvkpuItOypn6MJHCFfHvWSAr/Y7OIv/mzUmdK2Z+Ksl H/bz3Xo6rNzbyd/KPcuyeCTfdxuE7i6u6pP3ebmoR/WDZCS+RSc9UmB3sEdxm7npETnw kKV2f1qfXjjICunHjBHMqu560HKOAonmlzRf0CbzOqoF8YddQmHiRP5ulLi/Jr1h5INK pPbA== 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=PRGbK9k8R9uzFMCG9ps6sFZXam1J9ub+EnEOXkruzkY=; b=YtgzAMPaB5oGwXPxacXclhEWisZ8CZq3yWZ5/yI/k7lPLGuJFdfx73YoDTxD/A7y4t 3tTJ1fzKqJNr3UrR5zp4T5i3YTOZf4ed3RjKJTcwuKYEKavRmTBIveaQhmLrZWAxfQq3 zy0kkINWVazu4NfCl+h9q1u2gaUa4TpTNT1oOskdDPk5zo37ba6LJW+k/IajnHmxN0SQ mg5/vOfluCv4AVmk0pHz6v6VlTB8mDBYCaBVewW3FTvBynon+7bDt0ATP6C5/Q1jDT/a 7LU7bF403EBkCQCi3tu1MaxLuAxZ6utAXef+S4EBnQ0WYPrZGvNHXlSak0qBPbTDHYHa MNlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dBm4DUqc; 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 np10-20020a17090b4c4a00b00219e38b5071si5792774pjb.14.2022.12.06.14.46.38; Tue, 06 Dec 2022 14:46:48 -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=dBm4DUqc; 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 S229652AbiLFV2e (ORCPT + 77 others); Tue, 6 Dec 2022 16:28:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229575AbiLFV2c (ORCPT ); Tue, 6 Dec 2022 16:28:32 -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 801CA637F for ; Tue, 6 Dec 2022 13:27:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670362056; 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=PRGbK9k8R9uzFMCG9ps6sFZXam1J9ub+EnEOXkruzkY=; b=dBm4DUqcec8iQeDw8nOsoZnfinJnIXxbTLjszgSDPG82dRF+ZUgCs/OPKS0eUZ7dSKgySa CpG2yUR8RMYI/yVIykcA1pEV68qKrxjd3FWmzufxnfXTe3QCyeerJCmH3aSquBtKo/0zsF ruPzINCC1xphxzF9nuPdRBjuAbtmeTM= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-149-AtaVwDmXMm-fLdNHUuAJXg-1; Tue, 06 Dec 2022 16:27:34 -0500 X-MC-Unique: AtaVwDmXMm-fLdNHUuAJXg-1 Received: by mail-qt1-f197.google.com with SMTP id ff5-20020a05622a4d8500b003a526107477so35068249qtb.9 for ; Tue, 06 Dec 2022 13:27:34 -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=PRGbK9k8R9uzFMCG9ps6sFZXam1J9ub+EnEOXkruzkY=; b=sV3QbJMgtW1LXy+jUvf5OwWx2UyQD/eGmHXfvkiuBLXElIVX45U4a3RWu3ipXrq+MP CSt/xE/gB/WzslpHYEmilO8Ka/tIxwviSakl03wMhcdjZnxALFNEhMON+dgeSZFUhadB Irsa97mlNMHwwzwR90ZDmi/8221tbwCs5dP7I/UvJDHyBxWaTv+M/In9k0McyBwTcUe4 3rCgJlCCZKhpq5Xc50gtxp6o4GS0sb3pJPEtwpeoiB3s2FXAyeDaQz2yMiXZs3Gorops wv0uzk0KlGg+deSMhbzGwMaKMAvNganzePotwKDNYUfgxiCo69agsy7XXBfW4o2nZOz3 9yBw== X-Gm-Message-State: ANoB5plsTebadX65QqCgfitB6QzUxSlPY6h2xqStWVOnxjmhJpvIQ01s W7r/EUiNhp2ptK9OTSroa8bSNx7wkPJbfoRKbifWpeD6/FQmH8rLs+mFw0Du9AhKu0Xrbc1ieGO 9uETo1yG8G3yGAS2gnohE2Sj/ X-Received: by 2002:ac8:5508:0:b0:39c:da20:688 with SMTP id j8-20020ac85508000000b0039cda200688mr612911qtq.43.1670362054289; Tue, 06 Dec 2022 13:27:34 -0800 (PST) X-Received: by 2002:ac8:5508:0:b0:39c:da20:688 with SMTP id j8-20020ac85508000000b0039cda200688mr612909qtq.43.1670362054063; Tue, 06 Dec 2022 13:27:34 -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 k17-20020ac84791000000b003a50c9993e1sm12431610qtq.16.2022.12.06.13.27.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 13:27:33 -0800 (PST) Date: Tue, 6 Dec 2022 16:27:31 -0500 From: Peter Xu To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ives van Hoorne , stable@vger.kernel.org, Andrew Morton , Hugh Dickins , 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: <20221202122748.113774-1-david@redhat.com> <690afe0f-c9a0-9631-b365-d11d98fdf56f@redhat.com> <19800718-9cb6-9355-da1c-c7961b01e922@redhat.com> <92173bad-caa3-6b43-9d1e-9a471fdbc184@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <92173bad-caa3-6b43-9d1e-9a471fdbc184@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 Tue, Dec 06, 2022 at 05:28:07PM +0100, David Hildenbrand wrote: > > If no one is using mprotect() with uffd-wp like that, then the reproducer > > may not be valid - the reproducer is defining how it should work, but does > > that really stand? That's why I said it's ambiguous, because the > > definition in this case is unclear. > > There are interesting variations like: > > mmap(PROT_READ, MAP_POPULATE|MAP_SHARED) > uffd_wp() > mprotect(PROT_READ|PROT_WRITE) > > Where we start out with all-write permissions before we enable selective > write permissions. Could you elaborate what's the difference of above comparing to: mmap(PROT_READ|PROT_WRITE, MAP_POPULATE|MAP_SHARED) uffd_wp() ? [...] > Yes, you are correct. I added that to the patch description: > > " > Note that we don't optimize for the actual migration case: > (1) When migration succeeds the new PTE will not be writable because > the source PTE was not writable (protnone); in the future we > might just optimize that case similarly by reusing > can_change_pte_writable()/can_change_pmd_writable() when > removing migration PTEs. > (2) When migration fails, we'd have to recalculate the "writable" > flag because we temporarily dropped the PT lock; for now keep it > simple and set "writable=false". > " > > Case (1) would, with your current patch, always lose the write bit during > migration, even if vma->vm_page_prot included it. We most might want to > optimize that in the future. > > Case (2) is rather a corner case, and unless people complain about it being > a real performance issue, it felt cleaner (less code) to not optimize for > that now. As I didn't have a closer look on the savedwrite removal patchset so I may not speak anything sensible here.. What I hope is that we don't lose write bits easily, after all we tried to even safe the dirty and young bits to avoid the machine cycles in the MMUs. > > Again Peter, I am not against you, not at all. Sorry if I gave you the > impression. I highly appreciate your work and this discussion. No worry on that part. You're doing great in this email explaining things and write things up, especially I'm happy Hugh confirmed it so it's good to have those. Let's start with something like this when you NAK something next time. :) Thanks, -- Peter Xu