linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Nikita Ermakov <sh1r4s3@mail.si-head.nl>
To: linux-mm@kvack.org
Cc: Nikita Ermakov <sh1r4s3@mail.si-head.nl>,
	Andrew Morton <akpm@linux-foundation.org>,
	Vlastimil Babka <vbabka@suse.cz>
Subject: [PATCH v3] mm/msync: exit early when the flags is an MS_ASYNC and start < vm_start
Date: Sun, 25 Oct 2020 12:29:01 +0300	[thread overview]
Message-ID: <20201025092901.56399-1-sh1r4s3@mail.si-head.nl> (raw)
In-Reply-To: <bb6e370a-8901-5db0-1057-90414ea085e2@suse.cz>

If an unmapped region was found and the flag is MS_ASYNC (without
MS_INVALIDATE) there is nothing to do and the result would be always
-ENOMEM, so return immediately.

Signed-off-by: Nikita Ermakov <sh1r4s3@mail.si-head.nl>
---
 mm/msync.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/mm/msync.c b/mm/msync.c
index 69c6d2029531..137d1c104f3e 100644
--- a/mm/msync.c
+++ b/mm/msync.c
@@ -55,7 +55,9 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
 		goto out;
 	/*
 	 * If the interval [start,end) covers some unmapped address ranges,
-	 * just ignore them, but return -ENOMEM at the end.
+	 * just ignore them, but return -ENOMEM at the end. Besides, if the
+	 * flag is MS_ASYNC (w/o MS_INVALIDATE) the result would be -ENOMEM
+	 * anyway and there is nothing left to do, so return immediately.
 	 */
 	mmap_read_lock(mm);
 	vma = find_vma(mm, start);
@@ -69,6 +71,8 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
 			goto out_unlock;
 		/* Here start < vma->vm_end. */
 		if (start < vma->vm_start) {
+			if (flags == MS_ASYNC)
+				goto out_unlock;
 			start = vma->vm_start;
 			if (start >= end)
 				goto out_unlock;

base-commit: 6824a8a9b4861d7df7ee132a952bdf6f84a99cb8
-- 
2.28.0



  reply	other threads:[~2020-10-25  9:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-12 16:09 [PATCH] mm/msync: exit early when the flags is an MS_ASYNC and start < vm_start Nikita Ermakov
2020-10-20 10:19 ` Vlastimil Babka
2020-10-20 14:38   ` Nikita
2020-10-20 15:03     ` Vlastimil Babka
2020-10-20 16:19       ` Nikita
2020-10-20 20:56         ` [PATCH v2] " Nikita Ermakov
2020-10-23 11:12           ` Vlastimil Babka
2020-10-25  9:29             ` Nikita Ermakov [this message]
2020-10-25  9:38             ` Nikita Ermakov

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=20201025092901.56399-1-sh1r4s3@mail.si-head.nl \
    --to=sh1r4s3@mail.si-head.nl \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=vbabka@suse.cz \
    /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;
as well as URLs for NNTP newsgroup(s).