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.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, 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 ADD12C47E48 for ; Thu, 26 Sep 2019 09:39:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7D677222BE for ; Thu, 26 Sep 2019 09:39:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7D677222BE 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 332556B000D; Thu, 26 Sep 2019 05:39:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E3A16B000E; Thu, 26 Sep 2019 05:39:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1AB2D6B0010; Thu, 26 Sep 2019 05:39:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0188.hostedemail.com [216.40.44.188]) by kanga.kvack.org (Postfix) with ESMTP id F12286B000D for ; Thu, 26 Sep 2019 05:39:53 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 71A20181AC9CC for ; Thu, 26 Sep 2019 09:39:53 +0000 (UTC) X-FDA: 75976575066.28.spoon07_736a9b417f147 X-HE-Tag: spoon07_736a9b417f147 X-Filterd-Recvd-Size: 5063 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Thu, 26 Sep 2019 09:39:53 +0000 (UTC) Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.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 15C8350F4D for ; Thu, 26 Sep 2019 09:39:52 +0000 (UTC) Received: by mail-pl1-f197.google.com with SMTP id k9so1165753pls.13 for ; Thu, 26 Sep 2019 02:39:52 -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=nj2m7MUZQj6IXXRy4zbweijjogaCLtcKQ4EIZak4N0g=; b=q/tKaJH8GnE7Vg1UR1cd3aFF5FsgsDsOIqCmG6sdIQtxDMxUecVkbuatDAI/ntWFBJ s7TIIK2LMJud9zpqaqUqSusicw/j/NTbOaJsQXktBnE46PhcHMzKVNfRYQej1WWUxYpk UHBFOV16nVlghGmnzBHIzMcw583cSvx1LX9KpwKOv6cyyGgjzcAPt+C9r6gSczhAgl8k LSov1Avywk5DxjT12Ls6xhlObsnKFrnKf3ByRsnboycNPwN2hO9tbEDYmYDmqr23fTtB sKxESd938lHm0n6xfHakCVphs7FQmjy84Js0uLzxTti0ONq0LSZBT7jt/gUF2gRRJqnD +Vpw== X-Gm-Message-State: APjAAAXbxhqgBqoQpT7kqCbxMU1Thhtp0ION8wH66Dx4xQvtoAKgk3nF JC80wrpJtNUPhW3X3CxcernOWTCG8vd0NeIgMqqfTJPQR42yA+5LaEA2BSdjaOrv98RgY2Y1LDH gUgrkVjo6xkQ= X-Received: by 2002:a63:9742:: with SMTP id d2mr2391544pgo.356.1569490791005; Thu, 26 Sep 2019 02:39:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqw3zgXy3wRQcC9cw9sy7SwV86a9/+fNTVOhrGLjp87vBhGEjJORyCXZ82QFiBleXBcoc7oI5w== X-Received: by 2002:a63:9742:: with SMTP id d2mr2391518pgo.356.1569490790717; Thu, 26 Sep 2019 02:39:50 -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.39.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2019 02:39:50 -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 04/16] x86/mm: Use helper fault_signal_pending() Date: Thu, 26 Sep 2019 17:38:52 +0800 Message-Id: <20190926093904.5090-5-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: Let's move the fatal signal check even earlier so that we can directly use the new fault_signal_pending() in x86 mm code. Signed-off-by: Peter Xu --- arch/x86/mm/fault.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 9ceacd1156db..059331797827 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -1441,27 +1441,25 @@ void do_user_addr_fault(struct pt_regs *regs, fault =3D handle_mm_fault(vma, address, flags); major |=3D fault & VM_FAULT_MAJOR; =20 + /* Quick path to respond to signals */ + if (fault_signal_pending(fault, regs)) { + if (!user_mode(regs)) + no_context(regs, hw_error_code, address, SIGBUS, + BUS_ADRERR); + return; + } + /* * If we need to retry the mmap_sem has already been released, * and if there is a fatal signal pending there is no guarantee * that we made any progress. Handle this case first. */ - if (unlikely(fault & VM_FAULT_RETRY)) { + if (unlikely((fault & VM_FAULT_RETRY) && + (flags & FAULT_FLAG_ALLOW_RETRY))) { /* Retry at most once */ - if (flags & FAULT_FLAG_ALLOW_RETRY) { - flags &=3D ~FAULT_FLAG_ALLOW_RETRY; - flags |=3D FAULT_FLAG_TRIED; - if (!fatal_signal_pending(tsk)) - goto retry; - } - - /* User mode? Just return to handle the fatal exception */ - if (flags & FAULT_FLAG_USER) - return; - - /* Not returning to user mode? Handle exceptions or die: */ - no_context(regs, hw_error_code, address, SIGBUS, BUS_ADRERR); - return; + flags &=3D ~FAULT_FLAG_ALLOW_RETRY; + flags |=3D FAULT_FLAG_TRIED; + goto retry; } =20 up_read(&mm->mmap_sem); --=20 2.21.0