Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp739815pxf; Wed, 7 Apr 2021 10:19:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytzz9hkyzPAO1its94fqMcc4Tt9Bvzldkru3oQNd8Jj08ZMlnMPNVmE5D0VL8Jj3p5FClh X-Received: by 2002:a02:a807:: with SMTP id f7mr2674370jaj.54.1617815976910; Wed, 07 Apr 2021 10:19:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617815976; cv=none; d=google.com; s=arc-20160816; b=NaspNcbNM8CxgU/oqdKO6cWugIHzWtP6AvT3O6aryoJms+OzO+zjUi40kpUofa7Vhd 6q45LgqmSPTMoCtq12LIv3cnJBB6GYBxqqME7/pr2YYT5n9+AdycdT2SYOdDNuVa3Z4a pbWSkDkQSuIS6WKVSxHwl0pdPs94ZItcyg+s9pvYerLKvfAaGas8c3aA4KagJ04kvlco XjYCgk1ch4jvsyBCSzK0r+iJp8tAbEdHL2mmJF5fdSbF8BrOe3g1fxpgQE11u+fppq27 3bH3LA84rtgGRZoS8wCKf448dAwT1Iyh3cBoBRUhhQIFj8sHqOC7daRF7BDVThVEGcip 9xNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=JSd8USyA44o7aisWRjJJmP/cvdrCX+QQ/xlTQKWni9A=; b=iZvSp2Y6NH0NZYbjCa7Pzr1SRmFn2doABWWSoopo/tiQ3uBsOSBiRNay95tGydkJqM CjFB2ba/YRjCFHqKr9MImZu3G41rfZnlT5W1pHlh4sI4bm+bRMP2nouTq1sC1G20fvcR 7BNGv2SwmjK6VgpjoqwWSZMLHJUEKO+6/SFXC3PMak0HYs2l/ijTX+EnsXJujw+9LgzO vhBRiLHAm/SgJ55IR0hiIVMNg5PKvanUF9Dv/VHwo4BcE2xqBw2p+wYCGpZTbKmmu9Vj Pi+zt2u5s4nP5S4p6cuRHEGjSIgWqXIx9GM6YnAryfKChDfF2HINGC6j2Lj9NVi5byeV oNIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (no key) header.i=@lespinasse.org header.s=srv-11-ed; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-11-rsa header.b="ZSb7AHc/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lespinasse.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u16si6240041iln.93.2021.04.07.10.19.23; Wed, 07 Apr 2021 10:19:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=neutral (no key) header.i=@lespinasse.org header.s=srv-11-ed; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-11-rsa header.b="ZSb7AHc/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lespinasse.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347827AbhDGBwx (ORCPT + 99 others); Tue, 6 Apr 2021 21:52:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347834AbhDGBvv (ORCPT ); Tue, 6 Apr 2021 21:51:51 -0400 Received: from server.lespinasse.org (unknown [IPv6:2602:303:fcdc:ce10::100:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA313C061763 for ; Tue, 6 Apr 2021 18:51:40 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 /* -- 2.20.1