Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4092402pxb; Mon, 1 Feb 2021 12:12:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJyjXNfPiljjHu09icV2nHcOZo5lTSPJwHNBvljxBVwpG/UG9spqIiFl7n8ZbFbi8X+ROC81 X-Received: by 2002:a17:906:225a:: with SMTP id 26mr19717293ejr.477.1612210366572; Mon, 01 Feb 2021 12:12:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612210366; cv=none; d=google.com; s=arc-20160816; b=oDnWe8NWgMtmrr6K27vJgtnUL3xmrVPEFRxi0iXeM/hpcx+WutLb8ugPpGsRIDg5OY r3enDXcTpIopuROwbI0ZHpjHYBwgufVJ+uhQRQTBZSUz736EkgdBhPhEvdGBUQt8jDA6 X4rfCwEy0dn/f7YDBfriPM3nz4NCJRNO0kcBUoxzCDLsZ26YbMNl8OpWPZjvnK6ugShu MedSiF9UuLA7bUSlj1Oea5QkL5KzYb742AHTJGLfeJLMGQTbFJZAkX+OVsffPpw1N+l2 KcmNFESAM5lEpGVwr+JU6N3XtKT0ZNUHKX7ORZr443Rfw/hBIA8mnzLWMYLSvj4IQuvf MJaQ== 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=ZfxwGnD+dy8umn1NYGcjVPYpHw77B9r85fxRnvKqVIE=; b=PrASzVy+UUHZvWOGRRl6yRXCQthT8ZxqlzD8+X2uF63qZdWwxEcFY84z8UPF9jVpSL /7BaNIaTXSuLgcotPODUdYXAMbyfnoDDqgce7TCHNqVzLwhwT6N6q+5hpefUvwGj07FZ 1atCB0GzY2od6ToNsHETGPHK7A/QuEe28XAoOcj1L6vEdp/LCGFtBTbJ0J01lc5BXk7M 0v4gLP5KfvvVlwedhDFt/01AEDiK/uPMqagqkNU845S6H0PsqpXVkOrAeXcQ2169FkL5 MjjUAf0h5mEaHZi06a2RJIdDPqfkqjHp7MShddC0r84QDkFDwg8KHt7I0E0JqMdA5zGa ztqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iT0Yzbdo; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a8si10595898ejk.646.2021.02.01.12.12.22; Mon, 01 Feb 2021 12:12:46 -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=@redhat.com header.s=mimecast20190719 header.b=iT0Yzbdo; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233166AbhBAUJf (ORCPT + 99 others); Mon, 1 Feb 2021 15:09:35 -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-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