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=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 26B11C4360C for ; Thu, 26 Sep 2019 09:40:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E90E1222BE for ; Thu, 26 Sep 2019 09:40:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E90E1222BE 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 99AAE6B0008; Thu, 26 Sep 2019 05:40:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 94B146B026A; Thu, 26 Sep 2019 05:40:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 861926B026B; Thu, 26 Sep 2019 05:40:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0203.hostedemail.com [216.40.44.203]) by kanga.kvack.org (Postfix) with ESMTP id 683D66B0008 for ; Thu, 26 Sep 2019 05:40:36 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id E91D5180AD802 for ; Thu, 26 Sep 2019 09:40:35 +0000 (UTC) X-FDA: 75976576830.15.books71_79936eb4b071b X-HE-Tag: books71_79936eb4b071b X-Filterd-Recvd-Size: 4879 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Thu, 26 Sep 2019 09:40:35 +0000 (UTC) Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) (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 8A9217FDCA for ; Thu, 26 Sep 2019 09:40:34 +0000 (UTC) Received: by mail-pg1-f198.google.com with SMTP id f10so313073pgj.0 for ; Thu, 26 Sep 2019 02:40:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Zs0icSpFo5EckbI9NuVzMV23UUzKD43r4J1NyJ/klic=; b=Et7L4qx3Q3mBOTxknJPg1ayxLrzHB464yMHvpEGYyWzSaUh7v80sWR7ckTu/orU5jw ZZcbRCGDWj+i6PpsF8+oL5p3QQ1cRHBiib2rpwyMzT35y0gQDqa7R0TxEP+Xn6vRcIsa nyd7f5C2ubB3egomg1Z2/xLs7qjz7GsVnd8+u0AFURdfyWgYb6IXOFgxLoLJ2mc8lwuB KxJx7aUS85g+8+ydVRfq9yX4HcS96TisuvQYoYcEdtmgg5cT7yLstjTv5XJZJ6KivWPt PUT2CBaDOPpatFcLNmgWJPWVI8aTNX+cJu3nCDZ06glPcLezjGYOTsvYF1C1gcFwCdw4 ZtyA== X-Gm-Message-State: APjAAAVzwDtEZ3UcrEaTueTAEbwo7V+z9lXw7IE+cCM/R4ztj7jbTaUf DiHW0eX8PoPI64UGqJxF/2k+Mqk0+DmedvLkZApNQQe4FuIZ34Ho7m+wQqXsqTJCwM6IjM4i7s2 kyscu8ckW4aY= X-Received: by 2002:a17:902:8488:: with SMTP id c8mr2742260plo.164.1569490833546; Thu, 26 Sep 2019 02:40:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqy78qElHwxU+VN7yYhyu4WKCD5RFszqHAErQMKeM6BohEAgdvKCeLfzyvCTuMFSeTddGiEejA== X-Received: by 2002:a17:902:8488:: with SMTP id c8mr2742227plo.164.1569490833256; Thu, 26 Sep 2019 02:40:33 -0700 (PDT) Received: from xz-x1.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id p68sm3224982pfp.9.2019.09.26.02.40.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2019 02:40:32 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: David Hildenbrand , Hugh Dickins , Maya Gokhale , Jerome Glisse , Pavel Emelyanov , Johannes Weiner , peterx@redhat.com, Martin Cracauer , Matthew Wilcox , Shaohua Li , Marty McFadden , Andrea Arcangeli , Mike Kravetz , Denis Plotnikov , Mike Rapoport , Linus Torvalds , Mel Gorman , "Kirill A . Shutemov" , "Dr . David Alan Gilbert" Subject: [PATCH v5 09/16] mm: Return faster for non-fatal signals in user mode faults Date: Thu, 26 Sep 2019 17:38:57 +0800 Message-Id: <20190926093904.5090-10-peterx@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190926093904.5090-1-peterx@redhat.com> References: <20190926093904.5090-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: The idea comes from the upstream discussion between Linus and Andrea: https://lore.kernel.org/lkml/20171102193644.GB22686@redhat.com/ A summary to the issue: there was a special path in handle_userfault() in the past that we'll return a VM_FAULT_NOPAGE when we detected non-fatal signals when waiting for userfault handling. We did that by reacquiring the mmap_sem before returning. However that brings a risk in that the vmas might have changed when we retake the mmap_sem and even we could be holding an invalid vma structure. 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. Suggested-by: Linus Torvalds Suggested-by: Andrea Arcangeli Signed-off-by: Peter Xu --- include/linux/sched/signal.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h index 46429192733b..031af0a6505a 100644 --- a/include/linux/sched/signal.h +++ b/include/linux/sched/signal.h @@ -387,7 +387,8 @@ static inline bool fault_signal_pending(unsigned int = fault_flags, struct pt_regs *regs) { return unlikely((fault_flags & VM_FAULT_RETRY) && - fatal_signal_pending(current)); + (fatal_signal_pending(current) || + (user_mode(regs) && signal_pending(current)))); } =20 /* --=20 2.21.0