Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1588690rdb; Mon, 2 Oct 2023 14:34:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFl99Um1udTGm7vi8rCRBo0tOXgnTinhN5t21ynGEK6ytKUvpmjN2vVwDA69x4c3uGC7l86 X-Received: by 2002:a05:6808:211e:b0:3af:63a3:559 with SMTP id r30-20020a056808211e00b003af63a30559mr15689474oiw.12.1696282484126; Mon, 02 Oct 2023 14:34:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696282484; cv=none; d=google.com; s=arc-20160816; b=ACo/JC/gBAG9qgfWKq/ui/kVgUP/lCzSQ9d7QVirZeQJbw0L8+kSdh5x0SnGE2hJG3 ojIcWbZZdOee87xx3Lg/vrkDxE4xgxt17K+XBj1D1YxM5L6RnetIZKohSB+r+5cDaAsM 00G/GV+owZDkeNikauICsVFxYF6OHvlFlizwql1Ea/pKfjDCneehCQNpw2Imhk/WGMtI o0gm0cdwJ9cAHAEQzNwuQ4qWs547Rb+seQuDASzNjlqjUC4rXNMmbVmlqPV5KUdg1z5r gVXbf3oFIZLyc6pFcBbqmhNWiijC+11tidfMXh6zecr+w+nmb9MMhXCrMwLGgoNYetrA tmJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=R3pNKxFBUrDFcUW5mxBwAPe/18s1s98AEQ79l0wt2AA=; fh=YDmoMQG3rMzQ3KuoyDs1/z6j8a5MDB0bNzkSxhup2QY=; b=wR+0+/km7RQguybfsITXKILESzdeqrEGrxeammQwxRtzRVLLkyKSNmPz6TSbTEPGvI 64VdgvFR7XGlwuZA5n+HRT4MiKbaaLFZiM+TL8VesxiCqpRX1jCZt/cHN20ayaoXFFH8 RzeiFOJdrdKsrs+hqXr4HALQAc7xHdeGzfOMHF2u9VzHh+LAF/KchXzDO4ccmai5UAOt pQXkTlVZOmcPX7DWBEYnYqXbLVzvcowKCL0ddNnfSFcg0tvJbBrJ4FLqrPagGxpI5cgk h3Cfup1Iz6yhFC6Z8mako8kxzCCkj5kis0g5LE/ZAxTvfHryFfj7l9lSZjaIokBR7oI4 RUDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Qm9tqKZY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id u71-20020a63854a000000b005859cd26197si9051395pgd.455.2023.10.02.14.34.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 14:34:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Qm9tqKZY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id EC6AB804C635; Mon, 2 Oct 2023 00:50:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235788AbjJBHue (ORCPT + 99 others); Mon, 2 Oct 2023 03:50:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229712AbjJBHud (ORCPT ); Mon, 2 Oct 2023 03:50:33 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF77ABF for ; Mon, 2 Oct 2023 00:49:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696232983; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R3pNKxFBUrDFcUW5mxBwAPe/18s1s98AEQ79l0wt2AA=; b=Qm9tqKZYABYPRb7sor+tDQnl6L/WGtTQSAzPudhaNhph4w8/WYZ+IFnU2VpsdXnreye4oF pCJcAafjCtfUjiwklDp/EFuDg9arhxBC2k29qzqU/ueuOfKb0JiHc9NcUuwvJct5Wspr9D q66yzEX3PVybY3+1o6rC7327pUlciG8= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-308-rF3EJqj9NCWQvwEYOultqw-1; Mon, 02 Oct 2023 03:49:42 -0400 X-MC-Unique: rF3EJqj9NCWQvwEYOultqw-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3217fdf913dso12018498f8f.3 for ; Mon, 02 Oct 2023 00:49:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696232981; x=1696837781; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=R3pNKxFBUrDFcUW5mxBwAPe/18s1s98AEQ79l0wt2AA=; b=vYkz64TuoaxZmA3Z7CfOmlTYHP+kp/gNTt/StrFjfFCpLj2PnvjdFi1eUeFNIkPr57 axepsnRgDL+eBxk02ihKXI/h8FJqMYAIG0Vs512F9fPW74MegbfyxSYc7R51Z9q2FdqN ttN7ts9UPz4UPrf/Zug+MSw4oVWdUEZdqit3RpuGcY8kD/HHbVL3hBqp4cY6Nke8SQ+h aFyXt4BMB9OBUcrcoIoLKTnhxS//gX7iXhXRfS78nH6EDSThwGmHiXsofF1iqyL0eK2U Djj0JO+/8n0rOwDUw4ZkMsM9XEd2tpM8WnjtsQHQ5OH64SEi3Z0+QPgIC8cyirME1DO4 u1WQ== X-Gm-Message-State: AOJu0Yzka0fK+Crwho+U3N4+iOUrSWMtBwAeUBmO60IBtYKdNUJ3ckkd nRZw+zP71hfZi8b6jsy1K6NnGf1RKEKbiNbcD/PUlNAttyajfNNcCSQRAwcDti/YGsMxWeRhJT7 DuK0b3Q2DfzGjYgVUnPVk7j50 X-Received: by 2002:adf:cd0a:0:b0:31f:f982:5395 with SMTP id w10-20020adfcd0a000000b0031ff9825395mr10301916wrm.35.1696232981321; Mon, 02 Oct 2023 00:49:41 -0700 (PDT) X-Received: by 2002:adf:cd0a:0:b0:31f:f982:5395 with SMTP id w10-20020adfcd0a000000b0031ff9825395mr10301886wrm.35.1696232980873; Mon, 02 Oct 2023 00:49:40 -0700 (PDT) Received: from ?IPV6:2003:cb:c735:f200:cb49:cb8f:88fc:9446? (p200300cbc735f200cb49cb8f88fc9446.dip0.t-ipconnect.de. [2003:cb:c735:f200:cb49:cb8f:88fc:9446]) by smtp.gmail.com with ESMTPSA id s5-20020adf9785000000b003232380ffd7sm19386758wrb.102.2023.10.02.00.49.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Oct 2023 00:49:40 -0700 (PDT) Message-ID: <56c63536-3947-49b3-d271-6092e50474ec@redhat.com> Date: Mon, 2 Oct 2023 09:49:38 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH v2 2/3] userfaultfd: UFFDIO_REMAP uABI Content-Language: en-US To: Peter Xu Cc: Suren Baghdasaryan , Jann Horn , akpm@linux-foundation.org, viro@zeniv.linux.org.uk, brauner@kernel.org, shuah@kernel.org, aarcange@redhat.com, lokeshgidra@google.com, hughd@google.com, mhocko@suse.com, axelrasmussen@google.com, rppt@kernel.org, willy@infradead.org, Liam.Howlett@oracle.com, zhangpeng362@huawei.com, bgeffon@google.com, kaleshsingh@google.com, ngeoffray@google.com, jdduke@google.com, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kernel-team@android.com References: <20230923013148.1390521-1-surenb@google.com> <20230923013148.1390521-3-surenb@google.com> <03f95e90-82bd-6ee2-7c0d-d4dc5d3e15ee@redhat.com> <9101f70c-0c0a-845b-4ab7-82edf71c7bac@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 02 Oct 2023 00:50:45 -0700 (PDT) On 28.09.23 21:00, Peter Xu wrote: > On Thu, Sep 28, 2023 at 07:15:13PM +0200, David Hildenbrand wrote: >> There are some interesting questions to ask here: >> >> 1) What happens if the old VMA has VM_SOFTDIRTY set but the new one not? You >> most probably have to mark the PTE softdirty and not make it writable. > > I don't know whether anyone would care about soft-dirty used with uffd > remap, but if to think about it.. > > Logically if the dst vma has !SOFTDIRTY (means, soft-dirty tracking > enabled), then IIUC the right thing to do is to assume this page is > modified, hence mark softdirty and perhaps proceed with other checks (where > write bit can be set if all check pass)? I think so, yes. > > Because from a soft-dirty monitor POV on dst_vma I see this REMAP the same > as writting data onto the missing page and got a page fault > (e.g. UFFDIO_COPY); we just avoided the allocation and copy. > > The src vma seems also fine in this regard: soft-dirty should ignore holes > always anyway (e.g. DONTNEED on a page should report !soft-dirty later even > if tracking). Sounds good to me. > >> >> 2) VM_UFFD_WP requires similar care I assume? Peter might know. > > UFFD_WP shouldn't be affected, iiuc. > > Let's first discuss dst vma side. > > WP_UNPOPULATED made it slightly complicated but not so much. The core > should be that REMAP only installs pages if it's exactly pte_none(): > > + if (!pte_none(orig_dst_pte)) { > + err = -EEXIST; > + goto out; > + } > > Then it already covers things like pte markers, and any marker currently > will fail the REMAP ioctl already. May not be always wanted, but no risk > of losing wp notifications. If that'll be a valid use case we can work it > out. Agreed. > > On src vma, REMAP ioctl should behave the same as DONTNEED. Now we drop > the src pte along with the uffd-wp bit even if set, which is the correct > behavior from that regard. > > Again, I don't know whether anyone cares on any of those, though.. If it's easy to handle, we should just handle it or instead spell it out why we believe we can break other features. Seems to be very easy to handle. -- Cheers, David / dhildenb