From patchwork Mon Jul 10 20:43:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13307616 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC47FEB64D9 for ; Mon, 10 Jul 2023 20:44:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3504B8E0011; Mon, 10 Jul 2023 16:43:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F1158E0012; Mon, 10 Jul 2023 16:43:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D48918E000F; Mon, 10 Jul 2023 16:43:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 9A9E98E000B for ; Mon, 10 Jul 2023 16:43:49 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 751F5C0263 for ; Mon, 10 Jul 2023 20:43:49 +0000 (UTC) X-FDA: 80996878578.02.F7B76BD Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf09.hostedemail.com (Postfix) with ESMTP id CEBF4140010 for ; Mon, 10 Jul 2023 20:43:47 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=TyH0uCOA; dmarc=none; spf=none (imf09.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689021827; a=rsa-sha256; cv=none; b=UVIuT4FkO2EbueBDGUUPzGGBvNFquICJZn9fTQRyjA1WmgT/dba7KKd/RUHb34taybsa+Z izvre6cwLpEeTD94G4zgkdYJbgBav/HKhICS6v/GzAKMgZqQiZaU+jSyXXABfkUHLNFMw0 v8gAwrYsS2ccCRIr0trZf+5sjZL4rww= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=TyH0uCOA; dmarc=none; spf=none (imf09.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689021827; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=nV5u7fUN7eLvvulKehuO2ZLa6X1ni8Kq3NCH3wI1W68=; b=ri1acMx+pwWwPuZM5BMB33RyPhna3MDi4KrN9y7J8DywTN2Errwz1PoOPl3K5Q+tXY5/aQ yd/54lMaQakhkHH1FC/Sixevrd2DMXTur3dYWkdMFY4gP4l2EQ9pGWXVit+EItaKicsaEs ylRpV1eDgf8Twyi8LmZ0VLBga/2baYI= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=nV5u7fUN7eLvvulKehuO2ZLa6X1ni8Kq3NCH3wI1W68=; b=TyH0uCOAc3cacwsNtSZ03toNxz /ldDgYNddIyTOMMCZ1doy4k1qRn3NKk9gaueXlr9Q9ZVwH7d6MVaJwERahiAgCAgQAxDi5JRsVFDi 3eHBvfR1ifNIth5VmyFLKtzah2dSw0acjuFg5RowKxVCVLH2xhcDXdP5tmz+HHmuLnfag6TRgXq0C dDUGPZDTEpllcYWbCHppyfSaiB6v5Mq+VWBJB8++zjxej6Zzy2RAjB9w/UOfYIH27C4iZJqdMPgje lL8zXH5n6a9ozIhoQ12ZP4f/qyLyI35Z5owqmkGKE52ljgsHGgjeLRIaU1mxeXq43+5KR7nDuWuP4 DjHkWKSA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qIxjV-00Euru-MR; Mon, 10 Jul 2023 20:43:45 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 38/38] mm: Call update_mmu_cache_range() in more page fault handling paths Date: Mon, 10 Jul 2023 21:43:39 +0100 Message-Id: <20230710204339.3554919-39-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230710204339.3554919-1-willy@infradead.org> References: <20230710204339.3554919-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: CEBF4140010 X-Stat-Signature: 5kjemgpwctdfm5d9151qwh41u4z6tduu X-HE-Tag: 1689021827-149359 X-HE-Meta: U2FsdGVkX1/GTOy02sLhM9GlGmkmiuadI71HUc9vRB/03c+5jq2EXMOhkBZAFIIBC+0urBuyk+RNNA18asK2FzgoO0I6+NsNUl7QfhlvkuB1jhYUxgOAVVXqdiS4fSD5+awh4LsYjUEBu08/bBkkrcouD2yYQwzbFMXcTIWQMNJagTSUT/0t4Yd8IsCd+EyIAwc/gb2kzwyHKy7/pPDSw0P72njqyfRnfUBXS+EpkWPYYIu07HKOtEQa5ZDg1650vpH8KQvPj0DTR3+KarSLQX7CKGpfuSB4Vnvg8usroYqOHvDDx/LUpabdf0YmbpQtxqD8LA941ONhWyPcK7GbIfZO18ubx4hE9GmkUwDQSBMf9bGtFElRivmhCAa116KRiANPIYJIv3r2V8Vod127RertgIDMvJ4RdmfRsyXFb3qd6TP+UYuAzBkT7Np1NgHR4TAsax7bAHPVeovV9yOmtItL161aB4Qw1EFiJYCvq7AqGpH1wdxTnVe+PuoRfXi8olaMrMGI2Q6OdQEZeoHsi7sSMuk6m0zIcukddnfD6z76WJtf1mKLMWTPgQFvougq59p1SXs/CkXOW2C6uyGUE1H2GFe7C7J48MtTdneCbil3whZm5sEsv/moVaMiqSDM/qbSKcOBDopSKtbEByt+XugNGFn//1+38FP3Zb/6f29yDkAj2smTnh+YgpSUSGlNNCXqFc1lCwLQ/N3RaUbNYdDn8+oHljKR+8gVoH0naF8GPCNUpA55MKTb0SlNCPZGweFWi5UU/ooymfdPEdObAl6Xs9iP9uU31YTDpttB/5ZAhvNjTneuFN6RJ96djTc33Hawk6z+7jPFnDy7yLRc+tRuCpU1iJJWFsHEldhD/09KftuZNXNwMlfFAhAr3BNTEtoGX0/3nzP2l5xuu93yDRc/2cBfYRoeoZ2RiCGtkSV4NBkoWvmWj7fe6+bQ55YkLxMOTo7r94l/dWqYQJ3 u3OElg+N o1TKNm6yHVYKgvh51h+FcAPl/CnswaOQ3lKMicHUeItFnA6e42pjtzhaC0GjI6L4XYowrT9cZWyUA5s1Ps/H+smnR8E4iW92d05BW2tVYxJJM/2SEWSEcg9hY+On1i9IJnqziJxpTLe0zqTRSnpZgXfhMh0gWxDj2h15JUqF3YYepJgaL0rAyBorKaG3kdDAPDK2I377Kp/x+NC7fPURZ5At6ZPbAuUaPTsIR 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: Pass the vm_fault to the architecture to help it make smarter decisions about which PTEs to insert into the TLB. Signed-off-by: Matthew Wilcox (Oracle) --- mm/memory.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index e712e5fda56e..8dc54e412269 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2867,7 +2867,7 @@ static inline int __wp_page_copy_user(struct page *dst, struct page *src, entry = pte_mkyoung(vmf->orig_pte); if (ptep_set_access_flags(vma, addr, vmf->pte, entry, 0)) - update_mmu_cache(vma, addr, vmf->pte); + update_mmu_cache_range(vmf, vma, addr, vmf->pte, 1); } /* @@ -3045,7 +3045,7 @@ static inline void wp_page_reuse(struct vm_fault *vmf) entry = pte_mkyoung(vmf->orig_pte); entry = maybe_mkwrite(pte_mkdirty(entry), vma); if (ptep_set_access_flags(vma, vmf->address, vmf->pte, entry, 1)) - update_mmu_cache(vma, vmf->address, vmf->pte); + update_mmu_cache_range(vmf, vma, vmf->address, vmf->pte, 1); pte_unmap_unlock(vmf->pte, vmf->ptl); count_vm_event(PGREUSE); } @@ -3169,7 +3169,7 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) */ BUG_ON(unshare && pte_write(entry)); set_pte_at_notify(mm, vmf->address, vmf->pte, entry); - update_mmu_cache(vma, vmf->address, vmf->pte); + update_mmu_cache_range(vmf, vma, vmf->address, vmf->pte, 1); if (old_folio) { /* * Only after switching the pte to the new page may @@ -4039,7 +4039,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) } /* No need to invalidate - it was non-present before */ - update_mmu_cache(vma, vmf->address, vmf->pte); + update_mmu_cache_range(vmf, vma, vmf->address, vmf->pte, 1); unlock: if (vmf->pte) pte_unmap_unlock(vmf->pte, vmf->ptl); @@ -4163,7 +4163,7 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) set_pte_at(vma->vm_mm, vmf->address, vmf->pte, entry); /* No need to invalidate - it was non-present before */ - update_mmu_cache(vma, vmf->address, vmf->pte); + update_mmu_cache_range(vmf, vma, vmf->address, vmf->pte, 1); unlock: if (vmf->pte) pte_unmap_unlock(vmf->pte, vmf->ptl); @@ -4837,7 +4837,7 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf) if (writable) pte = pte_mkwrite(pte); ptep_modify_prot_commit(vma, vmf->address, vmf->pte, old_pte, pte); - update_mmu_cache(vma, vmf->address, vmf->pte); + update_mmu_cache_range(vmf, vma, vmf->address, vmf->pte, 1); pte_unmap_unlock(vmf->pte, vmf->ptl); goto out; } @@ -4986,7 +4986,8 @@ static vm_fault_t handle_pte_fault(struct vm_fault *vmf) entry = pte_mkyoung(entry); if (ptep_set_access_flags(vmf->vma, vmf->address, vmf->pte, entry, vmf->flags & FAULT_FLAG_WRITE)) { - update_mmu_cache(vmf->vma, vmf->address, vmf->pte); + update_mmu_cache_range(vmf, vmf->vma, vmf->address, + vmf->pte, 1); } else { /* Skip spurious TLB flush for retried page fault */ if (vmf->flags & FAULT_FLAG_TRIED)