Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp821233ybv; Thu, 20 Feb 2020 07:54:45 -0800 (PST) X-Google-Smtp-Source: APXvYqzGbtC1Hfe8YTbJO4x93zMiWmMdKEYSJxwmlMg9jlufwZu6T+ddmJcuArLfErSRmfA7gU/G X-Received: by 2002:a9d:2264:: with SMTP id o91mr12864314ota.328.1582214085443; Thu, 20 Feb 2020 07:54:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582214085; cv=none; d=google.com; s=arc-20160816; b=P70dwFZ9+77EC4p8Uf447k8OCsLFCzBH/a+RC/nLGby2m1fddlq1TPv6IF4Pwm4n+T pDah2pzgY6f+LlZt8Vxf+HsbPyue7Hq+TWAEtmjgXDEM/E+GHERRLvZplVzZ9cYSN+5z 0hqgkkI55RPcGvMtbxPP765CitrjabR9C6uwhgua/PpsWu/6KriMBV1K0nw6JdyXtZQ1 dhhCH0LEQBA+PmJ5qp94hfhPAdhBub2aZxt1ELWcj46tPF5aAELl1idweVJCzT9A3B/d 7GcaoRP9UQxhjtMViIUNCckfFKh+M0RMKiFn/JQ74JyxGUs1bSMxvmphPZ85s89YP7MF heFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3cu+nCrF0vUC0DWPMISJ46Dyo+A/qgWPAj0jcXPlop0=; b=XNvQF68I2PJldbNHjAM71kmbsV75kCjlmuaoK7UfSYufg/Q2ar6AGzAao3117pkNCD 0iBzmDtNpVo4C101FjHiVC8FbA0Ip+iZYXvZmr7GEpJiTnOXG8JG4ZJC5vVl8YM//UfF hJiYWuV10zS5ACxWJUBRKkcEixdn4oj0A44f25ljGQTsFA6UhwU126E9s/K/8MT2RvZo VREGcMMwnvBHRbCtFIN5hMXPRZvJYBd6KZsVMisJKYLxsmLjo48afbdJNWXgCAF2JHC/ h8btVLGzHe7ojYC97aAAyfal5+1XAp/EHXr46Lkdk4aC3J2VPpSdXqDPSX+Ckg6gD2lG nKJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XrCWY6F+; 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=pass (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 j20si1697425otp.147.2020.02.20.07.54.31; Thu, 20 Feb 2020 07:54:45 -0800 (PST) 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=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XrCWY6F+; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728621AbgBTPyK (ORCPT + 99 others); Thu, 20 Feb 2020 10:54:10 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:35651 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728602AbgBTPyJ (ORCPT ); Thu, 20 Feb 2020 10:54:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582214048; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3cu+nCrF0vUC0DWPMISJ46Dyo+A/qgWPAj0jcXPlop0=; b=XrCWY6F+Ap676vKabppYeOI/HFR35R5yPNA7Tr+SwJ5/DpHv8ZgTSYu6Fbu3DNwOl2DTT6 LBFOvibm7RL4PTalMW4xzi7gClWC8eI7Ybz1znEHX8qop/0Fm28fe3nPSrmXpfOgqvx1WT VeNbVjBdcapgDMwsCutUoy1iJVerm2k= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-288-yaqCZDlTOxyx1LO4_uJ8fQ-1; Thu, 20 Feb 2020 10:54:07 -0500 X-MC-Unique: yaqCZDlTOxyx1LO4_uJ8fQ-1 Received: by mail-qt1-f198.google.com with SMTP id t4so2885424qtd.3 for ; Thu, 20 Feb 2020 07:54:07 -0800 (PST) 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=3cu+nCrF0vUC0DWPMISJ46Dyo+A/qgWPAj0jcXPlop0=; b=Ez4ASygG4u04JqMMc6N0s8padNLHlEFr3ESHqKSOcl8yMQt+xraKAAL8Bu/oqY9IkB UrjeeAQfC+JfxiI824rcBvCeFKarhoVfeMpHmwFkucjTPI/lJCSit44VWsVL+oCUOf8c L5N715JUdfqnw7wxdVW6+gGmYk5JIJ61wfC9QEtakCVPh+njWh7sbbliwR2vC/GFEr8r O0a+/iwHFDIGJtH++lI8lO8Wz7saAFA8oqOXYJjzFH63g4DV66u6k0S5bCxuqcbM/uke 8Scg7lm4Ns5LT22oI5pNIvSr4i4Vcd+1d6V8fLEidAkv8l3V/YHlsivENRoCvlGBJpa4 drrw== X-Gm-Message-State: APjAAAWTn6bbIvDd3vy8/xKlR5eyaWwxdceHtGbESg+yrxFPdFH5LNfV YqT1rvFk+uOBVZmTSi/gjs7e2eekEiGnYRKn43gawRsUxxDZwAgNvBU93ilHETeR7IGcOyh/U5h 6Z2aSJm1v8TaSMWzF2Zd/oal/ X-Received: by 2002:ae9:e003:: with SMTP id m3mr8332088qkk.250.1582214044027; Thu, 20 Feb 2020 07:54:04 -0800 (PST) X-Received: by 2002:ae9:e003:: with SMTP id m3mr8332062qkk.250.1582214043787; Thu, 20 Feb 2020 07:54:03 -0800 (PST) Received: from xz-x1.redhat.com ([104.156.64.75]) by smtp.gmail.com with ESMTPSA id h20sm1807430qkk.64.2020.02.20.07.54.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Feb 2020 07:54:03 -0800 (PST) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Andrea Arcangeli , Martin Cracauer , Linus Torvalds , Mike Rapoport , "Kirill A . Shutemov" , Johannes Weiner , "Dr . David Alan Gilbert" , David Hildenbrand , Bobby Powers , Maya Gokhale , Jerome Glisse , Mike Kravetz , Matthew Wilcox , Marty McFadden , Mel Gorman , peterx@redhat.com, Hugh Dickins , Brian Geffon , Denis Plotnikov , Pavel Emelyanov Subject: [PATCH RESEND v6 04/16] x86/mm: Use helper fault_signal_pending() Date: Thu, 20 Feb 2020 10:53:41 -0500 Message-Id: <20200220155353.8676-5-peterx@redhat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200220155353.8676-1-peterx@redhat.com> References: <20200220155353.8676-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 fa4ea09593ab..6a00bc8d047f 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -1442,27 +1442,25 @@ void do_user_addr_fault(struct pt_regs *regs, fault = handle_mm_fault(vma, address, flags); major |= fault & VM_FAULT_MAJOR; + /* 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 &= ~FAULT_FLAG_ALLOW_RETRY; - flags |= 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 &= ~FAULT_FLAG_ALLOW_RETRY; + flags |= FAULT_FLAG_TRIED; + goto retry; } up_read(&mm->mmap_sem); -- 2.24.1