Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752657AbcDZM5y (ORCPT ); Tue, 26 Apr 2016 08:57:54 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:34525 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752318AbcDZM4p (ORCPT ); Tue, 26 Apr 2016 08:56:45 -0400 From: Michal Hocko To: , Andrew Morton Cc: LKML , Michal Hocko , Daniel Vetter , David Airlie , Vlastimil Babka Subject: [PATCH 16/18] drm/i915: make i915_gem_mmap_ioctl wait for mmap_sem killable Date: Tue, 26 Apr 2016 14:56:23 +0200 Message-Id: <1461675385-5934-17-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: 1187 Lines: 34 From: Michal Hocko i915_gem_mmap_ioctl relies on 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: Daniel Vetter Cc: David Airlie Acked-by: Vlastimil Babka Signed-off-by: Michal Hocko --- drivers/gpu/drm/i915/i915_gem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 761e28febddc..b99c761846ce 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -1721,7 +1721,10 @@ i915_gem_mmap_ioctl(struct drm_device *dev, void *data, struct mm_struct *mm = current->mm; struct vm_area_struct *vma; - down_write(&mm->mmap_sem); + if (down_write_killable(&mm->mmap_sem)) { + drm_gem_object_unreference_unlocked(obj); + return -EINTR; + } vma = find_vma(mm, addr); if (vma) vma->vm_page_prot = -- 2.8.0.rc3