Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1704314ybn; Thu, 26 Sep 2019 00:31:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwD9CtKr1RIqkMQwYTGhtqn+s3dpaBmcDkzNA7rqrnewTGTDeq2Ywen1OzVr3ciaWFKrW+d X-Received: by 2002:a50:9625:: with SMTP id y34mr2037805eda.72.1569483094879; Thu, 26 Sep 2019 00:31:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569483094; cv=none; d=google.com; s=arc-20160816; b=RYTIxxYfIIDnGQ4FgX2IwGSnSCdSPyBZ+qSQbo0Q+oRnKPwyujMon2Hu1cZf9EFJPD P5YYRcGhXrJZkpBBMqeSEdby0suEmXwwjKql7PtI2zEQLr84HIYSi2UN0gh/A22JrMhb VRlbp2feikSDWpQIxRgPR7y3uowVmJzaHEcbgTEvJ0s3p59HugsI1iFkcz+00RqxppVH hjY4FdJHJ7Ywj66ZyiQOm45P9626J2RB+aqTe3i7CN9Zl+UsHjRKvnDWAKzogEQdr1xq t3FHXzHzpHlw4x1+2ANlXUbFb/bmUcYxZzOrs1W08MMCvmFmiM1qmFhkf+xM+84kKlcN dfzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=/DJNNX8am+OPFrfhRWv8QK+73Tkk4zg/UVywTKFicBE=; b=rCfGu9mTL4oifEBraq756DRlkdGfTDRY6tkyT22ylP96CBgYh47yCUx8j7owgnhTlC 8O7Ejw3tKHCxMnqLV0kanozM0pBRzcgHbXnoLHkG5digcbNWRZglQ/hkrA2FsaVlpIhj nwDZf2O75v6ZuBI3Y0ox3ubfBc6oQr346GUio3stJLd9xbGsq9Qv6Th+koZTliU43uM5 XhCwvZ7Z/YtsG9+RZhRYCSDlx+5nzJnDhTWMB2n4vG5oOmVB4m3400Wqn0aX9xX/8RxV nmwh2TEqr0G4oB6R6E7iLk3jCwyBUbnYXRT95gf1HHLdZK0IGGFdum+Awg12EKYOE7eb n6OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=RqRYQMPA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t7si624266ejo.302.2019.09.26.00.31.10; Thu, 26 Sep 2019 00:31:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=RqRYQMPA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2408814AbfIXCyv (ORCPT + 99 others); Mon, 23 Sep 2019 22:54:51 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:38092 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2408143AbfIXCyv (ORCPT ); Mon, 23 Sep 2019 22:54:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=/DJNNX8am+OPFrfhRWv8QK+73Tkk4zg/UVywTKFicBE=; b=RqRYQMPAOnZ/5zeYU+pgnLf8v WPsErvbclrAM0RhdNKnbhFY/qvPgBEZhw3SNqT4knMFlfm6KJxbjbluGS7hnhV7JB3EwXZdHqbUMt A6naj4Q9dspz3KN/oM4DVKPhENnGvXvjm7JMpJz/Jrgt6RIhrUGSgahci+Bw+91NFhl/HMCHh7Ygu 8yCEc+Ext1uobv/KB3kjRYBfCEbP0SNb04QsfBqhmNvLADSUgjHIS4bAGdxDoeI9JwfLXJnaT0/2J hWyRy61evmLeldRUm3IODMCIbdQpu0tcmdcvPX3g7htkxlR+htGn/K/dzaN9sRTDlQAtXKHPJcPCr Q1Ezm/hKw==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.2 #3 (Red Hat Linux)) id 1iCayV-0005bB-Tm; Tue, 24 Sep 2019 02:54:47 +0000 Date: Mon, 23 Sep 2019 19:54:47 -0700 From: Matthew Wilcox To: Peter Xu Cc: Linus Torvalds , Linux-MM , Linux Kernel Mailing List , David Hildenbrand , Hugh Dickins , Maya Gokhale , Jerome Glisse , Pavel Emelyanov , Johannes Weiner , Martin Cracauer , Marty McFadden , Shaohua Li , Andrea Arcangeli , Mike Kravetz , Denis Plotnikov , Mike Rapoport , Mel Gorman , "Kirill A . Shutemov" , "Dr . David Alan Gilbert" Subject: Re: [PATCH v4 05/10] mm: Return faster for non-fatal signals in user mode faults Message-ID: <20190924025447.GE1855@bombadil.infradead.org> References: <20190923042523.10027-1-peterx@redhat.com> <20190923042523.10027-6-peterx@redhat.com> <20190924024721.GD28074@xz-x1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190924024721.GD28074@xz-x1> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 24, 2019 at 10:47:21AM +0800, Peter Xu wrote: > On Mon, Sep 23, 2019 at 11:03:49AM -0700, Linus Torvalds wrote: > > On Sun, Sep 22, 2019 at 9:26 PM Peter Xu wrote: > > > > > > This patch is a preparation of removing that special path by allowing > > > the page fault to return even faster if we were interrupted by a > > > non-fatal signal during a user-mode page fault handling routine. > > > > So I really wish saome other vm person would also review these things, > > but looking over this series once more, this is the patch I probably > > like the least. > > > > And the reason I like it the least is that I have a hard time > > explaining to myself what the code does and why, and why it's so full > > of this pattern: > > > > > - if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) > > > + if ((fault & VM_FAULT_RETRY) && > > > + fault_should_check_signal(user_mode(regs))) > > > return; > > > > which isn't all that pretty. > > > > Why isn't this just > > > > static bool fault_signal_pending(unsigned int fault_flags, struct > > pt_regs *regs) > > { > > return (fault_flags & VM_FAULT_RETRY) && > > (fatal_signal_pending(current) || > > (user_mode(regs) && signal_pending(current))); > > } > > > > and then most of the users would be something like > > > > if (fault_signal_pending(fault, regs)) > > return; > > > > and the exceptions could do their own thing. > > > > Now the code is prettier and more understandable, I feel. > > > > And if something doesn't follow this pattern, maybe it either _should_ > > follow that pattern or it should just not use the helper but explain > > why it has an unusual pattern. > +++ b/arch/alpha/mm/fault.c > @@ -150,7 +150,7 @@ do_page_fault(unsigned long address, unsigned long mmcsr, > the fault. */ > fault = handle_mm_fault(vma, address, flags); > > - if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) > + if (fault_signal_pending(fault, regs)) > return; > > if (unlikely(fault & VM_FAULT_ERROR)) { > +++ b/arch/arm/mm/fault.c > @@ -301,6 +301,11 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs) > return 0; > } > > + /* Fast path to handle user mode signals */ > + if ((fault & VM_FAULT_RETRY) && user_mode(regs) && > + signal_pending(current)) > + return 0; But _why_ are they different? This is a good opportunity to make more code the same between architectures.