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.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 A7D31C11D05 for ; Thu, 20 Feb 2020 16:04:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 59CEA20659 for ; Thu, 20 Feb 2020 16:04:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Zwm6u9b5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 59CEA20659 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 0A89A6B0003; Thu, 20 Feb 2020 11:04:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 031046B000A; Thu, 20 Feb 2020 11:04:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E3BA36B000C; Thu, 20 Feb 2020 11:04:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0170.hostedemail.com [216.40.44.170]) by kanga.kvack.org (Postfix) with ESMTP id C65CC6B0003 for ; Thu, 20 Feb 2020 11:04:19 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 69E79181AEF21 for ; Thu, 20 Feb 2020 16:04:19 +0000 (UTC) X-FDA: 76510977438.23.guide27_51d1d9fc55d1a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id 004323A51A for ; Thu, 20 Feb 2020 16:02:42 +0000 (UTC) X-HE-Tag: guide27_51d1d9fc55d1a X-Filterd-Recvd-Size: 5620 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Thu, 20 Feb 2020 16:02:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582214561; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lWKwPhahZpSUBnt100XJWbQdRLQCpzYlK8vHHwiuuLM=; b=Zwm6u9b5YWwJls6zXybjWFMdS+jMtrKRuY6uF7cGNnQsvLEna5N+n34hK0CThcMubawjcz PRfA9em4n8o5CO9T1vMzEU+TP227Ely7A8CfUWZ4jTe18gs1XAK3kfkDdJn2HkntIgwTdN 9kb5UzsKumEt89TP3qhF87NYI/GTOrc= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-60-nXpgt1k3O4WXjcjr77WzwA-1; Thu, 20 Feb 2020 11:02:35 -0500 X-MC-Unique: nXpgt1k3O4WXjcjr77WzwA-1 Received: by mail-qk1-f198.google.com with SMTP id c77so3039055qke.7 for ; Thu, 20 Feb 2020 08:02:35 -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=ZV5sRyntf0+M2WjfLiyPs+XgTlCWnjkOIA0alCn5h7M=; b=OHJenYZx1jalbD4LwfxppVkRKl6DDoTvXrpNYYD0JhVuZQI2e2QIvPBg4ov9bkSAUL UBy/abhRZPDAJfwcjU4jgWqrMal9uabSYHcd0DJUWOyCyGUJwjCp2mMDMmxzOPGdd48A wdyNarnjsMdvyODBksmRK6I8d2DOXUbN55EdADr4W0VNW89fZpZ3BU/8j5f9fYgatjMp Mw7J1H39t+dZv74GjPNaaogoB3nLblZdl2SmSD3sUD2y9VXvEhWejdWTb3+KwG6Q554B /ldoscMXHNoQhlVi0kii9voxeu6yHP/DmeGerkNsWjvQlUXCqT3+cUEgx26H9h8LjFu3 ty0A== X-Gm-Message-State: APjAAAVSXEPpRK3pNN/AUx2to5cu/BocnietWbJUc5gq29xN6I6jJsQs hNqEDbmKcY/wNkNCgTzvxPlIdG7z8ModB79s2tf6/c+BH72Tgy9w7irUmedUFRTbFhJxrIT8yZk otA1V4JNA1VA= X-Received: by 2002:a37:714:: with SMTP id 20mr28851974qkh.347.1582214553472; Thu, 20 Feb 2020 08:02:33 -0800 (PST) X-Google-Smtp-Source: APXvYqxZHO0FXZai3X5wFkgabOPgehys+9qPT+3+TrtyslPTs5BnSW78NcqKByQgATBzv4ScYKwjog== X-Received: by 2002:a37:714:: with SMTP id 20mr28851937qkh.347.1582214553239; Thu, 20 Feb 2020 08:02:33 -0800 (PST) Received: from xz-x1.redhat.com ([104.156.64.75]) by smtp.gmail.com with ESMTPSA id g18sm2301qki.13.2020.02.20.08.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Feb 2020 08:02:32 -0800 (PST) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Peter Xu , Martin Cracauer , Mike Rapoport , Hugh Dickins , Jerome Glisse , "Kirill A . Shutemov" , Matthew Wilcox , Pavel Emelyanov , Brian Geffon , Maya Gokhale , Denis Plotnikov , Andrea Arcangeli , Johannes Weiner , "Dr . David Alan Gilbert" , Linus Torvalds , Mike Kravetz , Marty McFadden , David Hildenbrand , Bobby Powers , Mel Gorman Subject: [PATCH RESEND v6 09/16] mm: Return faster for non-fatal signals in user mode faults Date: Thu, 20 Feb 2020 11:02:30 -0500 Message-Id: <20200220160230.9598-1-peterx@redhat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200220155353.8676-1-peterx@redhat.com> References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII 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 4c87ffce64d1..09d40ce6a162 100644 --- a/include/linux/sched/signal.h +++ b/include/linux/sched/signal.h @@ -379,7 +379,8 @@ static inline bool fault_signal_pending(unsigned int fa= ult_flags, =09=09=09=09=09struct pt_regs *regs) { =09return unlikely((fault_flags & VM_FAULT_RETRY) && -=09=09=09fatal_signal_pending(current)); +=09=09=09(fatal_signal_pending(current) || +=09=09=09 (user_mode(regs) && signal_pending(current)))); } =20 /* --=20 2.24.1