From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932619AbcCKP3f (ORCPT ); Fri, 11 Mar 2016 10:29:35 -0500 Received: from mx2.suse.de ([195.135.220.15]:35911 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932570AbcCKP31 (ORCPT ); Fri, 11 Mar 2016 10:29:27 -0500 Subject: Re: [PATCH 18/18] drm/amdgpu: make amdgpu_mn_get wait for mmap_sem killable To: Michal Hocko , LKML References: <1456752417-9626-1-git-send-email-mhocko@kernel.org> <1456752417-9626-19-git-send-email-mhocko@kernel.org> Cc: Andrew Morton , linux-mm@kvack.org, Alex Deucher , Alex Thorlton , Andrea Arcangeli , Andy Lutomirski , Benjamin LaHaise , =?UTF-8?Q?Christian_K=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: Vlastimil Babka Message-ID: <56E2E453.1090305@suse.cz> Date: Fri, 11 Mar 2016 16:29:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1456752417-9626-19-git-send-email-mhocko@kernel.org> Content-Type: text/plain; charset=iso-8859-2; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/29/2016 02:26 PM, Michal Hocko wrote: > From: Michal Hocko > > amdgpu_mn_get which is called during ioct path 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: David Airlie > Cc: Alex Deucher > Signed-off-by: Michal Hocko Acked-by: Vlastimil Babka > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c > index d7ec9bd6755f..6f44f1c23be3 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c > @@ -181,7 +181,10 @@ static struct amdgpu_mn *amdgpu_mn_get(struct amdgpu_device *adev) > int r; > > mutex_lock(&adev->mn_lock); > - down_write(&mm->mmap_sem); > + if (down_write_killable(&mm->mmap_sem)) { > + mutex_unlock(&adev->mn_lock); > + return -EINTR; > + } > > hash_for_each_possible(adev->mn_hash, rmn, node, (unsigned long)mm) > if (rmn->mm == mm) > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vlastimil Babka Subject: Re: [PATCH 18/18] drm/amdgpu: make amdgpu_mn_get wait for mmap_sem killable Date: Fri, 11 Mar 2016 16:29:23 +0100 Message-ID: <56E2E453.1090305@suse.cz> References: <1456752417-9626-1-git-send-email-mhocko@kernel.org> <1456752417-9626-19-git-send-email-mhocko@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1456752417-9626-19-git-send-email-mhocko@kernel.org> Sender: owner-linux-mm@kvack.org To: Michal Hocko , LKML Cc: Andrew Morton , linux-mm@kvack.org, Alex Deucher , Alex Thorlton , Andrea Arcangeli , Andy Lutomirski , Benjamin LaHaise , =?UTF-8?Q?Christian_K=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 List-Id: linux-arch.vger.kernel.org On 02/29/2016 02:26 PM, Michal Hocko wrote: > From: Michal Hocko > > amdgpu_mn_get which is called during ioct path 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: David Airlie > Cc: Alex Deucher > Signed-off-by: Michal Hocko Acked-by: Vlastimil Babka > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c > index d7ec9bd6755f..6f44f1c23be3 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c > @@ -181,7 +181,10 @@ static struct amdgpu_mn *amdgpu_mn_get(struct amdgpu_device *adev) > int r; > > mutex_lock(&adev->mn_lock); > - down_write(&mm->mmap_sem); > + if (down_write_killable(&mm->mmap_sem)) { > + mutex_unlock(&adev->mn_lock); > + return -EINTR; > + } > > hash_for_each_possible(adev->mn_hash, rmn, node, (unsigned long)mm) > if (rmn->mm == mm) > -- 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f51.google.com (mail-wm0-f51.google.com [74.125.82.51]) by kanga.kvack.org (Postfix) with ESMTP id 7B8AA6B0253 for ; Fri, 11 Mar 2016 10:29:27 -0500 (EST) Received: by mail-wm0-f51.google.com with SMTP id p65so22172629wmp.0 for ; Fri, 11 Mar 2016 07:29:27 -0800 (PST) Subject: Re: [PATCH 18/18] drm/amdgpu: make amdgpu_mn_get wait for mmap_sem killable References: <1456752417-9626-1-git-send-email-mhocko@kernel.org> <1456752417-9626-19-git-send-email-mhocko@kernel.org> From: Vlastimil Babka Message-ID: <56E2E453.1090305@suse.cz> Date: Fri, 11 Mar 2016 16:29:23 +0100 MIME-Version: 1.0 In-Reply-To: <1456752417-9626-19-git-send-email-mhocko@kernel.org> Content-Type: text/plain; charset=iso-8859-2; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko , LKML Cc: Andrew Morton , linux-mm@kvack.org, Alex Deucher , Alex Thorlton , Andrea Arcangeli , Andy Lutomirski , Benjamin LaHaise , =?UTF-8?Q?Christian_K=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 On 02/29/2016 02:26 PM, Michal Hocko wrote: > From: Michal Hocko > > amdgpu_mn_get which is called during ioct path 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: David Airlie > Cc: Alex Deucher > Signed-off-by: Michal Hocko Acked-by: Vlastimil Babka > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c > index d7ec9bd6755f..6f44f1c23be3 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c > @@ -181,7 +181,10 @@ static struct amdgpu_mn *amdgpu_mn_get(struct amdgpu_device *adev) > int r; > > mutex_lock(&adev->mn_lock); > - down_write(&mm->mmap_sem); > + if (down_write_killable(&mm->mmap_sem)) { > + mutex_unlock(&adev->mn_lock); > + return -EINTR; > + } > > hash_for_each_possible(adev->mn_hash, rmn, node, (unsigned long)mm) > if (rmn->mm == mm) > -- 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