From: "Keppel, Pardo" <pardo.keppel@intel.com>
To: "linux-mm@kvack.org" <linux-mm@kvack.org>,
"mtk.manpages@gmail.com" <mtk.manpages@gmail.com>
Cc: "Hansen, Dave" <dave.hansen@intel.com>,
"Keppel, Pardo" <pardo.keppel@intel.com>
Subject: [patch] mremap.2: Note/clarify "partial completion" on errors
Date: Tue, 27 Aug 2019 23:57:13 +0000 [thread overview]
Message-ID: <388C0EB820381246B2BFD2C7583B3ECBAA1EE1FA@ORSMSX121.amr.corp.intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 761 bytes --]
When using mremap() with MREMAP_FIXED and bad parameters, mremap()
returns EINVAL, which is expected; but it also unmaps existing regions
at 'new_address', which surprised me. I had expected that on EINVAL,
mappings at 'new_address' would remain unmodified.
The current behavior is reasonable, but it was surprising to me, so it might
be surprising to others. The man page DESCRIPTION currently says:
"Any previous mapping at the address range specified by new_address
and new_size is unmapped."
It would be clearer to me if it also said something like:
"Previous mappings may be unmapped even if mremap() returns an error."
And/or if ERRORS said something about this behavior.
A sample patch for man2/mremap.2 is attached.
[-- Attachment #2: mremap.2.patch --]
[-- Type: application/octet-stream, Size: 788 bytes --]
diff --git a/man2/mremap.2 b/man2/mremap.2
index d73fb64fa..f6408a5c9 100644
--- a/man2/mremap.2
+++ b/man2/mremap.2
@@ -124,6 +124,9 @@ Any previous mapping at the address range specified by
and
.I new_size
is unmapped.
+Previous mappings may be unmapped even if
+.BR mremap ()
+returns an error.
If
.B MREMAP_FIXED
is specified, then
@@ -148,6 +151,16 @@ On error, the value
(that is, \fI(void\ *)\ \-1\fP) is returned,
and \fIerrno\fP is set appropriately.
.SH ERRORS
+On errors,
+.BR mremap ()
+may perform
+.I partial completion
+where some but not all side-effects occur.
+For example, with
+.BR MREMAP_FIXED ,
+mappings at
+.B new_address
+may be unmapped, with no new mappings to replace them.
.TP
.B EAGAIN
The caller tried to expand a memory segment that is locked,
reply other threads:[~2019-08-27 23:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=388C0EB820381246B2BFD2C7583B3ECBAA1EE1FA@ORSMSX121.amr.corp.intel.com \
--to=pardo.keppel@intel.com \
--cc=dave.hansen@intel.com \
--cc=linux-mm@kvack.org \
--cc=mtk.manpages@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox