Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp732297pxb; Tue, 2 Feb 2021 17:01:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJx0tJaTXOPSChQSmWRcWYXZgsmgR6ibGdvsFO89KQhucpzw8Z1RHle/SP8fQADtKbzqO4/w X-Received: by 2002:a05:6402:1bc7:: with SMTP id ch7mr718866edb.124.1612314102363; Tue, 02 Feb 2021 17:01:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612314102; cv=none; d=google.com; s=arc-20160816; b=TJQYTbwmZvqFMkyn+FFouOFi3rNoYJWhYUmXWpvCfYdPAEIdpL9Sgx7Uiqx8IwZBdz N2A79yekgKACO2CKnkKbqXx+vwkX58tPgicBynsxoRVFPVBNUbrCOMUp0UpWWVy48jE7 9U4vh7dvFMz8KK4qyWxMqhclODEfMEMV9wloqk92WbTaIMbX5FjuLctFQHdYpUh55yR2 M3dsIxmglmNw2ADSu63h+lgx5NzoQ07zWMuLnvVaIFGv5e4JFVhMF0nOkZBq5iYhKF2s DzJUfhXq8kYRZJXDsrXGQrwRYDHcMniK9sAaWmRnKOevEIQlYoz7f2m1OxBLJGG4NfaD uBjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=2RjDL0WnIqmbAwIPgih8NIYCRBA1hoXGPmIcl2Uor2U=; b=P+wJCWXhlF3dgpK6XGPkkIpjmV40+dxnGIi3JPgyos/8/ZerGLHhmNBUc8+pVH1z+c 895JycNznzWiUG/FEmv2hLiDNbZDMDjC42Yd/hOP/QiI5cH/sb2fbNcpTpVwd6K+H8JH vRV1pect4ac/Gf5yxUygikFY/ggAG/47d/fLVYY10tzGDO9nl0oKog4z3ZfWyge/9X4J SYQ/2NwhGOplEb1VK/UTYP1FQ6bGn4ZgheQwgp7Lx67uxdkg1tkTVhoTvshuw1qxildY EaPVMXLhCXPYjJO7GXZgkop9Vsf0kWQ9En5TNHnzVS4oSDKqmVyy24XZ33h0H2UmqYJq +1dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=AuP+ac8M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f7si305848edd.343.2021.02.02.17.01.18; Tue, 02 Feb 2021 17:01:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=AuP+ac8M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236255AbhBBXIi (ORCPT + 99 others); Tue, 2 Feb 2021 18:08:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236258AbhBBXIb (ORCPT ); Tue, 2 Feb 2021 18:08:31 -0500 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BA35C06174A for ; Tue, 2 Feb 2021 15:07:51 -0800 (PST) Received: by mail-io1-xd31.google.com with SMTP id u8so18135677ior.13 for ; Tue, 02 Feb 2021 15:07:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2RjDL0WnIqmbAwIPgih8NIYCRBA1hoXGPmIcl2Uor2U=; b=AuP+ac8MX1RXW6/ifC8coTGHU3fL8jBHv6wyEbBQU82hvYBd6rit1rVBuByKBewk6o aitY6VN9x52QeiYxDvYduMCgBFy0sVnvHldPS8Kx/p3r2hpZu57PJXeSsBeIyrdtCKAi NX6tsa5fKw2/S5yNfEYlCEJp8r6bZqmtgybezkjKSCECCeCL2M57YNPijm4SyRSdtYhc GgEE2dulh2oay46x2vBcTeckCL9Qs1M4g9rpYye3Hd6ubyStkTMehMnvRb//Is7Qx1z1 FSmnnm0YbPnxrkluWvRAA+Zzlovoga/x2e2e/d0zwMkPcrwM4MpRb+EDgbI6z5qT22uH 8xdg== 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=2RjDL0WnIqmbAwIPgih8NIYCRBA1hoXGPmIcl2Uor2U=; b=NDxR8dLAfta9irPHBTtcPHHDLhO6UM5k+2htNKA8vi96ikTUJpCIRZvqEKTWTWsp8L NqHaHpLU+X6NM4Z6XVfDILGXrR8oRbxZdXtGg/otnjfZxI2opreNdUmsX55RJnsaQN5H B6jD/mlvrO9uIv1aLz1ijysiUxez0YVb3ng62DDdnw+YaolwPXIwANSZo5B3syRVp69l s/YgjZ7yILYFUDShpQrKpc3Y3sy1vtwj73XgROYaSriA2o72Tl0h+hoT1J7GGWPO8eh/ uDa5JqzSlreOTHEGkZAOdxL78B+TH2dzwELA7uDgqVbVov0+ocTIwKx1RHZ4pPPlLhf7 u6zw== X-Gm-Message-State: AOAM531So6Ckyb7uvwJ7/v6VyaC/2i2pwSOwi67VcOAO07RC4B39z90e 4XT0/VDnEFx2dNESZv5IKVcrV3sa/SaoQpFWVlWNEA== X-Received: by 2002:a05:6638:42:: with SMTP id a2mr439972jap.99.1612307270724; Tue, 02 Feb 2021 15:07:50 -0800 (PST) MIME-Version: 1.0 References: <20210128224819.2651899-1-axelrasmussen@google.com> <20210128224819.2651899-9-axelrasmussen@google.com> <20210201200654.GI260413@xz-x1> In-Reply-To: <20210201200654.GI260413@xz-x1> From: Axel Rasmussen Date: Tue, 2 Feb 2021 15:07:14 -0800 Message-ID: Subject: Re: [PATCH v3 8/9] userfaultfd: update documentation to describe minor fault handling To: Peter Xu Cc: Alexander Viro , Alexey Dobriyan , Andrea Arcangeli , Andrew Morton , Anshuman Khandual , Catalin Marinas , Chinwen Chang , Huang Ying , Ingo Molnar , Jann Horn , Jerome Glisse , Lokesh Gidra , "Matthew Wilcox (Oracle)" , Michael Ellerman , =?UTF-8?Q?Michal_Koutn=C3=BD?= , Michel Lespinasse , Mike Kravetz , Mike Rapoport , Nicholas Piggin , Shaohua Li , Shawn Anastasio , Steven Rostedt , Steven Price , Vlastimil Babka , LKML , linux-fsdevel@vger.kernel.org, Linux MM , Adam Ruprecht , Cannon Matthews , "Dr . David Alan Gilbert" , David Rientjes , Oliver Upton Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 1, 2021 at 12:07 PM Peter Xu wrote: > > On Thu, Jan 28, 2021 at 02:48:18PM -0800, Axel Rasmussen wrote: > > Reword / reorganize things a little bit into "lists", so new features / > > modes / ioctls can sort of just be appended. > > > > Describe how UFFDIO_REGISTER_MODE_MINOR and UFFDIO_CONTINUE can be used > > to intercept and resolve minor faults. Make it clear that COPY and > > ZEROPAGE are used for MISSING faults, whereas CONTINUE is used for MINOR > > faults. > > Bare with me since I'm not native speaker.. but I'm pointing out things that > reads odd to me. Feel free to argue. :) No worries, that is true for many people in the community. I'm happy to reword to make things as clear as possible. :) > > [...] > > > +Resolving Userfaults > > +-------------------- > > + > > +There are three basic ways to resolve userfaults: > > + > > +- ``UFFDIO_COPY`` atomically copies some existing page contents from > > + userspace. > > + > > +- ``UFFDIO_ZEROPAGE`` atomically zeros the new page. > > + > > +- ``UFFDIO_CONTINUE`` maps an existing, previously-populated page. > > + > > +These operations are atomic in the sense that they guarantee nothing can > > +see a half-populated page, since readers will keep userfaulting until the > > +operation has finished. > > + > > +By default, these wake up userfaults blocked on the range in question. > > +They support a ``UFFDIO_*_MODE_DONTWAKE`` ``mode`` flag, which indicates > > +that waking will be done separately at some later time. > > + > > +Which of these are used depends on the kind of fault: > > Maybe: > > "We should choose the ioctl depending on the kind of the page fault, and what > we'd like to do with it:" > > ? > > > + > > +- For ``UFFDIO_REGISTER_MODE_MISSING`` faults, a new page has to be > > + provided. This can be done with either ``UFFDIO_COPY`` or > > UFFDIO_ZEROPAGE does not need a new page. > > > + ``UFFDIO_ZEROPAGE``. The default (non-userfaultfd) behavior would be to > > + provide a zero page, but in userfaultfd this is left up to userspace. > > "By default, kernel will provide a zero page for a missing fault. With > userfaultfd, the userspace could decide which content to provide before the > faulted thread continues." ? > > > + > > +- For ``UFFDIO_REGISTER_MODE_MINOR`` faults, an existing page already > > "page cache existed"? > > > + exists. Userspace needs to ensure its contents are correct (if it needs > > + to be modified, by writing directly to the non-userfaultfd-registered > > + side of shared memory), and then issue ``UFFDIO_CONTINUE`` to resolve > > + the fault. > > "... Userspace can modify the page content before asking the faulted thread to > continue the fault with UFFDIO_CONTINUE ioctl." ? I agree with all the comments; these areas can be clarified. I didn't take the suggestions exactly as-is, but I did reword these parts in my v4. Let me know if further changes would be useful. > > -- > Peter Xu >