From: Piotr Kwapulinski <kwapulinski.piotr@gmail.com>
To: akpm@linux-foundation.org
Cc: kirill.shutemov@linux.intel.com, riel@redhat.com, mhocko@suse.cz,
sasha.levin@oracle.com, dave@stgolabs.net, koct9i@gmail.com,
pfeiner@google.com, dh.herrmann@gmail.com, vishnu.ps@samsung.com,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Piotr Kwapulinski <kwapulinski.piotr@gmail.com>
Subject: [PATCH] mm/mmap.c: optimization of do_mmap_pgoff function
Date: Sat, 6 Jun 2015 11:54:32 +0200 [thread overview]
Message-ID: <1433584472-19151-1-git-send-email-kwapulinski.piotr@gmail.com> (raw)
The simple check for zero length memory mapping may be performed
earlier. It causes that in case of zero length memory mapping some
unnecessary code is not executed at all. It does not make the code less
readable and saves some CPU cycles.
Signed-off-by: Piotr Kwapulinski <kwapulinski.piotr@gmail.com>
---
mm/mmap.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mm/mmap.c b/mm/mmap.c
index bb50cac..aa632ad 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1258,6 +1258,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
*populate = 0;
+ if (!len)
+ return -EINVAL;
+
/*
* Does the application expect PROT_READ to imply PROT_EXEC?
*
@@ -1268,9 +1271,6 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
prot |= PROT_EXEC;
- if (!len)
- return -EINVAL;
-
if (!(flags & MAP_FIXED))
addr = round_hint_to_min(addr);
--
2.3.7
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2015-06-06 9:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-06 9:54 Piotr Kwapulinski [this message]
2015-06-08 8:17 ` [PATCH] mm/mmap.c: optimization of do_mmap_pgoff function Michal Hocko
2015-06-08 15:42 ` Rik van Riel
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=1433584472-19151-1-git-send-email-kwapulinski.piotr@gmail.com \
--to=kwapulinski.piotr@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=dave@stgolabs.net \
--cc=dh.herrmann@gmail.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=koct9i@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.cz \
--cc=pfeiner@google.com \
--cc=riel@redhat.com \
--cc=sasha.levin@oracle.com \
--cc=vishnu.ps@samsung.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;
as well as URLs for NNTP newsgroup(s).