[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1456752417-9626-4-git-send-email-mhocko@kernel.org>
Date: Mon, 29 Feb 2016 14:26:42 +0100
From: Michal Hocko <mhocko@...nel.org>
To: LKML <linux-kernel@...r.kernel.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>, <linux-mm@...ck.org>,
Alex Deucher <alexander.deucher@....com>,
Alex Thorlton <athorlton@....com>,
Andrea Arcangeli <aarcange@...hat.com>,
Andy Lutomirski <luto@...capital.net>,
Benjamin LaHaise <bcrl@...ck.org>,
Christian König <christian.koenig@....com>,
Daniel Vetter <daniel.vetter@...el.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
David Airlie <airlied@...ux.ie>,
Davidlohr Bueso <dave@...olabs.net>,
David Rientjes <rientjes@...gle.com>,
"H . Peter Anvin" <hpa@...or.com>, Hugh Dickins <hughd@...gle.com>,
Ingo Molnar <mingo@...nel.org>,
Johannes Weiner <hannes@...xchg.org>,
"Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>,
Konstantin Khlebnikov <koct9i@...il.com>,
linux-arch@...r.kernel.org, Mel Gorman <mgorman@...e.de>,
Oleg Nesterov <oleg@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Petr Cermak <petrcermak@...omium.org>,
Thomas Gleixner <tglx@...utronix.de>,
Michal Hocko <mhocko@...e.com>,
Alexander Viro <viro@...iv.linux.org.uk>
Subject: [PATCH 03/18] mm: make vm_munmap killable
From: Michal Hocko <mhocko@...e.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@...hat.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
Cc: Konstantin Khlebnikov <koct9i@...il.com>
Cc: Andrea Arcangeli <aarcange@...hat.com>
Cc: Alexander Viro <viro@...iv.linux.org.uk>
Signed-off-by: Michal Hocko <mhocko@...e.com>
---
mm/mmap.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/mm/mmap.c b/mm/mmap.c
index 4e1f852a52ff..5d33c841e3a2 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2499,11 +2499,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.7.0
Powered by blists - more mailing lists