|
@@ -1291,7 +1291,21 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- addr = mmap_region(file, addr, len, flags, vm_flags, pgoff);
|
|
|
+ /*
|
|
|
+ * Set 'VM_NORESERVE' if we should not account for the
|
|
|
+ * memory use of this mapping.
|
|
|
+ */
|
|
|
+ if (flags & MAP_NORESERVE) {
|
|
|
+ /* We honor MAP_NORESERVE if allowed to overcommit */
|
|
|
+ if (sysctl_overcommit_memory != OVERCOMMIT_NEVER)
|
|
|
+ vm_flags |= VM_NORESERVE;
|
|
|
+
|
|
|
+ /* hugetlb applies strict overcommit unless MAP_NORESERVE */
|
|
|
+ if (file && is_file_hugepages(file))
|
|
|
+ vm_flags |= VM_NORESERVE;
|
|
|
+ }
|
|
|
+
|
|
|
+ addr = mmap_region(file, addr, len, vm_flags, pgoff);
|
|
|
if (!IS_ERR_VALUE(addr) &&
|
|
|
((vm_flags & VM_LOCKED) ||
|
|
|
(flags & (MAP_POPULATE | MAP_NONBLOCK)) == MAP_POPULATE))
|
|
@@ -1411,8 +1425,7 @@ static inline int accountable_mapping(struct file *file, vm_flags_t vm_flags)
|
|
|
}
|
|
|
|
|
|
unsigned long mmap_region(struct file *file, unsigned long addr,
|
|
|
- unsigned long len, unsigned long flags,
|
|
|
- vm_flags_t vm_flags, unsigned long pgoff)
|
|
|
+ unsigned long len, vm_flags_t vm_flags, unsigned long pgoff)
|
|
|
{
|
|
|
struct mm_struct *mm = current->mm;
|
|
|
struct vm_area_struct *vma, *prev;
|
|
@@ -1435,20 +1448,6 @@ munmap_back:
|
|
|
if (!may_expand_vm(mm, len >> PAGE_SHIFT))
|
|
|
return -ENOMEM;
|
|
|
|
|
|
- /*
|
|
|
- * Set 'VM_NORESERVE' if we should not account for the
|
|
|
- * memory use of this mapping.
|
|
|
- */
|
|
|
- if ((flags & MAP_NORESERVE)) {
|
|
|
- /* We honor MAP_NORESERVE if allowed to overcommit */
|
|
|
- if (sysctl_overcommit_memory != OVERCOMMIT_NEVER)
|
|
|
- vm_flags |= VM_NORESERVE;
|
|
|
-
|
|
|
- /* hugetlb applies strict overcommit unless MAP_NORESERVE */
|
|
|
- if (file && is_file_hugepages(file))
|
|
|
- vm_flags |= VM_NORESERVE;
|
|
|
- }
|
|
|
-
|
|
|
/*
|
|
|
* Private writable mapping: check memory availability
|
|
|
*/
|