Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1038959AbdDULl0 (ORCPT ); Fri, 21 Apr 2017 07:41:26 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:33786 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1038943AbdDULlY (ORCPT ); Fri, 21 Apr 2017 07:41:24 -0400 Subject: Re: Review request: draft ioctl_userfaultfd(2) manual page To: Mike Rapoport References: <487b2c79-f99b-6d0f-2412-aa75cde65569@gmail.com> <9af29fc6-dce2-f729-0f07-a0bfcc6c3587@gmail.com> <20170322135423.GB27789@rapoport-lnx> <20170421110714.GC20569@rapoport-lnx> Cc: mtk.manpages@gmail.com, Andrea Arcangeli , lkml , "linux-mm@kvack.org" , linux-man From: "Michael Kerrisk (man-pages)" Message-ID: <4c05c2bb-af77-d706-9455-8ceaa5510580@gmail.com> Date: Fri, 21 Apr 2017 13:41:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20170421110714.GC20569@rapoport-lnx> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8967 Lines: 216 Hi Mike, On 04/21/2017 01:07 PM, Mike Rapoport wrote: > Hello Michael, > > On Fri, Apr 21, 2017 at 11:11:18AM +0200, Michael Kerrisk (man-pages) wrote: >> Hello Mike, >> Hello Andrea (we need your help!), >> >> On 03/22/2017 02:54 PM, Mike Rapoport wrote: >>> Hello Michael, >>> >>> On Mon, Mar 20, 2017 at 09:11:07PM +0100, Michael Kerrisk (man-pages) wrote: >>>> Hello Andrea, Mike, and all, >>>> >>>> Mike: here's the split out page that describes the >>>> userfaultfd ioctl() operations. >>>> >>>> I'd like to get review input, especially from you and >>>> Andrea, but also anyone else, for the current version >>>> of this page, which includes quite a few FIXMEs to be >>>> sorted. >>>> >>>> I've shown the rendered version of the page below. >>>> The groff source is attached, and can also be found >>>> at the branch here: >>>> >>>> https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/log/?h=draft_userfaultfd >>>> >>>> The new ioctl_userfaultfd(2) page follows this mail. >>>> >>>> Cheers, >>>> >>>> Michael >>>> >>>> NAME >>>> userfaultfd - create a file descriptor for handling page faults in user >>>> space >>>> >>>> SYNOPSIS >>>> #include >>>> >>>> int ioctl(int fd, int cmd, ...); >>>> >>>> DESCRIPTION >>>> Various ioctl(2) operations can be performed on a userfaultfd object >>>> (created by a call to userfaultfd(2)) using calls of the form: >>>> >>>> ioctl(fd, cmd, argp); >>>> >>>> In the above, fd is a file descriptor referring to a userfaultfd >>>> object, cmd is one of the commands listed below, and argp is a pointer >>>> to a data structure that is specific to cmd. >>>> >>>> The various ioctl(2) operations are described below. The UFFDIO_API, >>>> UFFDIO_REGISTER, and UFFDIO_UNREGISTER operations are used to configure >>>> userfaultfd behavior. These operations allow the caller to choose what >>>> features will be enabled and what kinds of events will be delivered to >>>> the application. The remaining operations are range operations. These >>>> operations enable the calling application to resolve page-fault events >>>> in a consistent way. >>>> >>>> >>>> ┌─────────────────────────────────────────────────────┐ >>>> │FIXME │ >>>> ├─────────────────────────────────────────────────────┤ >>>> │Above: What does "consistent" mean? │ >>>> │ │ >>>> └─────────────────────────────────────────────────────┘ >>> >>> Andrea, can you please help with this one? >> >> Let's see what Andrea has to say. > > Actually, I though I've copied this text from Andrea's docs, but now I've > found out it was my wording and I really don't remember now what was my > intention for "consistent" :) > My guess is that I was thinking about atomicity of UFFDIO_COPY, or the fact > that from the faulting thread perspective the page fault handling is the > same whether it's done in kernel or via userfaultfd... > That said, maybe it'd be better just to drop "in a consistent way". Okay. Dropped. >>>> UFFDIO_API >>>> (Since Linux 4.3.) Enable operation of the userfaultfd and perform API >>>> handshake. The argp argument is a pointer to a uffdio_api structure, >>>> defined as: >>>> >>>> struct uffdio_api { >>>> __u64 api; /* Requested API version (input) */ >>>> __u64 features; /* Must be zero */ >>>> __u64 ioctls; /* Available ioctl() operations (output) */ >>>> }; >>>> >>>> The api field denotes the API version requested by the application. >>>> Before the call, the features field must be initialized to zero. >>>> >>>> >>>> ┌─────────────────────────────────────────────────────┐ >>>> │FIXME │ >>>> ├─────────────────────────────────────────────────────┤ >>>> │Above: Why must the 'features' field be initialized │ >>>> │to zero? │ >>>> └─────────────────────────────────────────────────────┘ >>> >>> Until 4.11 the only supported feature is delegation of missing page fault >>> and the UFFDIO_FEATURES bitmask is 0. >> >> So, the thing that was not clear, but now I think I understand: >> 'features' is an input field where one can ask about supported features >> (but none are supported, before Linux 4.11). Is that correct? > > Yes. Thanks. >> I've changed the text here to read: >> >> Before the call, the features field must be initialized >> to zero. In the future, it is intended that this field can be >> used to ask whether particular features are supported. >> >> Seem okay? > > Yes. > Just the future is only a week or two from today as we are at 4.11-rc7 :) Yes, I understand :-). So of course there's a *lot* more new stuff to document, right? [...] >>>> UFFDIO_REGISTER [...] >>>> EINVAL There as an incompatible mapping in the specified address range. >>>> >>>> >>>> ┌─────────────────────────────────────────────────────┐ >>>> │FIXME │ >>>> ├─────────────────────────────────────────────────────┤ >>>> │Above: What does "incompatible" mean? │ >>>> │ │ >>>> └─────────────────────────────────────────────────────┘ >>> >>> Up to 4.10 userfault context may be registered only for MAP_ANONYMOUS | >>> MAP_PRIVATE mappings. >> >> Hmmm -- this restriction is not actually mentioned in the description >> of UFFDIO_REGISTER. So, at the start of the description of that operation, >> I've made the text as follows: >> >> [[ >> .SS UFFDIO_REGISTER >> (Since Linux 4.3.) >> Register a memory address range with the userfaultfd object. >> The pages in the range must be "compatible". >> In the current implementation, >> .\" According to Mike Rapoport, this will change in Linux 4.11. >> only private anonymous ranges are compatible for registering with >> .BR UFFDIO_REGISTER . >> ]] >> >> Okay? > > Yes. Thanks for checking it. >>>> UFFDIO_UNREGISTER [...] >>>> EINVAL There as an incompatible mapping in the specified address range. >>>> >>>> >>>> ┌─────────────────────────────────────────────────────┐ >>>> │FIXME │ >>>> ├─────────────────────────────────────────────────────┤ >>>> │Above: What does "incompatible" mean? │ >>>> └─────────────────────────────────────────────────────┘ >>> >>> The same comments as for UFFDIO_REGISTER apply here as well. >> >> Okay. I changed the introductory text on UFFDIO_UNREGISTER to say: >> >> [[ >> .SS UFFDIO_UNREGISTER >> (Since Linux 4.3.) >> Unregister a memory address range from userfaultfd. >> The pages in the range must be "compatible" (see the description of >> .BR UFFDIO_REGISTER .) >> ]] >> >> Okay? > > Yes. Thanks. [...] The current version of the two pages has been pushed to https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/log/?h=draft_userfaultfd Cheers, Michael -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/