aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Kwapulinski <kwapulinski.piotr@gmail.com>2015-06-24 19:58:39 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-06-24 20:49:45 -0400
commite37609bb36f706c954e82e580e2e790e9d5caef8 (patch)
tree59b5af0dc55b58fc8b4c0ce68507b3ee5afb687b
parent93ada579b0eea06f808aef08ead64bb230fb7851 (diff)
mm/mmap.c: optimization of do_mmap_pgoff function
The simple check for zero length memory mapping may be performed earlier. So 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> Acked-by: Michal Hocko <mhocko@suse.cz> Acked-by: Rik van Riel <riel@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/mmap.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/mm/mmap.c b/mm/mmap.c
index bb50cacc3ea5..aa632ade2be7 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1258,6 +1258,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
1258 1258
1259 *populate = 0; 1259 *populate = 0;
1260 1260
1261 if (!len)
1262 return -EINVAL;
1263
1261 /* 1264 /*
1262 * Does the application expect PROT_READ to imply PROT_EXEC? 1265 * Does the application expect PROT_READ to imply PROT_EXEC?
1263 * 1266 *
@@ -1268,9 +1271,6 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
1268 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC))) 1271 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
1269 prot |= PROT_EXEC; 1272 prot |= PROT_EXEC;
1270 1273
1271 if (!len)
1272 return -EINVAL;
1273
1274 if (!(flags & MAP_FIXED)) 1274 if (!(flags & MAP_FIXED))
1275 addr = round_hint_to_min(addr); 1275 addr = round_hint_to_min(addr);
1276 1276