From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2455C433E6 for ; Tue, 2 Feb 2021 23:07:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3388064F74 for ; Tue, 2 Feb 2021 23:07:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3388064F74 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 82C7D6B0006; Tue, 2 Feb 2021 18:07:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7DBAE6B006C; Tue, 2 Feb 2021 18:07:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6CB876B006E; Tue, 2 Feb 2021 18:07:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0100.hostedemail.com [216.40.44.100]) by kanga.kvack.org (Postfix) with ESMTP id 538E96B0006 for ; Tue, 2 Feb 2021 18:07:52 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 1AE06181AEF1A for ; Tue, 2 Feb 2021 23:07:52 +0000 (UTC) X-FDA: 77774867184.23.laugh04_1612e5c275ce Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id EDA5F37604 for ; Tue, 2 Feb 2021 23:07:51 +0000 (UTC) X-HE-Tag: laugh04_1612e5c275ce X-Filterd-Recvd-Size: 6928 Received: from mail-io1-f54.google.com (mail-io1-f54.google.com [209.85.166.54]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Tue, 2 Feb 2021 23:07:51 +0000 (UTC) Received: by mail-io1-f54.google.com with SMTP id f8so2748786ion.4 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=pTUmnBdZ734h0p6zYvMLGH3LaYLfySqayRy2WThE5LEvFhBCrrebkpHUc8QVShAoss Z+F/khQ537bnXmSWZvTeffqEyW/XP03lsBYBOKRpYPEF9aaTPIlpFGSUopbFpoi5/B7b nYpvpK7MM8JClFxBy2IBudwUF4hVUM74caa+VSfoC+MSO8QVDqyUlTMBopHDYl5KYHn8 JAtW8IEztOqQW1QkQOBtqC+jvDxjjXF/up9Y1SCWZtz+yE0XbV00R8svbIq8HxgSpspc CMq3MkmhwaGmEiQvzIL2xEw2H8rhIoR9OgcgVyzi10hf6JvRSS+JtMMyV9rE4pKxXOew /eoA== X-Gm-Message-State: AOAM531gP46bywc3AS7J5ZOxTn5ri0AEGM++1WjQ46ML9OOTXcUf81q5 BpXwlwOorTUtlc7EBBeFRWTtl6OWPKPT2tVrx2Cydw== X-Google-Smtp-Source: ABdhPJztP8LUhXfkazYWFZECOAUKSzySbZT98LdOhvVXwQEBFs1RSta8vgRMJnvF71MgjNkzFAYRV7eTijoN89AuLRw= 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" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 >