git: 3c4f46b0d57b - main - riscv: Port improvements from arm64/amd64 pmaps, part 2
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 02 Nov 2023 18:47:45 UTC
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=3c4f46b0d57b76d304f8a94862c6ba9be0273565 commit 3c4f46b0d57b76d304f8a94862c6ba9be0273565 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2023-11-02 18:33:55 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2023-11-02 18:33:55 +0000 riscv: Port improvements from arm64/amd64 pmaps, part 2 - Give pmap_promote_l2() a return value indicating whether or not promotion succeeded. - Check pmap_ps_enabled() in pmap_promote_l2() rather than making callers do it. - Annotate superpages_enabled with __read_frequently. Reviewed by: kib MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D42289 --- sys/riscv/riscv/pmap.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c index 30bcf113628c..9b2866d7dd4d 100644 --- a/sys/riscv/riscv/pmap.c +++ b/sys/riscv/riscv/pmap.c @@ -256,7 +256,7 @@ CTASSERT(VM_EARLY_DTB_ADDRESS < (VM_MAX_KERNEL_ADDRESS - PMAP_MAPDEV_EARLY_SIZE) static struct rwlock_padalign pvh_global_lock; static struct mtx_padalign allpmaps_lock; -static int superpages_enabled = 1; +static int __read_frequently superpages_enabled = 1; SYSCTL_INT(_vm_pmap, OID_AUTO, superpages_enabled, CTLFLAG_RDTUN, &superpages_enabled, 0, "Enable support for transparent superpages"); @@ -2759,7 +2759,7 @@ pmap_demote_l2_locked(pmap_t pmap, pd_entry_t *l2, vm_offset_t va, } #if VM_NRESERVLEVEL > 0 -static void +static bool pmap_promote_l2(pmap_t pmap, pd_entry_t *l2, vm_offset_t va, vm_page_t ml3, struct rwlock **lockp) { @@ -2767,6 +2767,8 @@ pmap_promote_l2(pmap_t pmap, pd_entry_t *l2, vm_offset_t va, vm_page_t ml3, vm_paddr_t pa; PMAP_LOCK_ASSERT(pmap, MA_OWNED); + if (!pmap_ps_enabled(pmap)) + return (false); KASSERT((pmap_load(l2) & PTE_RWX) == 0, ("pmap_promote_l2: invalid l2 entry %p", l2)); @@ -2783,7 +2785,7 @@ pmap_promote_l2(pmap_t pmap, pd_entry_t *l2, vm_offset_t va, vm_page_t ml3, CTR2(KTR_PMAP, "pmap_promote_l2: failure for va %#lx pmap %p", va, pmap); atomic_add_long(&pmap_l2_p_failures, 1); - return; + return (false); } /* @@ -2817,7 +2819,7 @@ pmap_promote_l2(pmap_t pmap, pd_entry_t *l2, vm_offset_t va, vm_page_t ml3, "pmap_promote_l2: failure for va %#lx pmap %p", va, pmap); atomic_add_long(&pmap_l2_p_failures, 1); - return; + return (false); } while ((l3e & (PTE_W | PTE_D)) == PTE_W) { if (atomic_fcmpset_64(l3, &l3e, l3e & ~PTE_W)) { @@ -2830,7 +2832,7 @@ pmap_promote_l2(pmap_t pmap, pd_entry_t *l2, vm_offset_t va, vm_page_t ml3, "pmap_promote_l2: failure for va %#lx pmap %p", va, pmap); atomic_add_long(&pmap_l2_p_failures, 1); - return; + return (false); } all_l3e_PTE_A &= l3e; pa -= PAGE_SIZE; @@ -2857,7 +2859,7 @@ pmap_promote_l2(pmap_t pmap, pd_entry_t *l2, vm_offset_t va, vm_page_t ml3, CTR2(KTR_PMAP, "pmap_promote_l2: failure for va %#lx pmap %p", va, pmap); atomic_add_long(&pmap_l2_p_failures, 1); - return; + return (false); } if ((firstl3e & PTE_SW_MANAGED) != 0) @@ -2868,6 +2870,7 @@ pmap_promote_l2(pmap_t pmap, pd_entry_t *l2, vm_offset_t va, vm_page_t ml3, atomic_add_long(&pmap_l2_promotions, 1); CTR2(KTR_PMAP, "pmap_promote_l2: success for va %#lx in pmap %p", va, pmap); + return (true); } #endif @@ -3133,10 +3136,9 @@ validate: #if VM_NRESERVLEVEL > 0 if (mpte != NULL && mpte->ref_count == Ln_ENTRIES && - pmap_ps_enabled(pmap) && (m->flags & PG_FICTITIOUS) == 0 && vm_reserv_level_iffullpop(m) == 0) - pmap_promote_l2(pmap, l2, va, mpte, &lock); + (void)pmap_promote_l2(pmap, l2, va, mpte, &lock); #endif rv = KERN_SUCCESS;