From owner-dev-commits-src-branches@freebsd.org Wed Sep 1 13:31:12 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 92B0466B48E; Wed, 1 Sep 2021 13:31:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4H04hJ0k9zz3hPw; Wed, 1 Sep 2021 13:31:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E3AAE25856; Wed, 1 Sep 2021 13:31:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 181DVBeK057131; Wed, 1 Sep 2021 13:31:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 181DVB0F057130; Wed, 1 Sep 2021 13:31:11 GMT (envelope-from git) Date: Wed, 1 Sep 2021 13:31:11 GMT Message-Id: <202109011331.181DVB0F057130@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 026f9acc3831 - stable/13 - pmap: Micro-optimize pmap_remove_pages() on amd64 and arm64 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 026f9acc383102202b42e411f594f1bc7889ac04 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Sep 2021 13:31:12 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=026f9acc383102202b42e411f594f1bc7889ac04 commit 026f9acc383102202b42e411f594f1bc7889ac04 Author: Alan Cox AuthorDate: 2021-07-12 23:25:37 +0000 Commit: Mark Johnston CommitDate: 2021-09-01 13:29:01 +0000 pmap: Micro-optimize pmap_remove_pages() on amd64 and arm64 Reduce the live ranges for three variables so that they do not span the call to PHYS_TO_VM_PAGE(). This enables the compiler to generate slightly smaller machine code. Reviewed by: kib, markj (cherry picked from commit d411b285bc293a37e062d8fb15b85212ce16abab) --- sys/amd64/amd64/pmap.c | 14 ++++++++++---- sys/arm64/arm64/pmap.c | 19 ++++++++++--------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index b920426e6996..b9a83cd8bbad 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -8158,6 +8158,16 @@ pmap_remove_pages(pmap_t pmap) continue; } + /* Mark free */ + pc->pc_map[field] |= bitmask; + + /* + * Because this pmap is not active on other + * processors, the dirty bit cannot have + * changed state since we last loaded pte. + */ + pte_clear(pte); + if (superpage) pa = tpte & PG_PS_FRAME; else @@ -8174,8 +8184,6 @@ pmap_remove_pages(pmap_t pmap) ("pmap_remove_pages: bad tpte %#jx", (uintmax_t)tpte)); - pte_clear(pte); - /* * Update the vm_page_t clean/reference bits. */ @@ -8189,8 +8197,6 @@ pmap_remove_pages(pmap_t pmap) CHANGE_PV_LIST_LOCK_TO_VM_PAGE(&lock, m); - /* Mark free */ - pc->pc_map[field] |= bitmask; if (superpage) { pmap_resident_count_adj(pmap, -NBPDR / PAGE_SIZE); pvh = pa_to_pvh(tpte & PG_PS_FRAME); diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index f0419beace37..1ae6d87dee51 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -5182,6 +5182,16 @@ pmap_remove_pages(pmap_t pmap) continue; } + /* Mark free */ + pc->pc_map[field] |= bitmask; + + /* + * Because this pmap is not active on other + * processors, the dirty bit cannot have + * changed state since we last loaded pte. + */ + pmap_clear(pte); + pa = tpte & ~ATTR_MASK; m = PHYS_TO_VM_PAGE(pa); @@ -5195,13 +5205,6 @@ pmap_remove_pages(pmap_t pmap) ("pmap_remove_pages: bad pte %#jx", (uintmax_t)tpte)); - /* - * Because this pmap is not active on other - * processors, the dirty bit cannot have - * changed state since we last loaded pte. - */ - pmap_clear(pte); - /* * Update the vm_page_t clean/reference bits. */ @@ -5219,8 +5222,6 @@ pmap_remove_pages(pmap_t pmap) CHANGE_PV_LIST_LOCK_TO_VM_PAGE(&lock, m); - /* Mark free */ - pc->pc_map[field] |= bitmask; switch (lvl) { case 1: pmap_resident_count_dec(pmap,