Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp100586rwb; Wed, 18 Jan 2023 14:48:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXselqM/OZV4xFCw4r0s+VRVIsB1vQ7TMUh1VlRj4N625NykskI/QGtZTRZjkOgTNGAPufH1 X-Received: by 2002:a17:907:76da:b0:7c1:1dc7:8837 with SMTP id kf26-20020a17090776da00b007c11dc78837mr9180334ejc.66.1674082098611; Wed, 18 Jan 2023 14:48:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674082098; cv=none; d=google.com; s=arc-20160816; b=dfykDesSssRcVAxj2MCFP39yfbah2+T58s6C5FCmfA5Yai84DUibA304sOYRKI6dzV fc+xZ1UHGnrbP9xABt9e2DmZQrb4swRBbPuQfnXYtkFUnT0oDZjO+CzO5RN3IKWiEFvN bNBc56SRk9Vjido9ilM5fEylrhEkm5l1Fwv6wXLjn2QxIGPt45rhi/vWsqSVCyEgtoMB aaVW1x8DU88+2hrH0YrPP6jvsoG9W8jsVMBck0Pq4y1Ci5EoBJ2fO4CCMrW0Usqyo3C/ 3qkW2Mien+q6E3lS+YKREJ+ukAfgAL0JiIHP1xGE/y2+PLdHEIHCVPw7I27uACTuN1hy MBtw== 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=MspJ78t8fpxKGkTfcthNkvOr56UzNjzkTKTIZByHk64=; b=IwY6IjJ5IUQ+YHqAfHg6+8mrmxOeHFcqCS1K1DMBGDA7eenwEbGx9WI/KTQO0/AkZI 9FRYXJXaxgOpVwVnRVK1eAGVdp6lKtqqs/VYPzsxjRmLDysavsYZ9O8YlBPXUVMeAnm+ ri4ZCuXq7mCJPIqTEvIYoGGZGSw7G8uCvt1KU6xY1j0xMkxYV/X6CKIxtsN/UkZXcLvi cZMeuJr+QKcLsbJ7acaFNZ9Qsu6Skh8VfnIsd0CAnk3gbhSswbm98K4ZIVkLZ4KZRJ/0 UmQfTfXw4PiS8JnmWvGcjsJ79BIoSiCkmVo7D6SApKYWVEE8/aCvm0FusgH4y/ZFLMII R4Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Be/be34c"; 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 gs44-20020a1709072d2c00b0084d354539a5si39589090ejc.584.2023.01.18.14.48.07; Wed, 18 Jan 2023 14:48:18 -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="Be/be34c"; 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 S229476AbjARWNC (ORCPT + 44 others); Wed, 18 Jan 2023 17:13:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230042AbjARWM6 (ORCPT ); Wed, 18 Jan 2023 17:12:58 -0500 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 5D903654ED for ; Wed, 18 Jan 2023 14:12:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674079930; 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=MspJ78t8fpxKGkTfcthNkvOr56UzNjzkTKTIZByHk64=; b=Be/be34c6o0TtDWuezxnrvwOsU4VOuTutbU3Ek/Co/+PmYpm8yq3Wjdlo+FyfBOm7WhCpu pOBsok4NanqybW4OZP8Yk9ZiwyjHxgPYBnxJXXyxxaaubLyxSFqy3LSs7csc6rkiVT4+6j /wUmWi4c0Ztr3/yakFr90TKJn7Bs7R4= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-512-RvtsJ5GzMWKQibb-RoW7ZQ-1; Wed, 18 Jan 2023 17:12:09 -0500 X-MC-Unique: RvtsJ5GzMWKQibb-RoW7ZQ-1 Received: by mail-qv1-f71.google.com with SMTP id ng1-20020a0562143bc100b004bb706b3a27so70140qvb.20 for ; Wed, 18 Jan 2023 14:12:08 -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=MspJ78t8fpxKGkTfcthNkvOr56UzNjzkTKTIZByHk64=; b=edEeve482TAOejGLJaHVNkdb1HD5xRbVxoSCxE4l9ik7BYCXsrD6MnV5XZp3EPMC/g ututFDGxFczay3mg9WCyoUjcX6IxMa12LZDmssIoSz0NgGhgiLzuxavvgXQPBgxHIl8a jeGV75FrzFxqHbp4bpxUqFZbqYgpOWqOPP3J2P7AtssjnJq9jCbdMW8+EeugUkDuJO4V lStbfhC8qbkIoNOqIvMO9TwF/8y5Tun8WM+68OX2QUTp8Iz0j6unmy8n/4OBQfhmn++s NkyOx4GMtK5iejKlVBit37XIeUusWIWBTO2jR93uR/NFM1TIacBATc8COWnZ1acjFve7 /M9w== X-Gm-Message-State: AFqh2kopBrTmbAMW0QTl0L4eaaMUj6Vsm964z2Tmc5v535Jx2xCH+f2L IIMyDycchaJ5S2clim7rxLbeswfaXcE5G/2/MF5+lQZWWJJMsPu9lEUcMOROBQlV8ld7adstWxR AJMlpT/c4F8nuRktBf5BCVicf X-Received: by 2002:ac8:4696:0:b0:3b6:3334:5b95 with SMTP id g22-20020ac84696000000b003b633345b95mr10187267qto.11.1674079928305; Wed, 18 Jan 2023 14:12:08 -0800 (PST) X-Received: by 2002:ac8:4696:0:b0:3b6:3334:5b95 with SMTP id g22-20020ac84696000000b003b633345b95mr10187245qto.11.1674079928003; Wed, 18 Jan 2023 14:12:08 -0800 (PST) Received: from x1n (bras-base-aurron9127w-grc-56-70-30-145-63.dsl.bell.ca. [70.30.145.63]) by smtp.gmail.com with ESMTPSA id z24-20020ac875d8000000b003b68c7aeebfsm342908qtq.3.2023.01.18.14.12.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 14:12:07 -0800 (PST) Date: Wed, 18 Jan 2023 17:12:04 -0500 From: Peter Xu To: Muhammad Usama Anjum Cc: David Hildenbrand , Andrew Morton , =?utf-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Andrei Vagin , Danylo Mocherniuk , Paul Gofman , Cyrill Gorcunov , Alexander Viro , Shuah Khan , Christian Brauner , Yang Shi , Vlastimil Babka , "Liam R . Howlett" , Yun Zhou , Suren Baghdasaryan , Alex Sierra , Matthew Wilcox , Pasha Tatashin , Mike Rapoport , Nadav Amit , Axel Rasmussen , "Gustavo A . R . Silva" , Dan Williams , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Greg KH , kernel@collabora.com Subject: Re: [PATCH v7 0/4] Implement IOCTL to get and/or the clear info about PTEs Message-ID: References: <20230109064519.3555250-1-usama.anjum@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230109064519.3555250-1-usama.anjum@collabora.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=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 On Mon, Jan 09, 2023 at 11:45:15AM +0500, Muhammad Usama Anjum wrote: > *Changes in v7:* > - Add uffd wp async > - Update the IOCTL to use uffd under the hood instead of soft-dirty > flags > > Stop using the soft-dirty flags for finding which pages have been > written to. It is too delicate and wrong as it shows more soft-dirty > pages than the actual soft-dirty pages. There is no interest in > correcting it [A][B] as this is how the feature was written years ago. > It shouldn't be updated to changed behaviour. Peter Xu has suggested > using the async version of the UFFD WP [C] as it is based inherently > on the PTEs. > > So in this patch series, I've added a new mode to the UFFD which is > asynchronous version of the write protect. When this variant of the > UFFD WP is used, the page faults are resolved automatically by the > kernel. The pages which have been written-to can be found by reading > pagemap file (!PM_UFFD_WP). This feature can be used successfully to > find which pages have been written to from the time the pages were > write protected. This works just like the soft-dirty flag without > showing any extra pages which aren't soft-dirty in reality. > > [A] https://lore.kernel.org/all/20221220162606.1595355-1-usama.anjum@collabora.com > [B] https://lore.kernel.org/all/20221122115007.2787017-1-usama.anjum@collabora.com > [C] https://lore.kernel.org/all/Y6Hc2d+7eTKs7AiH@x1n > > *Changes in v6:* > - Updated the interface and made cosmetic changes > > *Cover Letter in v5:* > Hello, Please consider either drop the cover letter below this point or rephrase, otherwise many of them are not true anymore and it can confuse the reviewers. I have a few high level comments/questions here, please bare with me if any of them are already discussed by others in the old versions; I'd be happy to read them when there's a pointer to the relevant answers. Firstly, doc update is more than welcomed to explain the new interface first (before throwing the code..). That can be done in pagemap.rst on pagemap changes, or userfaultfd.rst on userfaultfd. Besides, can you provide more justification on the new pagemap-side interface design? It seems it came from the Windows API GetWriteWatch(), but it's definitely not exactly that. Let me spell some points out.. There're four kinds of masks (required/anyof/excluded/return). Are they all needed? Why this is a good interface design? I saw you used page_region structure to keep the information. I think you wanted to have a densed output, especially if counting in the "return mask" above it starts to make more sense. If with a very limited return mask it means many of the (continuous) page information can be merged into a single page_region struct when the kernel is scanning. However, at the meantime the other three masks (required/anyof/excluded) made me quite confused - it means you wanted to somehow filter the pages and only some of them will get collected. The thing is for a continuous page range if any of the page got skipped due to the masks (e.g. not in "required" or in "excluded") it also means it can never be merged into previous page_region either. That seems to be against the principle of having densed output. I hope you can help clarify what's the major use case here. There's also the new interface to do atomic "fetch + update" on wrprotected pages. Is that just for efficiency or is the accuracy required in some of the applications? Thanks, -- Peter Xu