Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1387441
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 03/18] mm: make vm_munmap killable |
| Date | 2016-04-26 15:00 +0200 |
| Message-ID | <rsaKT-81H-31@gated-at.bofh.it> (permalink) |
| References | <rsaKS-81H-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Michal Hocko <mhocko@suse.com> Almost all current users of vm_munmap are ignoring the return value and so they do not handle potential error. This means that some VMAs might stay behind. This patch doesn't try to solve those potential problems. Quite contrary it adds a new failure mode by using down_write_killable in vm_munmap. This should be safer than other failure modes, though, because the process is guaranteed to die as soon as it leaves the kernel and exit_mmap will clean the whole address space. This will help in the OOM conditions when the oom victim might be stuck waiting for the mmap_sem for write which in turn can block oom_reaper which relies on the mmap_sem for read to make a forward progress and reclaim the address space of the victim. Cc: Oleg Nesterov <oleg@redhat.com> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Cc: Konstantin Khlebnikov <koct9i@gmail.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Signed-off-by: Michal Hocko <mhocko@suse.com> --- mm/mmap.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 1d229487dab1..032605bda665 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2494,11 +2494,9 @@ int vm_munmap(unsigned long start, size_t len) int ret; struct mm_struct *mm = current->mm; - /* - * XXX convert to down_write_killable as soon as all users are able - * to handle the error. - */ - down_write(&mm->mmap_sem); + if (down_write_killable(&mm->mmap_sem)) + return -EINTR; + ret = do_munmap(mm, start, len); up_write(&mm->mmap_sem); return ret; -- 2.8.0.rc3
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/18] change mmap_sem taken for write killable v2 Michal Hocko <mhocko@kernel.org> - 2016-04-26 15:00 +0200
[PATCH 09/18] ipc, shm: make shmem attach/detach wait for mmap_sem killable Michal Hocko <mhocko@kernel.org> - 2016-04-26 15:00 +0200
[PATCH 07/18] mm, proc: make clear_refs killable Michal Hocko <mhocko@kernel.org> - 2016-04-26 15:00 +0200
[PATCH 13/18] exec: make exec path waiting for mmap_sem killable Michal Hocko <mhocko@kernel.org> - 2016-04-26 15:00 +0200
[PATCH 06/18] mm: make vm_brk killable Michal Hocko <mhocko@kernel.org> - 2016-04-26 15:00 +0200
[PATCH 18/18] drm/amdgpu: make amdgpu_mn_get wait for mmap_sem killable Michal Hocko <mhocko@kernel.org> - 2016-04-26 15:00 +0200
[PATCH 03/18] mm: make vm_munmap killable Michal Hocko <mhocko@kernel.org> - 2016-04-26 15:00 +0200
[PATCH 08/18] mm, fork: make dup_mmap wait for mmap_sem for write killable Michal Hocko <mhocko@kernel.org> - 2016-04-26 15:00 +0200
[PATCH 14/18] prctl: make PR_SET_THP_DISABLE wait for mmap_sem killable Michal Hocko <mhocko@kernel.org> - 2016-04-26 15:00 +0200
Re: [PATCH 14/18] prctl: make PR_SET_THP_DISABLE wait for mmap_sem killable Alex Thorlton <athorlton@sgi.com> - 2016-04-26 17:20 +0200
[PATCH 16/18] drm/i915: make i915_gem_mmap_ioctl wait for mmap_sem killable Michal Hocko <mhocko@kernel.org> - 2016-04-26 15:00 +0200
[PATCH 10/18] vdso: make arch_setup_additional_pages wait for mmap_sem for write killable Michal Hocko <mhocko@kernel.org> - 2016-04-26 15:00 +0200
[PATCH 02/18] mm: make vm_mmap killable Michal Hocko <mhocko@kernel.org> - 2016-04-26 15:00 +0200
[PATCH 11/18] coredump: make coredump_wait wait for mmap_sem for write killable Michal Hocko <mhocko@kernel.org> - 2016-04-26 15:00 +0200
[PATCH 12/18] aio: make aio_setup_ring killable Michal Hocko <mhocko@kernel.org> - 2016-04-26 15:00 +0200
[PATCH 04/18] mm, aout: handle vm_brk failures Michal Hocko <mhocko@kernel.org> - 2016-04-26 15:10 +0200
[PATCH 05/18] mm, elf: handle vm_brk error Michal Hocko <mhocko@kernel.org> - 2016-04-26 15:10 +0200
[PATCH 01/18] mm: Make mmap_sem for write waits killable for mm syscalls Michal Hocko <mhocko@kernel.org> - 2016-04-26 15:10 +0200
csiph-web