From patchwork Wed Apr 7 01:44:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michel Lespinasse X-Patchwork-Id: 12186435 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,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 76CB7C43460 for ; Wed, 7 Apr 2021 01:45:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F099C613A7 for ; Wed, 7 Apr 2021 01:45:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F099C613A7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=lespinasse.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D7D066B0088; Tue, 6 Apr 2021 21:45:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A6D066B0087; Tue, 6 Apr 2021 21:45:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6C4B36B0088; Tue, 6 Apr 2021 21:45:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0177.hostedemail.com [216.40.44.177]) by kanga.kvack.org (Postfix) with ESMTP id 3315E6B0083 for ; Tue, 6 Apr 2021 21:45:07 -0400 (EDT) Received: from smtpin34.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id ED1EE6C2F for ; Wed, 7 Apr 2021 01:45:06 +0000 (UTC) X-FDA: 78003877812.34.E328646 Received: from server.lespinasse.org (server.lespinasse.org [63.205.204.226]) by imf11.hostedemail.com (Postfix) with ESMTP id E718C200025C for ; Wed, 7 Apr 2021 01:45:01 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=lespinasse.org; i=@lespinasse.org; q=dns/txt; s=srv-11-ed; t=1617759902; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : from; bh=JSd8USyA44o7aisWRjJJmP/cvdrCX+QQ/xlTQKWni9A=; b=Mcq+tvl8z5tdgleIqie0lPGvo52Y/rVkX9Q70gSnW7/1nyO4h6x8+Y2tLz3+q6ZOfws7j 20Cpmhpc2n1VjYPDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lespinasse.org; i=@lespinasse.org; q=dns/txt; s=srv-11-rsa; t=1617759902; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : from; bh=JSd8USyA44o7aisWRjJJmP/cvdrCX+QQ/xlTQKWni9A=; b=ZSb7AHc/7/Pz09SX05JdQA0njLz+syzdV2IXZAgfAHmhRiolcNlHFH/3CNdEGBhnxENFM B4iV1cVjTFVKtRgcF4s2AFnptqp+XUyF7ZraP83Sk13Iq+aIpCYR4kv2jqtjwSs7I42jsH/ l/ipYRoZmqWwLoG3sounZvnGVXm4LAHBE+W00nAPf4xNvab25u0YkZT2c/RNx1xuPlofCU3 +i0wp85qLr/QEz1QOtdIas/1QNehEw9qRfnBzJBkX2sN6eRc9crG95VDt8WMl9ODNYEWAbK T9yhTEI5D4yBMKN8q4v7gViGKwCe8eL6g0oyVdtx6idZFEqT8ARf7Cd0ZItg== Received: from zeus.lespinasse.org (zeus.lespinasse.org [IPv6:fd00::150:0]) by server.lespinasse.org (Postfix) with ESMTPS id 9B7ED160253; Tue, 6 Apr 2021 18:45:02 -0700 (PDT) Received: by zeus.lespinasse.org (Postfix, from userid 1000) id 8C3BA19F31D; Tue, 6 Apr 2021 18:45:02 -0700 (PDT) From: Michel Lespinasse To: Linux-MM Cc: Laurent Dufour , Peter Zijlstra , Michal Hocko , Matthew Wilcox , Rik van Riel , Paul McKenney , Andrew Morton , Suren Baghdasaryan , Joel Fernandes , Rom Lemarchand , Linux-Kernel , Michel Lespinasse Subject: [RFC PATCH 08/37] mm: add do_handle_mm_fault() Date: Tue, 6 Apr 2021 18:44:33 -0700 Message-Id: <20210407014502.24091-9-michel@lespinasse.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210407014502.24091-1-michel@lespinasse.org> References: <20210407014502.24091-1-michel@lespinasse.org> MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: E718C200025C X-Stat-Signature: u6h9mx95xzhc3ec354p5aroyjxtqpq1r Received-SPF: none (lespinasse.org>: No applicable sender policy available) receiver=imf11; identity=mailfrom; envelope-from=""; helo=server.lespinasse.org; client-ip=63.205.204.226 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617759901-749081 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: Add a new do_handle_mm_fault function, which extends the existing handle_mm_fault() API by adding an mmap sequence count, to be used in the FAULT_FLAG_SPECULATIVE case. In the initial implementation, FAULT_FLAG_SPECULATIVE always fails (by returning VM_FAULT_RETRY). The existing handle_mm_fault() API is kept as a wrapper around do_handle_mm_fault() so that we do not have to immediately update every handle_mm_fault() call site. Signed-off-by: Michel Lespinasse --- include/linux/mm.h | 12 +++++++++--- mm/memory.c | 10 +++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 021fdab5b721..d5988e78e6ab 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1724,9 +1724,15 @@ int generic_error_remove_page(struct address_space *mapping, struct page *page); int invalidate_inode_page(struct page *page); #ifdef CONFIG_MMU -extern vm_fault_t handle_mm_fault(struct vm_area_struct *vma, - unsigned long address, unsigned int flags, - struct pt_regs *regs); +extern vm_fault_t do_handle_mm_fault(struct vm_area_struct *vma, + unsigned long address, unsigned int flags, + unsigned long seq, struct pt_regs *regs); +static inline vm_fault_t handle_mm_fault(struct vm_area_struct *vma, + unsigned long address, unsigned int flags, + struct pt_regs *regs) +{ + return do_handle_mm_fault(vma, address, flags, 0, regs); +} extern int fixup_user_fault(struct mm_struct *mm, unsigned long address, unsigned int fault_flags, bool *unlocked); diff --git a/mm/memory.c b/mm/memory.c index 477c98bfdd9d..3691be1f1319 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4509,11 +4509,15 @@ static inline void mm_account_fault(struct pt_regs *regs, * The mmap_lock may have been released depending on flags and our * return value. See filemap_fault() and __lock_page_or_retry(). */ -vm_fault_t handle_mm_fault(struct vm_area_struct *vma, unsigned long address, - unsigned int flags, struct pt_regs *regs) +vm_fault_t do_handle_mm_fault(struct vm_area_struct *vma, + unsigned long address, unsigned int flags, + unsigned long seq, struct pt_regs *regs) { vm_fault_t ret; + if (flags & FAULT_FLAG_SPECULATIVE) + return VM_FAULT_RETRY; + __set_current_state(TASK_RUNNING); count_vm_event(PGFAULT); @@ -4555,7 +4559,7 @@ vm_fault_t handle_mm_fault(struct vm_area_struct *vma, unsigned long address, return ret; } -EXPORT_SYMBOL_GPL(handle_mm_fault); +EXPORT_SYMBOL_GPL(do_handle_mm_fault); #ifndef __PAGETABLE_P4D_FOLDED /*