From patchwork Wed Mar 28 12:26:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuo Handa X-Patchwork-Id: 10312871 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4FA3B60383 for ; Wed, 28 Mar 2018 12:27:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4365829F6E for ; Wed, 28 Mar 2018 12:27:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3809129F72; Wed, 28 Mar 2018 12:27:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6766129F6E for ; Wed, 28 Mar 2018 12:27:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751207AbeC1M06 (ORCPT ); Wed, 28 Mar 2018 08:26:58 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:58505 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750820AbeC1M06 (ORCPT ); Wed, 28 Mar 2018 08:26:58 -0400 Received: from fsav104.sakura.ne.jp (fsav104.sakura.ne.jp [27.133.134.231]) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id w2SCQg8r033329; Wed, 28 Mar 2018 21:26:42 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav104.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav104.sakura.ne.jp); Wed, 28 Mar 2018 21:26:42 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav104.sakura.ne.jp) Received: from AQUA (softbank126099184120.bbtec.net [126.99.184.120]) (authenticated bits=0) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id w2SCQg0T033323; Wed, 28 Mar 2018 21:26:42 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) To: mhocko@kernel.org Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk, akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, riel@redhat.com Subject: Re: [PATCH] mm: Introduce i_mmap_lock_write_killable(). From: Tetsuo Handa References: <1522149570-4517-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> <20180327145220.GJ5652@dhcp22.suse.cz> <201803281923.EFF26009.OFOtJSMFHQFLVO@I-love.SAKURA.ne.jp> <20180328110513.GH9275@dhcp22.suse.cz> In-Reply-To: <20180328110513.GH9275@dhcp22.suse.cz> Message-Id: <201803282126.GBC56799.tOFVFSOHJLFOQM@I-love.SAKURA.ne.jp> X-Mailer: Winbiff [Version 2.51 PL2] X-Accept-Language: ja,en,zh Date: Wed, 28 Mar 2018 21:26:43 +0900 Mime-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Michal Hocko wrote: > > > I am not saying this is wrong, I would have to think about that much > > > more because mmap_sem tends to be used on many surprising places and the > > > write lock just hide them all. > > > > Then, an alternative approach which interrupts without downgrading is shown > > below. But I'm not sure. > > Failing the whole dup_mmap might be quite reasonable, yes. I haven't > checked your particular patch because this code path needs much more > time than I can give this, though. I think that interrupting at diff --git a/kernel/fork.c b/kernel/fork.c index 1e8c9a7..851c675 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -514,6 +514,9 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm, if (tmp->vm_ops && tmp->vm_ops->open) tmp->vm_ops->open(tmp); + if (!retval && fatal_signal_pending(current)) + retval = -EINTR; + if (retval) goto out; } -- is safe because there is no difference (except the error code) between above change and hitting "goto fail_nomem;" path after "mpnt = mpnt->vm_next;". Therefore, I think that interrupting at diff --git a/kernel/fork.c b/kernel/fork.c index 851c675..2706acc 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -508,7 +508,9 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm, rb_parent = &tmp->vm_rb; mm->map_count++; - if (!(tmp->vm_flags & VM_WIPEONFORK)) + if (fatal_signal_pending(current)) + retval = -EINTR; + else if (!(tmp->vm_flags & VM_WIPEONFORK)) retval = copy_page_range(mm, oldmm, mpnt); if (tmp->vm_ops && tmp->vm_ops->open)