Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752314AbcDZM4o (ORCPT ); Tue, 26 Apr 2016 08:56:44 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:35929 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752264AbcDZM4l (ORCPT ); Tue, 26 Apr 2016 08:56:41 -0400 From: Michal Hocko To: , Andrew Morton Cc: LKML , Michal Hocko , Oleg Nesterov , Vlastimil Babka Subject: [PATCH 11/18] coredump: make coredump_wait wait for mmap_sem for write killable Date: Tue, 26 Apr 2016 14:56:18 +0200 Message-Id: <1461675385-5934-12-git-send-email-mhocko@kernel.org> X-Mailer: git-send-email 2.8.0.rc3 In-Reply-To: <1461675385-5934-1-git-send-email-mhocko@kernel.org> References: <1461675385-5934-1-git-send-email-mhocko@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1355 Lines: 39 From: Michal Hocko coredump_wait waits for mmap_sem for write currently which can prevent oom_reaper to reclaim the oom victims address space asynchronously because that requires mmap_sem for read. This might happen if the oom victim is multi threaded and some thread(s) is holding mmap_sem for read (e.g. page fault) and it is stuck in the page allocator while other thread(s) reached coredump_wait already. This patch simply uses down_write_killable and bails out with EINTR if the lock got interrupted by the fatal signal. do_coredump will return right away and do_group_exit will take care to zap the whole thread group. Acked-by: Oleg Nesterov Acked-by: Vlastimil Babka Signed-off-by: Michal Hocko --- fs/coredump.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/coredump.c b/fs/coredump.c index 47c32c3bfa1d..f2cef927789b 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -413,7 +413,9 @@ static int coredump_wait(int exit_code, struct core_state *core_state) core_state->dumper.task = tsk; core_state->dumper.next = NULL; - down_write(&mm->mmap_sem); + if (down_write_killable(&mm->mmap_sem)) + return -EINTR; + if (!mm->core_state) core_waiters = zap_threads(tsk, mm, core_state, exit_code); up_write(&mm->mmap_sem); -- 2.8.0.rc3