Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp270315ybz; Wed, 15 Apr 2020 08:26:30 -0700 (PDT) X-Google-Smtp-Source: APiQypKXLxsTVJ8nVIKiY+XdE5R/j3GpMF8n0fQGIMfboNk/cgyp1gJ+RKtHzaV4oSQZDaRTMNUw X-Received: by 2002:a17:906:1c8a:: with SMTP id g10mr5859929ejh.342.1586964390165; Wed, 15 Apr 2020 08:26:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586964390; cv=none; d=google.com; s=arc-20160816; b=s4hl2Rcd3Fu3Kk71VhgfU9/6HSB3kDmAk5A3uQwJsKSpK9WHbwqIHEliGK8ItzNY6r 6bc73qopjLtz98muIPHyjxEgI/cR2k+v6qHHXWuBv2oSMGAs9yZNJHqk3BMiP3ZHm/wf ZP/0lF6PzXykii1GPMFBQghhMoz9OWabdqGOSq3G5/2XEffedC4dsvNTiIBY8p0MkVLm X8zK+qjuoStY5CUaktMsEj1/pvzvHUj2tL1JviJmD7xYJsS/3c+qJLWcdNK0fx3FECdA B+6pr9n65FeOXqRaOSW8FHoZQ8CmtKP7o4VQbng+bescGkb1vUfVR5u2f9lbyU1KJBFT DgOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:cc:dkim-signature; bh=U8TwIdyAMHCGD65LcfsNv1dps+LWQzXnmih7ivW+iwI=; b=pHK7ekf0r6OEDQyL8xflTbq26nBFHpSLqmHGVV9Gt/hnmQP0jR41w15q2/uiNou4hT PweMaYbfAvhW/GgAwYKKyW6Agsz00fxJnrFarHIpvcUiv1zyD6yWlCPsy4efaoesLYAV NNd6j4FN5iuIV83B5e44LttBhn2GdUwHqtJ/D1EJ2DOzVvK7EzwV/BLGj1n1iTLBewmz b5SqnEcGGmVMQfx1yCbX+oDdi2j2XzPW46uX5RzvSxjqMN9BRQWhnK+FJBYFMlkxMRnI kFP7OsHfp6XU36lvu0m6y2HbJY2ipJTPVKQLJFuHAGV0TqAIi+rDS4lyR8e+0MrqTthN jNtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="pDd/QED2"; spf=pass (google.com: best guess record for 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y16si5386514edw.422.2020.04.15.08.26.01; Wed, 15 Apr 2020 08:26:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for 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=@gmail.com header.s=20161025 header.b="pDd/QED2"; spf=pass (google.com: best guess record for 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390526AbgDOGlI (ORCPT + 99 others); Wed, 15 Apr 2020 02:41:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728535AbgDOGlF (ORCPT ); Wed, 15 Apr 2020 02:41:05 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18F17C061A0C; Tue, 14 Apr 2020 23:41:05 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id b11so6308418wrs.6; Tue, 14 Apr 2020 23:41:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=cc:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=U8TwIdyAMHCGD65LcfsNv1dps+LWQzXnmih7ivW+iwI=; b=pDd/QED2TjetbLunJPMXoJonJRZrJ9PY4pKrJxtGfFhUQWq2acuHke6HxvRkSjpd9F h0rRzz/7dvTAycclwpyau9aCA4yO2DRi+KrIJ7DYl0IaQNStADb56kYbJ8GHzOefaJ/b RmFQKM/nbg9//76cwBBBObTY1D7fvGaAl4V++tLkc1tt86whilA/VF2pn6f1HvnX2KKv m1DJr1yNHzL+EhEGlwDJNyeNbMAIwBuCj1KrE/m/nVaqu+UqbQd4RNDo4lFw6k0v0pkz wFoX8/AoGjbQxkv3oeV/lIoVUsKei7nB6NODKkxVwyowDb2mtT4Ze4YeJZRwOD2uho/M MNAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:cc:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=U8TwIdyAMHCGD65LcfsNv1dps+LWQzXnmih7ivW+iwI=; b=Dt3Udn4DfEZtuD2/0EUXudPy5SBE+0/OHFhYpnzXpGfH4sG1hP24+DqI2+5CNc5Fbk oF8MnHH4H6n7ycS0ZHcfIUXrGlafWEYh3X15yOlSdaYEP+j4V98iIxg9JUXMg5ldnAPg Rt8bJ9qCpeYhEMLki0ng1OwgZURUNk0f1txYqGM4FeKzxpoS0shuAW4u6ZPCTUlBmYPd E7gGQTZH4XXjcX0PHIedn8JOlJJfTzBzebG1xnqsB5o7wjGBHvfDyfFexTjSfgMDyUwt 2o+Q+NYSheB02Hl33kxrTvK47RmN7IHEg6yYxid/YWKA34OLJ3pp5mXiLfkiZwHL9QBq sX9A== X-Gm-Message-State: AGi0PuZD/jTGCuy1kYc8IfnXeQroXIQt3px9BBRaJ9r1ST3/kaBc9KsD HOsRUmJ+PZHnHsx9oylsC6GX9XQl X-Received: by 2002:adf:b1d0:: with SMTP id r16mr6958136wra.312.1586932863432; Tue, 14 Apr 2020 23:41:03 -0700 (PDT) Received: from ?IPv6:2001:a61:2482:101:3351:6160:8173:cc31? ([2001:a61:2482:101:3351:6160:8173:cc31]) by smtp.gmail.com with ESMTPSA id 91sm8073740wra.37.2020.04.14.23.41.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Apr 2020 23:41:02 -0700 (PDT) Cc: mtk.manpages@gmail.com, "Michael S . Tsirkin" , Arnd Bergmann , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-api@vger.kernel.org, Andy Lutomirski , Will Deacon , Andrea Arcangeli , Sonny Rao , Minchan Kim , Joel Fernandes , Yu Zhao , Jesse Barnes , Florian Weimer , "Kirill A . Shutemov" , linux-man@vger.kernel.org Subject: Re: [PATCH v7] mremap.2: Add information for MREMAP_DONTUNMAP. To: Brian Geffon , Andrew Morton References: <20200221174248.244748-1-bgeffon@google.com> <20200221174248.244748-3-bgeffon@google.com> From: "Michael Kerrisk (man-pages)" Message-ID: Date: Wed, 15 Apr 2020 08:40:59 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200221174248.244748-3-bgeffon@google.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Brian, I see that MREMAP_DONTUNMAP has been merged. Thanks for the patch below. In addition to Vlastimil's comments, could you please take a look at my comments below. On 2/21/20 6:42 PM, Brian Geffon wrote: > Signed-off-by: Brian Geffon > --- > man2/mremap.2 | 30 +++++++++++++++++++++++++++++- > 1 file changed, 29 insertions(+), 1 deletion(-) > > diff --git a/man2/mremap.2 b/man2/mremap.2 > index d73fb64fa..54ec67b20 100644 > --- a/man2/mremap.2 > +++ b/man2/mremap.2 > @@ -26,7 +26,8 @@ > .\" 1996-04-12 Tom Bjorkholm > .\" Update for Linux 1.3.87 and later > .\" 2005-10-11 mtk: Added NOTES for MREMAP_FIXED; revised EINVAL text. > -.\" > +.\" 2020-02-05 Brian Geffon > +.\" Update for MREMAP_DONTUNMAP. No need to add this piece. This info is maintained via the Git log these days. > .TH MREMAP 2 2019-03-06 "Linux" "Linux Programmer's Manual" > .SH NAME > mremap \- remap a virtual memory address > @@ -129,6 +130,13 @@ If > is specified, then > .B MREMAP_MAYMOVE > must also be specified. > +.TP > +.BR MREMAP_DONTUNMAP " (since Linux 5.7)" > +This flag which must be used in conjuction with s/conjuction/conjunction/ > +.B MREMAP_MAYMOVE > +remaps a mapping to a new address and it does not unmap the mapping at \fIold_address\fP. This flag can only be used with private anonymous mappings. Any access to the range specified at \fIold_address\fP after completion will result in a page fault. If a Please wrap source lines to no more than about 75 columns. Also, always start new sentences on new lines ("Semantic newlines"). As a general rule, I prefer formatting to be done like this: .BR old_address . rather than: \fIold_address\fP. (Yes, I know there's plenty of existing text that goes the other way, but I try to avoid the \fX...\fP style for new text. Re the "Any access to the range ... will result in a page fault", I think it would be helpful to be more explicit. I presume that if we access the range at old_address the mapping is repopulated with zero-filled pages, right? It would be good to note that explicitly, > +.BR userfaultfd (2) > +was registered on the mapping specified by \fIold_address\fP it will continue to watch that mapping for faults. (See comments above re wrapping and formatting.) Perhaps it would be nice to have a short paragraph on use cases? > .PP > If the memory segment specified by > .I old_address > @@ -176,6 +184,8 @@ a value other than > .B MREMAP_MAYMOVE > or > .B MREMAP_FIXED > +or > +.B MREMAP_DONTUNMAP > was specified in > .IR flags ; > .IP * > @@ -197,9 +207,17 @@ and > .IR old_size ; > .IP * > .B MREMAP_FIXED > +or > +.B MREMAP_DONTUNMAP > was specified without also specifying > .BR MREMAP_MAYMOVE ; > .IP * > +.B MREMAP_DONTUNMAP > +was specified with an \fIold_address\fP that was not private anonymous; > +.IP * > +.B MREMAP_DONTUNMAP > +was specified and \fIold_size\fP was not equal to \fInew_size\fP; > +.IP * > \fIold_size\fP was zero and \fIold_address\fP does not refer to a > shareable mapping (but see BUGS); > .IP * > @@ -209,10 +227,20 @@ flag was not specified. > .RE > .TP > .B ENOMEM > +Not enough memory was available to complete the operation. > +Possible causes are: > +.RS > +.IP * 3 > The memory area cannot be expanded at the current virtual address, and the > .B MREMAP_MAYMOVE > flag is not set in \fIflags\fP. > Or, there is not enough (virtual) memory available. > +.IP * > +.B MREMAP_DONTUNMAP > +was used without > +.B MREMAP_FIXED > +causing a new mapping to be created that would exceed the virtual memory available or it would exceed the maximum number of allowed mappings. (See comments above re wrapping.) > +.RE > .SH CONFORMING TO > This call is Linux-specific, and should not be used in programs > intended to be portable. Thanks, Michael -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/