From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com [74.125.82.41]) by kanga.kvack.org (Postfix) with ESMTP id E6FD46B0258 for ; Mon, 29 Feb 2016 08:27:23 -0500 (EST) Received: by mail-wm0-f41.google.com with SMTP id n186so49197973wmn.1 for ; Mon, 29 Feb 2016 05:27:23 -0800 (PST) From: Michal Hocko Subject: [PATCH 08/18] mm, fork: make dup_mmap wait for mmap_sem for write killable Date: Mon, 29 Feb 2016 14:26:47 +0100 Message-Id: <1456752417-9626-9-git-send-email-mhocko@kernel.org> In-Reply-To: <1456752417-9626-1-git-send-email-mhocko@kernel.org> References: <1456752417-9626-1-git-send-email-mhocko@kernel.org> Sender: owner-linux-mm@kvack.org List-ID: To: LKML Cc: Andrew Morton , linux-mm@kvack.org, Alex Deucher , Alex Thorlton , Andrea Arcangeli , Andy Lutomirski , Benjamin LaHaise , =?UTF-8?q?Christian=20K=C3=B6nig?= , Daniel Vetter , Dave Hansen , David Airlie , Davidlohr Bueso , David Rientjes , "H . Peter Anvin" , Hugh Dickins , Ingo Molnar , Johannes Weiner , "Kirill A . Shutemov" , Konstantin Khlebnikov , linux-arch@vger.kernel.org, Mel Gorman , Oleg Nesterov , Peter Zijlstra , Petr Cermak , Thomas Gleixner , Michal Hocko From: Michal Hocko dup_mmap needs to lock current's mm mmap_sem for write. If the waiting task gets killed by the oom killer it would block oom_reaper from asynchronous address space reclaim and reduce the chances of timely OOM resolving. Wait for the lock in the killable mode and return with EINTR if the task got killed while waiting. Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Oleg Nesterov Cc: Konstantin Khlebnikov Signed-off-by: Michal Hocko --- kernel/fork.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/fork.c b/kernel/fork.c index d277e83ed3e0..e064bc8453dc 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -413,7 +413,10 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm) unsigned long charge; uprobe_start_dup_mmap(); - down_write(&oldmm->mmap_sem); + if (down_write_killable(&oldmm->mmap_sem)) { + uprobe_end_dup_mmap(); + return -EINTR; + } flush_cache_dup_mm(oldmm); uprobe_dup_mmap(oldmm, mm); /* -- 2.7.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org