From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDA55C432C2 for ; Tue, 24 Sep 2019 03:19:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5B3402064A for ; Tue, 24 Sep 2019 03:19:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B3402064A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C6C796B0006; Mon, 23 Sep 2019 23:19:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF7116B0007; Mon, 23 Sep 2019 23:19:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE4946B0008; Mon, 23 Sep 2019 23:19:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0101.hostedemail.com [216.40.44.101]) by kanga.kvack.org (Postfix) with ESMTP id 86DC36B0006 for ; Mon, 23 Sep 2019 23:19:24 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 293A38243777 for ; Tue, 24 Sep 2019 03:19:24 +0000 (UTC) X-FDA: 75968358648.05.nose45_17d27f5a94b51 X-HE-Tag: nose45_17d27f5a94b51 X-Filterd-Recvd-Size: 7168 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Tue, 24 Sep 2019 03:19:23 +0000 (UTC) Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) (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 851CA4E938 for ; Tue, 24 Sep 2019 03:19:22 +0000 (UTC) Received: by mail-pg1-f197.google.com with SMTP id m17so391686pgh.21 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=SmO53rwA1kauIIw1x0tmg26V7oFNgJ92IbSp8EwiuqKJ6RIzcc4BuJqQ40hN4uEgl8 7eEOTlIsQ5mZVIRRQfxO/6OVUIsMUUPiJtCBTDthyuZfMrQaiZBYdIM8RXyCqG4e73N9 kbCjarKQ4CRXztAdVewVZb6S2oHHqhtASFS41MMT2n+xcFzkN6wRhPeTT7+JNgUpoTkY rWeB9H1rzhKcZ7JMmEj6ihFnq559f6qpTEJpBVfANZqaUiXfQ44z/6HHlEN6J6Ku1qAB rWcvCs43z48ivTnaq1YggnugbMvuZEISTwGpGHazrmHI4RQGpoA/L/HxebNXpk/Jz2Tc clZw== X-Gm-Message-State: APjAAAUJKyUThuTJtCD1Jos677X5eR/+DC1HwJLy8RMxmtE/6kyd1XDn v7PlZ1ixCHgdVHyCEkGtrtVVaBPpk8c5hQG6BoVLD8hnJCHSl3Rd9c0319wWzHSSSSajoent87e zwbNNaYghJFk= X-Received: by 2002:a62:1516:: with SMTP id 22mr810676pfv.87.1569295162074; Mon, 23 Sep 2019 20:19:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqzvvwc9qmVDzQ+3G7Oq/DsoKfd5QfwPt3k9ug8jmIgqi79JZwmDUqYomKmQbUA8CTqPKchZvw== 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) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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