aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/tile/mm/elf.c1
-rw-r--r--include/linux/mm.h3
-rw-r--r--mm/fremap.c3
-rw-r--r--mm/mmap.c33
4 files changed, 18 insertions, 22 deletions
diff --git a/arch/tile/mm/elf.c b/arch/tile/mm/elf.c
index 3cfa98bf9125..743c951c61b0 100644
--- a/arch/tile/mm/elf.c
+++ b/arch/tile/mm/elf.c
@@ -130,7 +130,6 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
130 if (!retval) { 130 if (!retval) {
131 unsigned long addr = MEM_USER_INTRPT; 131 unsigned long addr = MEM_USER_INTRPT;
132 addr = mmap_region(NULL, addr, INTRPT_SIZE, 132 addr = mmap_region(NULL, addr, INTRPT_SIZE,
133 MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE,
134 VM_READ|VM_EXEC| 133 VM_READ|VM_EXEC|
135 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC, 0); 134 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC, 0);
136 if (addr > (unsigned long) -PAGE_SIZE) 135 if (addr > (unsigned long) -PAGE_SIZE)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index da0a0fe970c2..8332f3069fe3 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1472,8 +1472,7 @@ extern int install_special_mapping(struct mm_struct *mm,
1472extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); 1472extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
1473 1473
1474extern unsigned long mmap_region(struct file *file, unsigned long addr, 1474extern unsigned long mmap_region(struct file *file, unsigned long addr,
1475 unsigned long len, unsigned long flags, 1475 unsigned long len, vm_flags_t vm_flags, unsigned long pgoff);
1476 vm_flags_t vm_flags, unsigned long pgoff);
1477extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr, 1476extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
1478 unsigned long len, unsigned long prot, unsigned long flags, 1477 unsigned long len, unsigned long prot, unsigned long flags,
1479 unsigned long pgoff, bool *populate); 1478 unsigned long pgoff, bool *populate);
diff --git a/mm/fremap.c b/mm/fremap.c
index b42e32171530..503a72387087 100644
--- a/mm/fremap.c
+++ b/mm/fremap.c
@@ -204,9 +204,8 @@ get_write_lock:
204 unsigned long addr; 204 unsigned long addr;
205 struct file *file = get_file(vma->vm_file); 205 struct file *file = get_file(vma->vm_file);
206 206
207 flags = (flags & MAP_NONBLOCK) | MAP_POPULATE;
208 addr = mmap_region(file, start, size, 207 addr = mmap_region(file, start, size,
209 flags, vma->vm_flags, pgoff); 208 vma->vm_flags, pgoff);
210 fput(file); 209 fput(file);
211 if (IS_ERR_VALUE(addr)) { 210 if (IS_ERR_VALUE(addr)) {
212 err = addr; 211 err = addr;
diff --git a/mm/mmap.c b/mm/mmap.c
index a23e30f9719c..d6bc39e939ab 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1291,7 +1291,21 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
1291 } 1291 }
1292 } 1292 }
1293 1293
1294 addr = mmap_region(file, addr, len, flags, vm_flags, pgoff); 1294 /*
1295 * Set 'VM_NORESERVE' if we should not account for the
1296 * memory use of this mapping.
1297 */
1298 if (flags & MAP_NORESERVE) {
1299 /* We honor MAP_NORESERVE if allowed to overcommit */
1300 if (sysctl_overcommit_memory != OVERCOMMIT_NEVER)
1301 vm_flags |= VM_NORESERVE;
1302
1303 /* hugetlb applies strict overcommit unless MAP_NORESERVE */
1304 if (file && is_file_hugepages(file))
1305 vm_flags |= VM_NORESERVE;
1306 }
1307
1308 addr = mmap_region(file, addr, len, vm_flags, pgoff);
1295 if (!IS_ERR_VALUE(addr) && 1309 if (!IS_ERR_VALUE(addr) &&
1296 ((vm_flags & VM_LOCKED) || 1310 ((vm_flags & VM_LOCKED) ||
1297 (flags & (MAP_POPULATE | MAP_NONBLOCK)) == MAP_POPULATE)) 1311 (flags & (MAP_POPULATE | MAP_NONBLOCK)) == MAP_POPULATE))
@@ -1411,8 +1425,7 @@ static inline int accountable_mapping(struct file *file, vm_flags_t vm_flags)
1411} 1425}
1412 1426
1413unsigned long mmap_region(struct file *file, unsigned long addr, 1427unsigned long mmap_region(struct file *file, unsigned long addr,
1414 unsigned long len, unsigned long flags, 1428 unsigned long len, vm_flags_t vm_flags, unsigned long pgoff)
1415 vm_flags_t vm_flags, unsigned long pgoff)
1416{ 1429{
1417 struct mm_struct *mm = current->mm; 1430 struct mm_struct *mm = current->mm;
1418 struct vm_area_struct *vma, *prev; 1431 struct vm_area_struct *vma, *prev;
@@ -1436,20 +1449,6 @@ munmap_back:
1436 return -ENOMEM; 1449 return -ENOMEM;
1437 1450
1438 /* 1451 /*
1439 * Set 'VM_NORESERVE' if we should not account for the
1440 * memory use of this mapping.
1441 */
1442 if ((flags & MAP_NORESERVE)) {
1443 /* We honor MAP_NORESERVE if allowed to overcommit */
1444 if (sysctl_overcommit_memory != OVERCOMMIT_NEVER)
1445 vm_flags |= VM_NORESERVE;
1446
1447 /* hugetlb applies strict overcommit unless MAP_NORESERVE */
1448 if (file && is_file_hugepages(file))
1449 vm_flags |= VM_NORESERVE;
1450 }
1451
1452 /*
1453 * Private writable mapping: check memory availability 1452 * Private writable mapping: check memory availability
1454 */ 1453 */
1455 if (accountable_mapping(file, vm_flags)) { 1454 if (accountable_mapping(file, vm_flags)) {