diff options
author | Michel Lespinasse <walken@google.com> | 2013-02-22 19:32:37 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-23 20:50:10 -0500 |
commit | bebeb3d68b24bb4132d452c5707fe321208bcbcd (patch) | |
tree | 6e609cb7323fb1b4b7026fa0e35867145a181094 /mm/util.c | |
parent | 940e7da5163029978c2f6b5bbe213607add59062 (diff) |
mm: introduce mm_populate() for populating new vmas
When creating new mappings using the MAP_POPULATE / MAP_LOCKED flags (or
with MCL_FUTURE in effect), we want to populate the pages within the
newly created vmas. This may take a while as we may have to read pages
from disk, so ideally we want to do this outside of the write-locked
mmap_sem region.
This change introduces mm_populate(), which is used to defer populating
such mappings until after the mmap_sem write lock has been released.
This is implemented as a generalization of the former do_mlock_pages(),
which accomplished the same task but was using during mlock() /
mlockall().
Signed-off-by: Michel Lespinasse <walken@google.com>
Reported-by: Andy Lutomirski <luto@amacapital.net>
Acked-by: Rik van Riel <riel@redhat.com>
Tested-by: Andy Lutomirski <luto@amacapital.net>
Cc: Greg Ungerer <gregungerer@westnet.com.au>
Cc: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/util.c')
-rw-r--r-- | mm/util.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -355,12 +355,16 @@ unsigned long vm_mmap_pgoff(struct file *file, unsigned long addr, | |||
355 | { | 355 | { |
356 | unsigned long ret; | 356 | unsigned long ret; |
357 | struct mm_struct *mm = current->mm; | 357 | struct mm_struct *mm = current->mm; |
358 | bool populate; | ||
358 | 359 | ||
359 | ret = security_mmap_file(file, prot, flag); | 360 | ret = security_mmap_file(file, prot, flag); |
360 | if (!ret) { | 361 | if (!ret) { |
361 | down_write(&mm->mmap_sem); | 362 | down_write(&mm->mmap_sem); |
362 | ret = do_mmap_pgoff(file, addr, len, prot, flag, pgoff); | 363 | ret = do_mmap_pgoff(file, addr, len, prot, flag, pgoff, |
364 | &populate); | ||
363 | up_write(&mm->mmap_sem); | 365 | up_write(&mm->mmap_sem); |
366 | if (!IS_ERR_VALUE(ret) && populate) | ||
367 | mm_populate(ret, len); | ||
364 | } | 368 | } |
365 | return ret; | 369 | return ret; |
366 | } | 370 | } |