Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp635507pxy; Fri, 30 Apr 2021 12:54:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz37Mb8pNIMtNDBZQKVZNdCo6680qZ0KcFxJDI7pG77zcklUGKEE8/WBR18HpPD3hz6y1Qy X-Received: by 2002:a62:29c2:0:b029:28c:d5f5:5ba3 with SMTP id p185-20020a6229c20000b029028cd5f55ba3mr4118875pfp.14.1619812453532; Fri, 30 Apr 2021 12:54:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619812453; cv=none; d=google.com; s=arc-20160816; b=gZcXTgBo/T1yKcL49XMchQhEIeye8JRxdc6JRVxMKOACFsYwHL/zh8a9x4x0F2fvIb JLCzwk1wokU3JcQU+dxnTolFEE1lvm1vUZFMeu/rruMHf2EItuUXQhOKGzJnsL42T3oU gpESLIQt7P++BuNbG0UIBYyLSZBTjbQF6bgsD7ISn3a+nqd74gva6mK9axpFNoRMyzNs J7+OB8kuXSfHeDmK28a5+ODnUEFcXWNsVFMv2d1CiQEZNMDgBqlZiGy1xI1e1a7qP0Fj UuGMG416L9BGmhgw2ZljnwsGkkX19EjDRoz/fLCZXbIP1WELV75GQ2vYmhjXaZY3AwhV RCLA== 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=BLfb3AqVSS1iZWKnBAI32as/v1HrLIIvwM3hMYePNUI=; b=Tbmfq71+W+M1bVEowaxkP+6Ad9/A4LyGvgWDHIFp8yXkZcXFhMP5Sl5Mxq/a3RvYvc bDWk97x9l2gFrq1orEFyTGpsWK9x+yAjopkpdAqdlDq8Qa4Wi6JziJiqlYWb885m2IoZ 7qaVTmU4HZnYuL+amy4LYOOp5A3zeg06ugeAwr9fIY5w4JYE4O6IuZqFPeMmgZEYMJp5 uOUSog/yK4VYqL+PTVScZnkkeOtCeZSRQhm991SC3mtLbpPkKfl9l6VjRh4qz8FYhzyK 8/pOT5Mn3ZL0TlXiKbQeNV9pxg7OAkO4cg+7ehwpXEPNbgg3+pgM71qMVrVZEcqrQntR aalQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (no key) header.i=@lespinasse.org header.s=srv-14-ed header.b=8cMpbIOW; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-14-rsa header.b=DpIS0cFI; 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 o4si3140471pjp.7.2021.04.30.12.54.01; Fri, 30 Apr 2021 12:54:13 -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-14-ed header.b=8cMpbIOW; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-14-rsa header.b=DpIS0cFI; 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 S233631AbhD3Txz (ORCPT + 99 others); Fri, 30 Apr 2021 15:53:55 -0400 Received: from server.lespinasse.org ([63.205.204.226]:47601 "EHLO server.lespinasse.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232323AbhD3TxY (ORCPT ); Fri, 30 Apr 2021 15:53:24 -0400 DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=lespinasse.org; i=@lespinasse.org; q=dns/txt; s=srv-14-ed; t=1619812353; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : from; bh=BLfb3AqVSS1iZWKnBAI32as/v1HrLIIvwM3hMYePNUI=; b=8cMpbIOWRRdLq4qrH07ZoApzOUUqxKhtXC5TX3uGlt6u+RUpiVpcE9PrmNQePGgU2/K/e a5JOxs2y8H+oTEoCQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lespinasse.org; i=@lespinasse.org; q=dns/txt; s=srv-14-rsa; t=1619812353; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : from; bh=BLfb3AqVSS1iZWKnBAI32as/v1HrLIIvwM3hMYePNUI=; b=DpIS0cFIofpJRFqMCJ61gjVijTff1dHnb1HPNRT1ZgY0tp/JXtLD9wd4oL+SrkGgcVvBO KMzFQepiwY1MBrqX3MbFVG0nrARR9h8xY42hFlnylvzNSekRPkJlpHirQ5xtxFdzcAU3cB9 1gj9/pjpbfCUZguQONX4fogFhe0N7MEDP1Nk9+74LwpTp5KxOfkBaDq09oPjlQqpEMdGeWr LANhkPfVDjI7lUJ+HQNB5DgVXhPDmlON4GsxCTQDgKHIJg2HVSe2lchFlRpo3M5eUnVe6yG qK6biGFrXSuBT8XVyl8swV17MF/DsmFVvc5054DirfuOL+J7p3G4+H+kBQUw== Received: from zeus.lespinasse.org (zeus.lespinasse.org [10.0.0.150]) by server.lespinasse.org (Postfix) with ESMTPS id 437BF16031E; Fri, 30 Apr 2021 12:52:33 -0700 (PDT) Received: by zeus.lespinasse.org (Postfix, from userid 1000) id 3666A19F521; Fri, 30 Apr 2021 12:52:33 -0700 (PDT) From: Michel Lespinasse To: Linux-MM , Linux-Kernel Cc: Laurent Dufour , Peter Zijlstra , Michal Hocko , Matthew Wilcox , Rik van Riel , Paul McKenney , Andrew Morton , Suren Baghdasaryan , Joel Fernandes , Andy Lutomirski , Michel Lespinasse Subject: [PATCH 09/29] mm: add do_handle_mm_fault() Date: Fri, 30 Apr 2021 12:52:10 -0700 Message-Id: <20210430195232.30491-10-michel@lespinasse.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210430195232.30491-1-michel@lespinasse.org> References: <20210430195232.30491-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 217c31c616f4..8258ff93a055 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