Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1393467ybn; Wed, 25 Sep 2019 17:40:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNi8avvaqHbdKvYMtUbmHNr4yksQPhxKt8vlIvsFmkvehWhmqdMyYVKw/ywjfKlVok127h X-Received: by 2002:a50:eb44:: with SMTP id z4mr776647edp.207.1569458433181; Wed, 25 Sep 2019 17:40:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569458433; cv=none; d=google.com; s=arc-20160816; b=i2ebObCrbi7y42qd+qnBc5PseF5dD09e8ZArex4f5lFGXeEeqQ1USwrp7VcGLURGCx 2+N/YV/GUjoIQgrmzlEqDSislFMS4ahX77bSLRBj5WFiIcfetu/7cIWKsGJkaLguTyiX XKiGkqPSvipOqQ5lh6/3vnvhh5jRpuwQALFrAGBe3+Gi+8p13unyMmo3G/HHf/m4AHfU j01ylzrammt/twt5a+aqDzf1yao749uKQuOLZL1pRE4i8MJTEjyKt2WcDjA5wKl4H9zM u0gpL0VEyFnYATdwsnIsfmaaWWLIBFePHQKxoW46oJ3yCJOGjwEZWvcrugl0uOWcEYeG euWQ== 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; bh=uePRz+zBUInRiBudQ8Q8EZdu0505xUFOoco9XYwCcgc=; b=PxGjqtTi6T5w+P8UieSMeSTK8TRArVYedFGOaH3354HaAGLwqhffDk1e/JAr3DH1Ut L+9HNxioFdhmq+MkHzjU9l+mU7niR4Qhbz5IiJnBxEaJ9FDuugDPEWz7biehW9RCtU91 mrg0mm3tySahL6D/JVqeTgH3MpQBUxc8A4GNwXba+rN63/0DYR2kCrpuSiRIc0kEDCLw eDeAdhscum5iX5Lx8Y9X3gwe4p8bFu3DnmS5U5r1enRuCMiEOzVjX3fkmwvPFlY+xTk5 4Jau+5BorI9rgLtbW+B4xtPFCn9AQV2CsWCbafX6tqJuHJHOHRfpgDSXF8JjBD4L6fro sAfg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w11si431106edi.442.2019.09.25.17.40.09; Wed, 25 Sep 2019 17:40:33 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394768AbfIXDTX (ORCPT + 99 others); Mon, 23 Sep 2019 23:19:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38772 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389152AbfIXDTW (ORCPT ); Mon, 23 Sep 2019 23:19:22 -0400 Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8DABA2A09D8 for ; Tue, 24 Sep 2019 03:19:22 +0000 (UTC) Received: by mail-pf1-f199.google.com with SMTP id i187so492913pfc.10 for ; Mon, 23 Sep 2019 20:19:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=uePRz+zBUInRiBudQ8Q8EZdu0505xUFOoco9XYwCcgc=; b=appDA7N/9lDYgJRNYLvjnUcraDMkTZw8KS+LH+9N9QSDStMe4WJMYQm+Bx9CPx6asm o6+LLO4mWp2UBY8hSQyY40GisGtgqJSd5Sd62UFypN3HgyhNMdL7SB2LOwRWsj9uDRhC iH7JwL6+yVc7K0J5GfDVkQ/UXevde2qbOVojnKFO7cP8BiKYJKcAZnXMIVYvqJwtDTBh GGQSpxRrF4Qu/ttAKhuOKgQGjjkqtprBX8D3PVrhpO/WI474ywfSWB4DDhtgnj0Rex4X LXYKRQCG5gy3wldct3KrLzetxVf8YmOiIzDoAbQ+R+ZmLMUgB/yc8Hn4z3U5BRSpvjW3 DbRA== X-Gm-Message-State: APjAAAWrhaVKt/gURjhPDUcE0wzMT0FzEgWMpw9U5bW2AKDE29R4MCki nj8b/ghMVGH8nw/OzQUCKkI57fc6kq/IJZMsbrJdnohbGWhevDiVTRMKxDhp0pzADc8yJHHevlX JTsCbjvJVOdk7xy9RN34TfqLQ X-Received: by 2002:a62:1516:: with SMTP id 22mr810669pfv.87.1569295162073; Mon, 23 Sep 2019 20:19:22 -0700 (PDT) X-Received: by 2002:a62:1516:: with SMTP id 22mr810652pfv.87.1569295161835; Mon, 23 Sep 2019 20:19:21 -0700 (PDT) Received: from xz-x1 ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id b20sm243572pff.158.2019.09.23.20.19.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2019 20:19:21 -0700 (PDT) Date: Tue, 24 Sep 2019 11:19:08 +0800 From: Peter Xu To: Matthew Wilcox 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: <20190924031908.GF28074@xz-x1> References: <20190923042523.10027-1-peterx@redhat.com> <20190923042523.10027-6-peterx@redhat.com> <20190924024721.GD28074@xz-x1> <20190924025447.GE1855@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190924025447.GE1855@bombadil.infradead.org> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 23, 2019 at 07:54:47PM -0700, Matthew Wilcox wrote: > 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. (Thanks for joining the discussion) I'd like to do these - my only worry is that I can't really test them well simply because I don't have all the hardwares. For now the changes are mostly straightforward so I'm relatively confident (not to mention the code needs proper reviews too, and of course I would appreciate much if anyone wants to smoke test it). If I change it in a drastic way, I won't be that confident without some tests at least on multiple archs (not to mention that even smoke testing across major archs will be a huge amount of work...). So IMHO those might be more suitable as follow-up for per-arch developers if we can at least reach a consensus on the whole idea of this patchset. Thanks, -- Peter Xu