From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753834AbcB2Rrp (ORCPT ); Mon, 29 Feb 2016 12:47:45 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:35310 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753796AbcB2Rrm (ORCPT ); Mon, 29 Feb 2016 12:47:42 -0500 Date: Mon, 29 Feb 2016 18:47:39 +0100 From: Michal Hocko To: Oleg Nesterov Cc: LKML , Andrew Morton , linux-mm@kvack.org, Alex Deucher , Alex Thorlton , Andrea Arcangeli , Andy Lutomirski , Benjamin LaHaise , Christian =?iso-8859-1?Q?K=F6nig?= , 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 , Peter Zijlstra , Petr Cermak , Thomas Gleixner , Alexander Viro Subject: Re: [PATCH 13/18] exec: make exec path waiting for mmap_sem killable Message-ID: <20160229174739.GL16930@dhcp22.suse.cz> References: <1456752417-9626-1-git-send-email-mhocko@kernel.org> <1456752417-9626-14-git-send-email-mhocko@kernel.org> <20160229172333.GB3615@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160229172333.GB3615@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 29-02-16 18:23:34, Oleg Nesterov wrote: > On 02/29, Michal Hocko wrote: > > > > @@ -267,7 +267,10 @@ static int __bprm_mm_init(struct linux_binprm *bprm) > > if (!vma) > > return -ENOMEM; > > > > - down_write(&mm->mmap_sem); > > + if (down_write_killable(&mm->mmap_sem)) { > > + err = -EINTR; > > + goto err_free; > > + } > > vma->vm_mm = mm; > > I won't argue, but this looks unnecessary. Nobody else can see this new mm, > down_write() can't block. > > In fact I think we can just remove down_write/up_write here. Except perhaps > there is lockdep_assert_held() somewhere in these paths. This is what I had initially but then I've noticed that mm_alloc() does mm_init(current)->init_new_context(current) so the outside can see this mm AFAICS. Now I guess this shouldn't matter in the real life but the code doesn't seem much harder to follow, the callers are already handling all error paths so I guess it would be better to simply move on this. Or am I misunderstanding the code or missing something? -- Michal Hocko SUSE Labs From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michal Hocko Subject: Re: [PATCH 13/18] exec: make exec path waiting for mmap_sem killable Date: Mon, 29 Feb 2016 18:47:39 +0100 Message-ID: <20160229174739.GL16930@dhcp22.suse.cz> References: <1456752417-9626-1-git-send-email-mhocko@kernel.org> <1456752417-9626-14-git-send-email-mhocko@kernel.org> <20160229172333.GB3615@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20160229172333.GB3615@redhat.com> Sender: owner-linux-mm@kvack.org To: Oleg Nesterov Cc: LKML , Andrew Morton , linux-mm@kvack.org, Alex Deucher , Alex Thorlton , Andrea Arcangeli , Andy Lutomirski , Benjamin LaHaise , Christian =?iso-8859-1?Q?K=F6nig?= , 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 , Peter Zijlstra List-Id: linux-arch.vger.kernel.org On Mon 29-02-16 18:23:34, Oleg Nesterov wrote: > On 02/29, Michal Hocko wrote: > > > > @@ -267,7 +267,10 @@ static int __bprm_mm_init(struct linux_binprm *bprm) > > if (!vma) > > return -ENOMEM; > > > > - down_write(&mm->mmap_sem); > > + if (down_write_killable(&mm->mmap_sem)) { > > + err = -EINTR; > > + goto err_free; > > + } > > vma->vm_mm = mm; > > I won't argue, but this looks unnecessary. Nobody else can see this new mm, > down_write() can't block. > > In fact I think we can just remove down_write/up_write here. Except perhaps > there is lockdep_assert_held() somewhere in these paths. This is what I had initially but then I've noticed that mm_alloc() does mm_init(current)->init_new_context(current) so the outside can see this mm AFAICS. Now I guess this shouldn't matter in the real life but the code doesn't seem much harder to follow, the callers are already handling all error paths so I guess it would be better to simply move on this. Or am I misunderstanding the code or missing something? -- Michal Hocko SUSE Labs -- 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-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by kanga.kvack.org (Postfix) with ESMTP id CE2BA6B025F for ; Mon, 29 Feb 2016 12:47:41 -0500 (EST) Received: by mail-wm0-f42.google.com with SMTP id n186so123993wmn.1 for ; Mon, 29 Feb 2016 09:47:41 -0800 (PST) Date: Mon, 29 Feb 2016 18:47:39 +0100 From: Michal Hocko Subject: Re: [PATCH 13/18] exec: make exec path waiting for mmap_sem killable Message-ID: <20160229174739.GL16930@dhcp22.suse.cz> References: <1456752417-9626-1-git-send-email-mhocko@kernel.org> <1456752417-9626-14-git-send-email-mhocko@kernel.org> <20160229172333.GB3615@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160229172333.GB3615@redhat.com> Sender: owner-linux-mm@kvack.org List-ID: To: Oleg Nesterov Cc: LKML , Andrew Morton , linux-mm@kvack.org, Alex Deucher , Alex Thorlton , Andrea Arcangeli , Andy Lutomirski , Benjamin LaHaise , Christian =?iso-8859-1?Q?K=F6nig?= , 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 , Peter Zijlstra , Petr Cermak , Thomas Gleixner , Alexander Viro On Mon 29-02-16 18:23:34, Oleg Nesterov wrote: > On 02/29, Michal Hocko wrote: > > > > @@ -267,7 +267,10 @@ static int __bprm_mm_init(struct linux_binprm *bprm) > > if (!vma) > > return -ENOMEM; > > > > - down_write(&mm->mmap_sem); > > + if (down_write_killable(&mm->mmap_sem)) { > > + err = -EINTR; > > + goto err_free; > > + } > > vma->vm_mm = mm; > > I won't argue, but this looks unnecessary. Nobody else can see this new mm, > down_write() can't block. > > In fact I think we can just remove down_write/up_write here. Except perhaps > there is lockdep_assert_held() somewhere in these paths. This is what I had initially but then I've noticed that mm_alloc() does mm_init(current)->init_new_context(current) so the outside can see this mm AFAICS. Now I guess this shouldn't matter in the real life but the code doesn't seem much harder to follow, the callers are already handling all error paths so I guess it would be better to simply move on this. Or am I misunderstanding the code or missing something? -- Michal Hocko SUSE Labs -- 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