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 173A0C433E0 for ; Mon, 1 Feb 2021 20:07:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8C75A64EA2 for ; Mon, 1 Feb 2021 20:07:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8C75A64EA2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CBAD96B0075; Mon, 1 Feb 2021 15:07:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C6B5E6B0080; Mon, 1 Feb 2021 15:07:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B839C6B0082; Mon, 1 Feb 2021 15:07:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0187.hostedemail.com [216.40.44.187]) by kanga.kvack.org (Postfix) with ESMTP id A13036B0075 for ; Mon, 1 Feb 2021 15:07:01 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 6963A181AEF15 for ; Mon, 1 Feb 2021 20:07:01 +0000 (UTC) X-FDA: 77770782642.03.care68_3b070e5275c5 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 4407A28A4E8 for ; Mon, 1 Feb 2021 20:07:01 +0000 (UTC) X-HE-Tag: care68_3b070e5275c5 X-Filterd-Recvd-Size: 7148 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Mon, 1 Feb 2021 20:07:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612210020; 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=Maan9w27IcYibL5YxbreY8x/KO9s5dEoL3R4LjK02aNMT301H8bmSviqQIX+pNLqFYexyO OnvopLoUwI5w+D3jp3xnLda7V3hTmOuimyfRUExPQOQ712Sp9fNrFWf1hsoa1iyboZyuLi D4qltanbkdTjdsOm2FP7cWPhDhAc+1w= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-378-wDu9DAQGOmyXRIdaCwhS9A-1; Mon, 01 Feb 2021 15:06:58 -0500 X-MC-Unique: wDu9DAQGOmyXRIdaCwhS9A-1 Received: by mail-qv1-f71.google.com with SMTP id l3so12111964qvz.12 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=BoOFXF4oUkMnuwH3HCx+krUFP6c1Uecf8SqhQJZWznLLQEFDFmEy8DPETZxx9H8vZB jj2m2vRFTU1gSqEVodKWIyIutYMpSFGPK/wxDFnwgKQfoVjEXN0zVx4P+/Iututcx6k3 NFL7y0WczaCu38JMML5Kv4aKdsKOGHm1zLd6ACh9v+n19nSOi/HmUZ1xDyQy2zUfF2Rb PDS+z1aWPtrF+VQ8rktXn9EtWbqlA7QSP04NrRe/9W5387I6gB7bvmSeF2QqViy5Fut8 V+turZMK3jPy11W9ML/McP3Prk0kEwvPqQBPwjWz89K+GNf3hDCHlKlO+4yd2APW9ZMJ PrtQ== X-Gm-Message-State: AOAM531M/Y5YYhob7LrGebyeRCignSi7/KgJqMCCPUfU3Ma9jYaQlah8 2DRlpe+QrL0ZdjLJ7zJR8SE8ZesnuohQtQ9YUHzFIIW8AP8c9Y93FJUm48ia1Y7Su8IkvCJZPbJ nRBqlWwY0lUI= X-Received: by 2002:ad4:48c8:: with SMTP id v8mr16720972qvx.38.1612210018061; 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 In-Reply-To: <20210128224819.2651899-9-axelrasmussen@google.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline 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 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