From patchwork Fri Apr 30 19:52:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michel Lespinasse X-Patchwork-Id: 12234193 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,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 3717AC433ED for ; Fri, 30 Apr 2021 19:53:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D17526146D for ; Fri, 30 Apr 2021 19:53:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D17526146D 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 9AAAF6B0095; Fri, 30 Apr 2021 15:52:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D03236B008A; Fri, 30 Apr 2021 15:52:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 538476B009F; Fri, 30 Apr 2021 15:52:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0006.hostedemail.com [216.40.44.6]) by kanga.kvack.org (Postfix) with ESMTP id 28EDD6B0092 for ; Fri, 30 Apr 2021 15:52:38 -0400 (EDT) Received: from smtpin35.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id DA923180AF920 for ; Fri, 30 Apr 2021 19:52:37 +0000 (UTC) X-FDA: 78090080754.35.C865AA5 Received: from server.lespinasse.org (server.lespinasse.org [63.205.204.226]) by imf30.hostedemail.com (Postfix) with ESMTP id F37CAE000123 for ; Fri, 30 Apr 2021 19:52:15 +0000 (UTC) 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=1L50YJ40ZUGhKi7U56okv5p4ypQrfJ9Qy1e+oZQLfEs=; b=Brwwj7gJyZRfaNkZXJQVGbs8sZpxuIJtgdHMAi1QT3YHt8Bee/ZoafHWKKtqdak76+hm7 Zkxt0jIKt4dvdwkAw== 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=1L50YJ40ZUGhKi7U56okv5p4ypQrfJ9Qy1e+oZQLfEs=; b=ouNOvDWkDxT2pSbRkmI32QMVAK9o/l9HE++tUyWfAi5lB/O0izySgxB6nzXJ+UKfpnHmx +n7kKQ2SWEHvsaTGG90ts4eyff88aM3tiLqQOmAEnz9AXk5kHBJ2L+aANfN7P/HfDqQCXL5 4hmfCw4JsNphr/TmFIYIJrnBWT5/2zMSnD84vK5AqH8mZ9S/h6EEtmt4R8x9RXkcdi2NJXY QCmVi9n1n0vvwDg6lR7ogUk7bR4uz7bSPyUCsNZz1m4dCBHBkNqRdGgmWdzK4QSNzjI/qlz XCvGtDkIE1sX7/T4etK/S4N4HWmfKfIJIocGbiT19PAprQylJxc6pSF04W7Q== Received: from zeus.lespinasse.org (zeus.lespinasse.org [IPv6:fd00::150:0]) by server.lespinasse.org (Postfix) with ESMTPS id 90A4D16033C; Fri, 30 Apr 2021 12:52:33 -0700 (PDT) Received: by zeus.lespinasse.org (Postfix, from userid 1000) id 8343919F522; 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 20/29] mm: enable speculative fault handling in do_numa_page() Date: Fri, 30 Apr 2021 12:52:21 -0700 Message-Id: <20210430195232.30491-21-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 Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=lespinasse.org header.s=srv-14-ed header.b=Brwwj7gJ; dkim=pass header.d=lespinasse.org header.s=srv-14-rsa header.b=ouNOvDWk; dmarc=pass (policy=none) header.from=lespinasse.org; spf=pass (imf30.hostedemail.com: domain of walken@lespinasse.org designates 63.205.204.226 as permitted sender) smtp.mailfrom=walken@lespinasse.org X-Rspamd-Server: rspam03 X-Stat-Signature: 516x5j6365yqx41umu9uo7nchkc3uzj6 X-Rspamd-Queue-Id: F37CAE000123 Received-SPF: none (lespinasse.org>: No applicable sender policy available) receiver=imf30; identity=mailfrom; envelope-from=""; helo=server.lespinasse.org; client-ip=63.205.204.226 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1619812335-19745 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: Change handle_pte_fault() to allow speculative fault execution to proceed through do_numa_page(). do_swap_page() does not implement speculative execution yet, so it needs to abort with VM_FAULT_RETRY in that case. Signed-off-by: Michel Lespinasse --- mm/memory.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index a2230269e034..286776b7795b 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3363,6 +3363,11 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) vm_fault_t ret = 0; void *shadow = NULL; + if (vmf->flags & FAULT_FLAG_SPECULATIVE) { + pte_unmap(vmf->pte); + return VM_FAULT_RETRY; + } + if (!pte_unmap_same(vma->vm_mm, vmf->pmd, vmf->pte, vmf->orig_pte)) goto out; @@ -4359,17 +4364,17 @@ static vm_fault_t handle_pte_fault(struct vm_fault *vmf) return do_fault(vmf); } - if (vmf->flags & FAULT_FLAG_SPECULATIVE) { - pte_unmap(vmf->pte); - return VM_FAULT_RETRY; - } - if (!pte_present(vmf->orig_pte)) return do_swap_page(vmf); if (pte_protnone(vmf->orig_pte) && vma_is_accessible(vmf->vma)) return do_numa_page(vmf); + if (vmf->flags & FAULT_FLAG_SPECULATIVE) { + pte_unmap(vmf->pte); + return VM_FAULT_RETRY; + } + vmf->ptl = pte_lockptr(vmf->vma->vm_mm, vmf->pmd); spin_lock(vmf->ptl); entry = vmf->orig_pte;