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=-6.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 C4D53C433E0 for ; Mon, 1 Feb 2021 20:10:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D20A64D9C for ; Mon, 1 Feb 2021 20:10:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232531AbhBAUJx (ORCPT ); Mon, 1 Feb 2021 15:09:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:31161 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232601AbhBAUJC (ORCPT ); Mon, 1 Feb 2021 15:09:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612210050; 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=ZfxwGnD+dy8umn1NYGcjVPYpHw77B9r85fxRnvKqVIE=; b=iT0Yzbdokxw5VsERCRliWZwcA+FL6gOMAAWFPbU6saYgnAl/OoN9hqrZ/iVmE+tB4HWu4s 9qlSaCyhUHxp+S1XeI++nQ6IlbMQmu+EHiAEd7yPB8IE7LELtlrda1HreW41USN1izvroM NAipySek8tVUz3n6mJUm0DKqUYJUKXU= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-160-ytXvpzX9NPaN_x5EQ4aXHQ-1; Mon, 01 Feb 2021 15:06:58 -0500 X-MC-Unique: ytXvpzX9NPaN_x5EQ4aXHQ-1 Received: by mail-qk1-f198.google.com with SMTP id v130so14166250qkb.14 for ; Mon, 01 Feb 2021 12:06:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ZfxwGnD+dy8umn1NYGcjVPYpHw77B9r85fxRnvKqVIE=; b=jRoZHNK30GCMgbWVRiGnDW2YQx/l1x4/SFqNARMdingpFHO1PNJEzbPNFvk+y/s7qN hluw1Wn7KOGsI8OJJgMNpNhUMM1Kf+N2NQVezMPc0lv6DL+uiiltr6bLeVGk0SA1d65x l89C0T5f9TWMPvcQMYvAG3T5FXQJ8HxVYeEpMSd57JhwLEya3Rt6QIwOw5Uh8pAU0aA/ sMglDWSKTGbFZekRkf6/sHK3Xr9Wae2f+OpoAi736Cl/iH4E5qQSOyJmToHutSwK54l8 END4zZoVPi4iXddv7sW3yL4zolUAIpyaCuLabE+rTVh4CkMBN8MdSRrWNCvouDTOdjcS GKaA== X-Gm-Message-State: AOAM531WTdGLWMl6qdkE7V/YDxZQHKqqsQxhFH5EA+IYx+YKI4Y7jV9+ dw7a983NXqQG8VE9P1zzY3UaFAB+9PMQnu0SaCeGr7WtpggIEr9x31iManPjCxlpVTccSHCDKzh 4RJK4ZScdKgvWM6bjhqm5HcjI X-Received: by 2002:ad4:48c8:: with SMTP id v8mr16720959qvx.38.1612210018039; Mon, 01 Feb 2021 12:06:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwHHxydcBEc3CJJbewLgzu9DZ1H4bSs28KW+16tXmuMDdFdnbUkwBL/eKC15pCMhCXHwbCWyw== X-Received: by 2002:ad4:48c8:: with SMTP id v8mr16720926qvx.38.1612210017772; Mon, 01 Feb 2021 12:06:57 -0800 (PST) Received: from xz-x1 ([142.126.83.202]) by smtp.gmail.com with ESMTPSA id z8sm14666242qtu.10.2021.02.01.12.06.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 12:06:57 -0800 (PST) Date: Mon, 1 Feb 2021 15:06:54 -0500 From: Peter Xu To: Axel Rasmussen 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 , Michal =?utf-8?Q?Koutn=C3=BD?= , Michel Lespinasse , Mike Kravetz , Mike Rapoport , Nicholas Piggin , Shaohua Li , Shawn Anastasio , Steven Rostedt , Steven Price , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Adam Ruprecht , Cannon Matthews , "Dr . David Alan Gilbert" , David Rientjes , Oliver Upton Subject: Re: [PATCH v3 8/9] userfaultfd: update documentation to describe minor fault handling Message-ID: <20210201200654.GI260413@xz-x1> References: <20210128224819.2651899-1-axelrasmussen@google.com> <20210128224819.2651899-9-axelrasmussen@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210128224819.2651899-9-axelrasmussen@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. :) [...] > +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." ? -- Peter Xu