Commit 936af1576e4c24b466380fc2b8d93352161d13b0
1 parent
6be5ceb02e
Exists in
master
and in
20 other branches
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>
Showing 1 changed file with 14 additions and 1 deletions Side-by-side Diff
fs/aio.c
... | ... | @@ -92,8 +92,10 @@ |
92 | 92 | for (i=0; i<info->nr_pages; i++) |
93 | 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 | 97 | vm_munmap(ctx->mm, info->mmap_base, info->mmap_size); |
98 | + } | |
97 | 99 | |
98 | 100 | if (info->ring_pages && info->ring_pages != info->internal_pages) |
99 | 101 | kfree(info->ring_pages); |
... | ... | @@ -386,6 +388,17 @@ |
386 | 388 | "exit_aio:ioctx still alive: %d %d %d\n", |
387 | 389 | atomic_read(&ctx->users), ctx->dead, |
388 | 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 | 402 | put_ioctx(ctx); |
390 | 403 | } |
391 | 404 | } |