Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Nov 2023 18:47:47 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 71b77a7172c2 - main - riscv: Remove unnecessary invalidations in pmap_enter_quick_locked()
Message-ID:  <202311021847.3A2IllTH044804@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=71b77a7172c26783a9d2181d3bed27cf62974200

commit 71b77a7172c26783a9d2181d3bed27cf62974200
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-11-02 18:34:26 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-11-02 18:34:26 +0000

    riscv: Remove unnecessary invalidations in pmap_enter_quick_locked()
    
    This function always overwrites an invalid PTE, so if
    pmap_try_insert_pv_entry() fails it is certainly not necessary to
    invalidate anything, because the PTE has not yet been written by that
    point.
    
    It should also not be necessary to invalidate TLBs after overwriting an
    invalid entry.  In principle the TLB could cache negative entries, but
    then the worst case scenario is a spurious fault.  Since pmap_enter()
    does not bother issuing an sfence.vma, pmap_enter_quick_locked() should
    behave similarly.
    
    Reviewed by:    kib
    MFC after:      1 month
    Differential Revision:  https://reviews.freebsd.org/D42291
---
 sys/riscv/riscv/pmap.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c
index ebb0f069b4ab..f0108b611937 100644
--- a/sys/riscv/riscv/pmap.c
+++ b/sys/riscv/riscv/pmap.c
@@ -3458,11 +3458,9 @@ pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, vm_page_t m,
 	if (l3 == NULL)
 		panic("pmap_enter_quick_locked: No l3");
 	if (pmap_load(l3) != 0) {
-		if (mpte != NULL) {
+		if (mpte != NULL)
 			mpte->ref_count--;
-			mpte = NULL;
-		}
-		return (mpte);
+		return (NULL);
 	}
 
 	/*
@@ -3472,13 +3470,10 @@ pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, vm_page_t m,
 	    !pmap_try_insert_pv_entry(pmap, va, m, lockp)) {
 		if (mpte != NULL) {
 			SLIST_INIT(&free);
-			if (pmap_unwire_ptp(pmap, va, mpte, &free)) {
-				pmap_invalidate_page(pmap, va);
+			if (pmap_unwire_ptp(pmap, va, mpte, &free))
 				vm_page_free_pages_toq(&free, false);
-			}
-			mpte = NULL;
 		}
-		return (mpte);
+		return (NULL);
 	}
 
 	/*
@@ -3524,7 +3519,6 @@ pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, vm_page_t m,
 	}
 #endif
 
-	pmap_invalidate_page(pmap, va);
 	return (mpte);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202311021847.3A2IllTH044804>