diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-04-20 21:49:41 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-04-21 01:58:16 -0400 |
commit | 936af1576e4c24b466380fc2b8d93352161d13b0 (patch) | |
tree | b7ecc2a4706ab25b0d06af7bac5fdf5d0fc7acb5 | |
parent | 6be5ceb02e98eaf6cfc4f8b12a896d04023f340d (diff) |
aio: don't bother with unmapping when aio_free_ring() is coming from exit_aio()
... since exit_mmap() is coming and it will munmap() everything anyway.
In all other cases aio_free_ring() has ctx->mm == current->mm; moreover,
all other callers of vm_munmap() have mm == current->mm, so this will
allow us to get rid of mm argument of vm_munmap().
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/aio.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -92,8 +92,10 @@ static void aio_free_ring(struct kioctx *ctx) | |||
92 | for (i=0; i<info->nr_pages; i++) | 92 | for (i=0; i<info->nr_pages; i++) |
93 | put_page(info->ring_pages[i]); | 93 | put_page(info->ring_pages[i]); |
94 | 94 | ||
95 | if (info->mmap_size) | 95 | if (info->mmap_size) { |
96 | BUG_ON(ctx->mm != current->mm); | ||
96 | vm_munmap(ctx->mm, info->mmap_base, info->mmap_size); | 97 | vm_munmap(ctx->mm, info->mmap_base, info->mmap_size); |
98 | } | ||
97 | 99 | ||
98 | if (info->ring_pages && info->ring_pages != info->internal_pages) | 100 | if (info->ring_pages && info->ring_pages != info->internal_pages) |
99 | kfree(info->ring_pages); | 101 | kfree(info->ring_pages); |
@@ -386,6 +388,17 @@ void exit_aio(struct mm_struct *mm) | |||
386 | "exit_aio:ioctx still alive: %d %d %d\n", | 388 | "exit_aio:ioctx still alive: %d %d %d\n", |
387 | atomic_read(&ctx->users), ctx->dead, | 389 | atomic_read(&ctx->users), ctx->dead, |
388 | ctx->reqs_active); | 390 | ctx->reqs_active); |
391 | /* | ||
392 | * We don't need to bother with munmap() here - | ||
393 | * exit_mmap(mm) is coming and it'll unmap everything. | ||
394 | * Since aio_free_ring() uses non-zero ->mmap_size | ||
395 | * as indicator that it needs to unmap the area, | ||
396 | * just set it to 0; aio_free_ring() is the only | ||
397 | * place that uses ->mmap_size, so it's safe. | ||
398 | * That way we get all munmap done to current->mm - | ||
399 | * all other callers have ctx->mm == current->mm. | ||
400 | */ | ||
401 | ctx->ring_info.mmap_size = 0; | ||
389 | put_ioctx(ctx); | 402 | put_ioctx(ctx); |
390 | } | 403 | } |
391 | } | 404 | } |