aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Cox <alc@FreeBSD.org>2021-06-23 19:14:31 +0000
committerAlan Cox <alc@FreeBSD.org>2021-06-24 03:35:46 +0000
commit0c188c06c627b5de30eeeeb7cde00d071a80ecfa (patch)
treead8bcb631743109583350598e831b330fbc00648
parent33e1287b6a54672860d6646111ef0e544a00c569 (diff)
downloadsrc-0c188c06c627b5de30eeeeb7cde00d071a80ecfa.tar.gz
src-0c188c06c627b5de30eeeeb7cde00d071a80ecfa.zip
arm64: replace pa_to_pvh() with page_to_pvh() in pmap_remove_l2()
Revise pmap_remove_l2() to use the constant-time function page_to_pvh() instead of the linear-time function pa_to_pvh(). Reviewed by: kib, markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D30876
-rw-r--r--sys/arm64/arm64/pmap.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c
index 7def96bca70b..bc3d4fd6446b 100644
--- a/sys/arm64/arm64/pmap.c
+++ b/sys/arm64/arm64/pmap.c
@@ -2834,8 +2834,7 @@ pmap_remove_l2(pmap_t pmap, pt_entry_t *l2, vm_offset_t sva,
{
struct md_page *pvh;
pt_entry_t old_l2;
- vm_offset_t eva, va;
- vm_page_t m, ml3;
+ vm_page_t m, ml3, mt;
PMAP_LOCK_ASSERT(pmap, MA_OWNED);
KASSERT((sva & L2_OFFSET) == 0, ("pmap_remove_l2: sva is not aligned"));
@@ -2853,19 +2852,18 @@ pmap_remove_l2(pmap_t pmap, pt_entry_t *l2, vm_offset_t sva,
pmap->pm_stats.wired_count -= L2_SIZE / PAGE_SIZE;
pmap_resident_count_dec(pmap, L2_SIZE / PAGE_SIZE);
if (old_l2 & ATTR_SW_MANAGED) {
+ m = PHYS_TO_VM_PAGE(old_l2 & ~ATTR_MASK);
+ pvh = page_to_pvh(m);
CHANGE_PV_LIST_LOCK_TO_PHYS(lockp, old_l2 & ~ATTR_MASK);
- pvh = pa_to_pvh(old_l2 & ~ATTR_MASK);
pmap_pvh_free(pvh, pmap, sva);
- eva = sva + L2_SIZE;
- for (va = sva, m = PHYS_TO_VM_PAGE(old_l2 & ~ATTR_MASK);
- va < eva; va += PAGE_SIZE, m++) {
+ for (mt = m; mt < &m[L2_SIZE / PAGE_SIZE]; mt++) {
if (pmap_pte_dirty(pmap, old_l2))
- vm_page_dirty(m);
+ vm_page_dirty(mt);
if (old_l2 & ATTR_AF)
- vm_page_aflag_set(m, PGA_REFERENCED);
- if (TAILQ_EMPTY(&m->md.pv_list) &&
+ vm_page_aflag_set(mt, PGA_REFERENCED);
+ if (TAILQ_EMPTY(&mt->md.pv_list) &&
TAILQ_EMPTY(&pvh->pv_list))
- vm_page_aflag_clear(m, PGA_WRITEABLE);
+ vm_page_aflag_clear(mt, PGA_WRITEABLE);
}
}
if (pmap == kernel_pmap) {