mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
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 <[email protected]> Reported-by: Andy Lutomirski <[email protected]> Acked-by: Rik van Riel <[email protected]> Tested-by: Andy Lutomirski <[email protected]> Cc: Greg Ungerer <[email protected]> Cc: David Howells <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
940e7da516
commit
bebeb3d68b
7 changed files with 62 additions and 22 deletions
6
fs/aio.c
6
fs/aio.c
|
|
@ -103,6 +103,7 @@ static int aio_setup_ring(struct kioctx *ctx)
|
|||
unsigned nr_events = ctx->max_reqs;
|
||||
unsigned long size;
|
||||
int nr_pages;
|
||||
bool populate;
|
||||
|
||||
/* Compensate for the ring buffer's head/tail overlap entry */
|
||||
nr_events += 2; /* 1 is required, 2 for good luck */
|
||||
|
|
@ -129,7 +130,8 @@ static int aio_setup_ring(struct kioctx *ctx)
|
|||
down_write(&ctx->mm->mmap_sem);
|
||||
info->mmap_base = do_mmap_pgoff(NULL, 0, info->mmap_size,
|
||||
PROT_READ|PROT_WRITE,
|
||||
MAP_ANONYMOUS|MAP_PRIVATE, 0);
|
||||
MAP_ANONYMOUS|MAP_PRIVATE, 0,
|
||||
&populate);
|
||||
if (IS_ERR((void *)info->mmap_base)) {
|
||||
up_write(&ctx->mm->mmap_sem);
|
||||
info->mmap_size = 0;
|
||||
|
|
@ -147,6 +149,8 @@ static int aio_setup_ring(struct kioctx *ctx)
|
|||
aio_free_ring(ctx);
|
||||
return -EAGAIN;
|
||||
}
|
||||
if (populate)
|
||||
mm_populate(info->mmap_base, info->mmap_size);
|
||||
|
||||
ctx->user_id = info->mmap_base;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue