From: Michel Lespinasse <walken@google.com>
To: Andy Lutomirski <luto@amacapital.net>,
Ingo Molnar <mingo@kernel.org>, Al Viro <viro@zeniv.linux.org.uk>,
Hugh Dickins <hughd@google.com>, Jorn_Engel <joern@logfs.org>,
Rik van Riel <riel@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH 7/9] mm: remove flags argument to mmap_region
Date: Thu, 20 Dec 2012 16:49:55 -0800 [thread overview]
Message-ID: <1356050997-2688-8-git-send-email-walken@google.com> (raw)
In-Reply-To: <1356050997-2688-1-git-send-email-walken@google.com>
After the MAP_POPULATE handling has been moved to mmap_region() call sites,
the only remaining use of the flags argument is to pass the MAP_NORESERVE
flag. This can be just as easily handled by do_mmap_pgoff(), so do that
and remove the mmap_region() flags parameter.
Signed-off-by: Michel Lespinasse <walken@google.com>
---
arch/tile/mm/elf.c | 1 -
include/linux/mm.h | 3 +--
mm/fremap.c | 3 +--
mm/mmap.c | 33 ++++++++++++++++-----------------
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,
if (!retval) {
unsigned long addr = MEM_USER_INTRPT;
addr = mmap_region(NULL, addr, INTRPT_SIZE,
- MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE,
VM_READ|VM_EXEC|
VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC, 0);
if (addr > (unsigned long) -PAGE_SIZE)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index fea461cd9027..3b2912f6e91a 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1442,8 +1442,7 @@ extern int install_special_mapping(struct mm_struct *mm,
extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
extern 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);
extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
unsigned long len, unsigned long prot, unsigned long flags,
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:
unsigned long addr;
struct file *file = get_file(vma->vm_file);
- flags = (flags & MAP_NONBLOCK) | MAP_POPULATE;
addr = mmap_region(file, start, size,
- flags, vma->vm_flags, pgoff);
+ vma->vm_flags, pgoff);
fput(file);
if (IS_ERR_VALUE(addr)) {
err = addr;
diff --git a/mm/mmap.c b/mm/mmap.c
index 4c8d39e64e80..b0a341e5685f 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1138,7 +1138,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))
@@ -1257,8 +1271,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;
@@ -1282,20 +1295,6 @@ munmap_back:
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
*/
if (accountable_mapping(file, vm_flags)) {
--
1.7.7.3
--
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>
WARNING: multiple messages have this Message-ID (diff)
From: Michel Lespinasse <walken@google.com>
To: Andy Lutomirski <luto@amacapital.net>,
Ingo Molnar <mingo@kernel.org>, Al Viro <viro@zeniv.linux.org.uk>,
Hugh Dickins <hughd@google.com>, Jorn_Engel <joern@logfs.org>,
Rik van Riel <riel@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH 7/9] mm: remove flags argument to mmap_region
Date: Thu, 20 Dec 2012 16:49:55 -0800 [thread overview]
Message-ID: <1356050997-2688-8-git-send-email-walken@google.com> (raw)
In-Reply-To: <1356050997-2688-1-git-send-email-walken@google.com>
After the MAP_POPULATE handling has been moved to mmap_region() call sites,
the only remaining use of the flags argument is to pass the MAP_NORESERVE
flag. This can be just as easily handled by do_mmap_pgoff(), so do that
and remove the mmap_region() flags parameter.
Signed-off-by: Michel Lespinasse <walken@google.com>
---
arch/tile/mm/elf.c | 1 -
include/linux/mm.h | 3 +--
mm/fremap.c | 3 +--
mm/mmap.c | 33 ++++++++++++++++-----------------
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,
if (!retval) {
unsigned long addr = MEM_USER_INTRPT;
addr = mmap_region(NULL, addr, INTRPT_SIZE,
- MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE,
VM_READ|VM_EXEC|
VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC, 0);
if (addr > (unsigned long) -PAGE_SIZE)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index fea461cd9027..3b2912f6e91a 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1442,8 +1442,7 @@ extern int install_special_mapping(struct mm_struct *mm,
extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
extern 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);
extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
unsigned long len, unsigned long prot, unsigned long flags,
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:
unsigned long addr;
struct file *file = get_file(vma->vm_file);
- flags = (flags & MAP_NONBLOCK) | MAP_POPULATE;
addr = mmap_region(file, start, size,
- flags, vma->vm_flags, pgoff);
+ vma->vm_flags, pgoff);
fput(file);
if (IS_ERR_VALUE(addr)) {
err = addr;
diff --git a/mm/mmap.c b/mm/mmap.c
index 4c8d39e64e80..b0a341e5685f 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1138,7 +1138,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))
@@ -1257,8 +1271,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;
@@ -1282,20 +1295,6 @@ munmap_back:
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
*/
if (accountable_mapping(file, vm_flags)) {
--
1.7.7.3
next prev parent reply other threads:[~2012-12-21 0:50 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-21 0:49 [PATCH 0/9] Avoid populating unbounded num of ptes with mmap_sem held Michel Lespinasse
2012-12-21 0:49 ` Michel Lespinasse
2012-12-21 0:49 ` [PATCH 1/9] mm: make mlockall preserve flags other than VM_LOCKED in def_flags Michel Lespinasse
2012-12-21 0:49 ` Michel Lespinasse
2012-12-22 4:25 ` Rik van Riel
2012-12-22 4:25 ` Rik van Riel
2012-12-21 0:49 ` [PATCH 2/9] mm: remap_file_pages() fixes Michel Lespinasse
2012-12-21 0:49 ` Michel Lespinasse
2013-01-03 0:31 ` Rik van Riel
2013-01-03 0:31 ` Rik van Riel
2012-12-21 0:49 ` [PATCH 3/9] mm: introduce mm_populate() for populating new vmas Michel Lespinasse
2012-12-21 0:49 ` Michel Lespinasse
2013-01-03 2:14 ` Rik van Riel
2013-01-03 2:14 ` Rik van Riel
2012-12-21 0:49 ` [PATCH 4/9] mm: use mm_populate() for blocking remap_file_pages() Michel Lespinasse
2012-12-21 0:49 ` Michel Lespinasse
2013-01-03 2:25 ` Rik van Riel
2013-01-03 2:25 ` Rik van Riel
2013-03-10 18:55 ` Tommi Rantala
2013-03-10 18:55 ` Tommi Rantala
2013-03-11 23:03 ` Andrew Morton
2013-03-11 23:03 ` Andrew Morton
2013-03-12 0:24 ` Michel Lespinasse
2013-03-12 0:24 ` Michel Lespinasse
2013-03-12 4:23 ` Hillf Danton
2013-03-12 4:23 ` Hillf Danton
2013-03-12 5:01 ` Michel Lespinasse
2013-03-12 5:01 ` Michel Lespinasse
2013-03-12 20:47 ` Andrew Morton
2013-03-12 20:47 ` Andrew Morton
2012-12-21 0:49 ` [PATCH 5/9] mm: use mm_populate() when adjusting brk with MCL_FUTURE in effect Michel Lespinasse
2012-12-21 0:49 ` Michel Lespinasse
2013-01-03 2:56 ` Rik van Riel
2013-01-03 2:56 ` Rik van Riel
2012-12-21 0:49 ` [PATCH 6/9] mm: use mm_populate() for mremap() of VM_LOCKED vmas Michel Lespinasse
2012-12-21 0:49 ` Michel Lespinasse
2013-01-03 5:47 ` Rik van Riel
2013-01-03 5:47 ` Rik van Riel
2012-12-21 0:49 ` Michel Lespinasse [this message]
2012-12-21 0:49 ` [PATCH 7/9] mm: remove flags argument to mmap_region Michel Lespinasse
2013-01-03 5:49 ` Rik van Riel
2013-01-03 5:49 ` Rik van Riel
2012-12-21 0:49 ` [PATCH 8/9] mm: directly use __mlock_vma_pages_range() in find_extend_vma() Michel Lespinasse
2012-12-21 0:49 ` Michel Lespinasse
2013-01-03 5:50 ` Rik van Riel
2013-01-03 5:50 ` Rik van Riel
2012-12-21 0:49 ` [PATCH 9/9] mm: introduce VM_POPULATE flag to better deal with racy userspace programs Michel Lespinasse
2012-12-21 0:49 ` Michel Lespinasse
2013-01-03 6:20 ` Rik van Riel
2013-01-03 6:20 ` Rik van Riel
2012-12-21 10:46 ` [PATCH 0/9] Avoid populating unbounded num of ptes with mmap_sem held Michel Lespinasse
2012-12-21 10:46 ` Michel Lespinasse
2012-12-22 15:02 ` Greg Ungerer
2012-12-22 15:02 ` Greg Ungerer
2013-01-23 13:37 ` Greg Ungerer
2013-01-23 13:37 ` Greg Ungerer
2012-12-22 0:36 ` Andy Lutomirski
2012-12-22 0:36 ` Andy Lutomirski
2012-12-22 0:59 ` Michel Lespinasse
2012-12-22 0:59 ` Michel Lespinasse
2012-12-22 1:09 ` Andy Lutomirski
2012-12-22 1:09 ` Andy Lutomirski
2012-12-22 1:59 ` Michel Lespinasse
2012-12-22 1:59 ` Michel Lespinasse
2012-12-22 2:16 ` Andy Lutomirski
2012-12-22 2:16 ` Andy Lutomirski
2012-12-22 9:37 ` Michel Lespinasse
2012-12-22 9:37 ` Michel Lespinasse
2012-12-22 9:45 ` [PATCH 10/9] mm: make do_mmap_pgoff return populate as a size in bytes, not as a bool Michel Lespinasse
2012-12-22 9:45 ` Michel Lespinasse
2013-01-03 6:21 ` Rik van Riel
2013-01-03 6:21 ` Rik van Riel
2013-01-03 18:54 ` Andy Lutomirski
2013-01-03 18:54 ` Andy Lutomirski
2013-01-03 18:56 ` [PATCH 0/9] Avoid populating unbounded num of ptes with mmap_sem held Andy Lutomirski
2013-01-03 18:56 ` Andy Lutomirski
2013-01-04 18:16 ` Andy Lutomirski
2013-01-04 18:16 ` Andy Lutomirski
2013-01-04 22:58 ` Michel Lespinasse
2013-01-04 22:58 ` Michel Lespinasse
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=1356050997-2688-8-git-send-email-walken@google.com \
--to=walken@google.com \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=joern@logfs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@amacapital.net \
--cc=mingo@kernel.org \
--cc=riel@redhat.com \
--cc=viro@zeniv.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.