Module Name: src Committed By: skrll Date: Sun Sep 25 06:21:58 UTC 2022
Modified Files: src/sys/arch/mips/mips: pmap_machdep.c src/sys/arch/powerpc/booke: booke_pmap.c trap.c src/sys/uvm/pmap: pmap_segtab.c Log Message: Rename pmap_segtab_t *stp to stb for consistency with a future pmap_pdetab_t *ptb. pmap_pdetab_t *ptp would be far too confusing. NFC. Same code before and after. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/arch/mips/mips/pmap_machdep.c cvs rdiff -u -r1.34 -r1.35 src/sys/arch/powerpc/booke/booke_pmap.c cvs rdiff -u -r1.37 -r1.38 src/sys/arch/powerpc/booke/trap.c cvs rdiff -u -r1.27 -r1.28 src/sys/uvm/pmap/pmap_segtab.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/mips/mips/pmap_machdep.c diff -u src/sys/arch/mips/mips/pmap_machdep.c:1.36 src/sys/arch/mips/mips/pmap_machdep.c:1.37 --- src/sys/arch/mips/mips/pmap_machdep.c:1.36 Sat Oct 2 14:28:04 2021 +++ src/sys/arch/mips/mips/pmap_machdep.c Sun Sep 25 06:21:58 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_machdep.c,v 1.36 2021/10/02 14:28:04 skrll Exp $ */ +/* $NetBSD: pmap_machdep.c,v 1.37 2022/09/25 06:21:58 skrll Exp $ */ /*- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap_machdep.c,v 1.36 2021/10/02 14:28:04 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap_machdep.c,v 1.37 2022/09/25 06:21:58 skrll Exp $"); /* * Manages physical address maps. @@ -444,23 +444,23 @@ pmap_bootstrap(void) if (xsegs > 1) { printf("%s: %zu xsegs required for %zu pages\n", __func__, xsegs, sysmap_size); - pmap_segtab_t *stp = (pmap_segtab_t *) + pmap_segtab_t *stb = (pmap_segtab_t *) uvm_pageboot_alloc(sizeof(pmap_segtab_t) * (xsegs - 1)); - for (size_t i = 1; i <= xsegs; i++, stp++) { - pmap_kern_segtab.seg_seg[i] = stp; + for (size_t i = 1; i <= xsegs; i++, stb++) { + pmap_kern_segtab.seg_seg[i] = stb; } } - pmap_segtab_t ** const xstp = pmap_kern_segtab.seg_seg; + pmap_segtab_t ** const xstb = pmap_kern_segtab.seg_seg; #else const size_t xsegs = 1; - pmap_segtab_t * const stp = &pmap_kern_segtab; + pmap_segtab_t * const stb = &pmap_kern_segtab; #endif KASSERT(curcpu()->ci_pmap_kern_segtab == &pmap_kern_segtab); for (size_t k = 0, i = 0; k < xsegs; k++) { #ifdef _LP64 - pmap_segtab_t * const stp = - xstp[(va >> XSEGSHIFT) & (NSEGPG - 1)]; + pmap_segtab_t * const stb = + xstb[(va >> XSEGSHIFT) & (NSEGPG - 1)]; #endif bool done = false; @@ -470,7 +470,7 @@ pmap_bootstrap(void) /* * Now set the page table pointer... */ - stp->seg_tab[j] = &sysmap[i]; + stb->seg_tab[j] = &sysmap[i]; #ifdef _LP64 /* * If we are at end of this XSEG, terminate the loop Index: src/sys/arch/powerpc/booke/booke_pmap.c diff -u src/sys/arch/powerpc/booke/booke_pmap.c:1.34 src/sys/arch/powerpc/booke/booke_pmap.c:1.35 --- src/sys/arch/powerpc/booke/booke_pmap.c:1.34 Sat Oct 2 14:28:04 2021 +++ src/sys/arch/powerpc/booke/booke_pmap.c Sun Sep 25 06:21:58 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: booke_pmap.c,v 1.34 2021/10/02 14:28:04 skrll Exp $ */ +/* $NetBSD: booke_pmap.c,v 1.35 2022/09/25 06:21:58 skrll Exp $ */ /*- * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. * All rights reserved. @@ -37,7 +37,7 @@ #define __PMAP_PRIVATE #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: booke_pmap.c,v 1.34 2021/10/02 14:28:04 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: booke_pmap.c,v 1.35 2022/09/25 06:21:58 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_multiprocessor.h" @@ -125,9 +125,9 @@ pmap_md_direct_mapped_vaddr_to_paddr(vad #ifdef PMAP_MINIMALTLB static pt_entry_t * -kvtopte(const pmap_segtab_t *stp, vaddr_t va) +kvtopte(const pmap_segtab_t *stb, vaddr_t va) { - pt_entry_t * const ptep = stp->seg_tab[va >> SEGSHIFT]; + pt_entry_t * const ptep = stb->seg_tab[va >> SEGSHIFT]; if (ptep == NULL) return NULL; return &ptep[(va & SEGOFSET) >> PAGE_SHIFT]; @@ -136,9 +136,9 @@ kvtopte(const pmap_segtab_t *stp, vaddr_ vaddr_t pmap_kvptefill(vaddr_t sva, vaddr_t eva, pt_entry_t pt_entry) { - pmap_segtab_t * const stp = &pmap_kern_segtab; + pmap_segtab_t * const stb = &pmap_kern_segtab; KASSERT(sva == trunc_page(sva)); - pt_entry_t *ptep = kvtopte(stp, sva); + pt_entry_t *ptep = kvtopte(stb, sva); for (; sva < eva; sva += NBPG) { *ptep++ = pt_entry ? (sva | pt_entry) : 0; } Index: src/sys/arch/powerpc/booke/trap.c diff -u src/sys/arch/powerpc/booke/trap.c:1.37 src/sys/arch/powerpc/booke/trap.c:1.38 --- src/sys/arch/powerpc/booke/trap.c:1.37 Sat Mar 6 08:08:19 2021 +++ src/sys/arch/powerpc/booke/trap.c Sun Sep 25 06:21:58 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.37 2021/03/06 08:08:19 rin Exp $ */ +/* $NetBSD: trap.c,v 1.38 2022/09/25 06:21:58 skrll Exp $ */ /*- * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. * All rights reserved. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.37 2021/03/06 08:08:19 rin Exp $"); +__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.38 2022/09/25 06:21:58 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_altivec.h" @@ -144,11 +144,11 @@ get_faultmap(const struct trapframe * co static inline pt_entry_t * trap_pte_lookup(struct trapframe *tf, vaddr_t va, register_t psl_mask) { - pmap_segtab_t ** const stps = &curcpu()->ci_pmap_kern_segtab; - pmap_segtab_t * const stp = stps[(tf->tf_srr1 / psl_mask) & 1]; - if (__predict_false(stp == NULL)) + pmap_segtab_t ** const stbs = &curcpu()->ci_pmap_kern_segtab; + pmap_segtab_t * const stb = stbs[(tf->tf_srr1 / psl_mask) & 1]; + if (__predict_false(stb == NULL)) return NULL; - pt_entry_t * const ptep = stp->seg_tab[va >> SEGSHIFT]; + pt_entry_t * const ptep = stb->seg_tab[va >> SEGSHIFT]; if (__predict_false(ptep == NULL)) return NULL; return ptep + ((va & SEGOFSET) >> PAGE_SHIFT); Index: src/sys/uvm/pmap/pmap_segtab.c diff -u src/sys/uvm/pmap/pmap_segtab.c:1.27 src/sys/uvm/pmap/pmap_segtab.c:1.28 --- src/sys/uvm/pmap/pmap_segtab.c:1.27 Sat Mar 13 15:29:55 2021 +++ src/sys/uvm/pmap/pmap_segtab.c Sun Sep 25 06:21:58 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_segtab.c,v 1.27 2021/03/13 15:29:55 skrll Exp $ */ +/* $NetBSD: pmap_segtab.c,v 1.28 2022/09/25 06:21:58 skrll Exp $ */ /*- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap_segtab.c,v 1.27 2021/03/13 15:29:55 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap_segtab.c,v 1.28 2022/09/25 06:21:58 skrll Exp $"); /* * Manages physical address maps. @@ -134,7 +134,7 @@ kmutex_t pmap_segtab_lock __cacheline_al /* * Check that a seg_tab[] array is empty. * - * This is used when allocating or freeing a pmap_segtab_t. The stp + * This is used when allocating or freeing a pmap_segtab_t. The stb * should be unused -- meaning, none of the seg_tab[] pointers are * not NULL, as it transitions from either freshly allocated segtab from * pmap pool, an unused allocated page segtab alloc from the SMP case, @@ -143,23 +143,23 @@ kmutex_t pmap_segtab_lock __cacheline_al * also frees a freshly allocated but unused entry. */ static void -pmap_check_stp(pmap_segtab_t *stp, const char *caller, const char *why) +pmap_check_stb(pmap_segtab_t *stb, const char *caller, const char *why) { #ifdef DEBUG for (size_t i = 0; i < PMAP_SEGTABSIZE; i++) { - if (stp->seg_tab[i] != NULL) { + if (stb->seg_tab[i] != NULL) { #define DEBUG_NOISY #ifdef DEBUG_NOISY UVMHIST_FUNC(__func__); - UVMHIST_CALLARGS(pmapsegtabhist, "stp=%#jx", - (uintptr_t)stp, 0, 0, 0); + UVMHIST_CALLARGS(pmapsegtabhist, "stb=%#jx", + (uintptr_t)stb, 0, 0, 0); for (size_t j = i; j < PMAP_SEGTABSIZE; j++) - if (stp->seg_tab[j] != NULL) - printf("%s: stp->seg_tab[%zu] = %p\n", - caller, j, stp->seg_tab[j]); + if (stb->seg_tab[j] != NULL) + printf("%s: stb->seg_tab[%zu] = %p\n", + caller, j, stb->seg_tab[j]); #endif panic("%s: pm_segtab.seg_tab[%zu] != 0 (%p): %s", - caller, i, stp->seg_tab[i], why); + caller, i, stb->seg_tab[i], why); } } #endif @@ -216,16 +216,16 @@ pmap_pte_pagealloc(void) static inline pt_entry_t * pmap_segmap(struct pmap *pmap, vaddr_t va) { - pmap_segtab_t *stp = pmap->pm_segtab; + pmap_segtab_t *stb = pmap->pm_segtab; KASSERTMSG(pmap != pmap_kernel() || !pmap_md_direct_mapped_vaddr_p(va), "pmap %p va %#" PRIxVADDR, pmap, va); #ifdef _LP64 - stp = stp->seg_seg[(va >> XSEGSHIFT) & (NSEGPG - 1)]; - if (stp == NULL) + stb = stb->seg_seg[(va >> XSEGSHIFT) & (NSEGPG - 1)]; + if (stb == NULL) return NULL; #endif - return stp->seg_tab[(va >> SEGSHIFT) & (PMAP_SEGTABSIZE - 1)]; + return stb->seg_tab[(va >> SEGSHIFT) & (PMAP_SEGTABSIZE - 1)]; } pt_entry_t * @@ -242,29 +242,29 @@ pmap_pte_lookup(pmap_t pmap, vaddr_t va) * Insert the segtab into the segtab freelist. */ static void -pmap_segtab_free(pmap_segtab_t *stp) +pmap_segtab_free(pmap_segtab_t *stb) { UVMHIST_FUNC(__func__); - UVMHIST_CALLARGS(pmapsegtabhist, "stp=%#jx", (uintptr_t)stp, 0, 0, 0); + UVMHIST_CALLARGS(pmapsegtabhist, "stb=%#jx", (uintptr_t)stb, 0, 0, 0); mutex_spin_enter(&pmap_segtab_lock); - stp->seg_seg[0] = pmap_segtab_info.free_segtab; - pmap_segtab_info.free_segtab = stp; + stb->seg_seg[0] = pmap_segtab_info.free_segtab; + pmap_segtab_info.free_segtab = stb; SEGTAB_ADD(nput, 1); mutex_spin_exit(&pmap_segtab_lock); } static void -pmap_segtab_release(pmap_t pmap, pmap_segtab_t **stp_p, bool free_stp, +pmap_segtab_release(pmap_t pmap, pmap_segtab_t **stb_p, bool free_stb, pte_callback_t callback, uintptr_t flags, vaddr_t va, vsize_t vinc) { - pmap_segtab_t *stp = *stp_p; + pmap_segtab_t *stb = *stb_p; UVMHIST_FUNC(__func__); - UVMHIST_CALLARGS(pmapsegtabhist, "pm=%#jx stpp=%#jx free=%jd", - (uintptr_t)pmap, (uintptr_t)stp_p, free_stp, 0); + UVMHIST_CALLARGS(pmapsegtabhist, "pm=%#jx stb_p=%#jx free=%jd", + (uintptr_t)pmap, (uintptr_t)stb_p, free_stb, 0); UVMHIST_LOG(pmapsegtabhist, " callback=%#jx flags=%#jx va=%#jx vinc=%#jx", (uintptr_t)callback, flags, (uintptr_t)va, (uintptr_t)vinc); for (size_t i = (va / vinc) & (PMAP_SEGTABSIZE - 1); @@ -272,12 +272,12 @@ pmap_segtab_release(pmap_t pmap, pmap_se i++, va += vinc) { #ifdef _LP64 if (vinc > NBSEG) { - if (stp->seg_seg[i] != NULL) { + if (stb->seg_seg[i] != NULL) { UVMHIST_LOG(pmapsegtabhist, " recursing %jd", i, 0, 0, 0); - pmap_segtab_release(pmap, &stp->seg_seg[i], + pmap_segtab_release(pmap, &stb->seg_seg[i], true, callback, flags, va, vinc / NSEGPG); - KASSERT(stp->seg_seg[i] == NULL); + KASSERT(stb->seg_seg[i] == NULL); } continue; } @@ -285,7 +285,7 @@ pmap_segtab_release(pmap_t pmap, pmap_se KASSERT(vinc == NBSEG); /* get pointer to segment map */ - pt_entry_t *pte = stp->seg_tab[i]; + pt_entry_t *pte = stb->seg_tab[i]; if (pte == NULL) continue; pmap_check_ptes(pte, __func__); @@ -308,15 +308,15 @@ pmap_segtab_release(pmap_t pmap, pmap_se uvm_pagefree(pg); #endif - stp->seg_tab[i] = NULL; + stb->seg_tab[i] = NULL; UVMHIST_LOG(pmapsegtabhist, " zeroing tab[%jd]", i, 0, 0, 0); } - if (free_stp) { - pmap_check_stp(stp, __func__, + if (free_stb) { + pmap_check_stb(stb, __func__, vinc == NBSEG ? "release seg" : "release xseg"); - pmap_segtab_free(stp); - *stp_p = NULL; + pmap_segtab_free(stb); + *stb_p = NULL; } } @@ -335,26 +335,26 @@ pmap_segtab_release(pmap_t pmap, pmap_se static pmap_segtab_t * pmap_segtab_alloc(void) { - pmap_segtab_t *stp; + pmap_segtab_t *stb; bool found_on_freelist = false; UVMHIST_FUNC(__func__); again: mutex_spin_enter(&pmap_segtab_lock); - if (__predict_true((stp = pmap_segtab_info.free_segtab) != NULL)) { - pmap_segtab_info.free_segtab = stp->seg_seg[0]; - stp->seg_seg[0] = NULL; + if (__predict_true((stb = pmap_segtab_info.free_segtab) != NULL)) { + pmap_segtab_info.free_segtab = stb->seg_seg[0]; + stb->seg_seg[0] = NULL; SEGTAB_ADD(nget, 1); found_on_freelist = true; - UVMHIST_CALLARGS(pmapsegtabhist, "freelist stp=%#jx", - (uintptr_t)stp, 0, 0, 0); + UVMHIST_CALLARGS(pmapsegtabhist, "freelist stb=%#jx", + (uintptr_t)stb, 0, 0, 0); } mutex_spin_exit(&pmap_segtab_lock); - if (__predict_false(stp == NULL)) { - struct vm_page * const stp_pg = pmap_pte_pagealloc(); + if (__predict_false(stb == NULL)) { + struct vm_page * const stb_pg = pmap_pte_pagealloc(); - if (__predict_false(stp_pg == NULL)) { + if (__predict_false(stb_pg == NULL)) { /* * XXX What else can we do? Could we deadlock here? */ @@ -362,34 +362,34 @@ pmap_segtab_alloc(void) goto again; } SEGTAB_ADD(npage, 1); - const paddr_t stp_pa = VM_PAGE_TO_PHYS(stp_pg); + const paddr_t stb_pa = VM_PAGE_TO_PHYS(stb_pg); - stp = (pmap_segtab_t *)PMAP_MAP_POOLPAGE(stp_pa); - UVMHIST_CALLARGS(pmapsegtabhist, "new stp=%#jx", - (uintptr_t)stp, 0, 0, 0); - const size_t n = NBPG / sizeof(*stp); + stb = (pmap_segtab_t *)PMAP_MAP_POOLPAGE(stb_pa); + UVMHIST_CALLARGS(pmapsegtabhist, "new stb=%#jx", + (uintptr_t)stb, 0, 0, 0); + const size_t n = NBPG / sizeof(*stb); if (n > 1) { /* * link all the segtabs in this page together */ for (size_t i = 1; i < n - 1; i++) { - stp[i].seg_seg[0] = &stp[i+1]; + stb[i].seg_seg[0] = &stb[i+1]; } /* * Now link the new segtabs into the free segtab list. */ mutex_spin_enter(&pmap_segtab_lock); - stp[n-1].seg_seg[0] = pmap_segtab_info.free_segtab; - pmap_segtab_info.free_segtab = stp + 1; + stb[n-1].seg_seg[0] = pmap_segtab_info.free_segtab; + pmap_segtab_info.free_segtab = stb + 1; SEGTAB_ADD(nput, n - 1); mutex_spin_exit(&pmap_segtab_lock); } } - pmap_check_stp(stp, __func__, + pmap_check_stb(stb, __func__, found_on_freelist ? "from free list" : "allocated"); - return stp; + return stb; } /* @@ -505,30 +505,30 @@ pmap_pte_process(pmap_t pmap, vaddr_t sv pt_entry_t * pmap_pte_reserve(pmap_t pmap, vaddr_t va, int flags) { - pmap_segtab_t *stp = pmap->pm_segtab; + pmap_segtab_t *stb = pmap->pm_segtab; pt_entry_t *pte; UVMHIST_FUNC(__func__); pte = pmap_pte_lookup(pmap, va); if (__predict_false(pte == NULL)) { #ifdef _LP64 - pmap_segtab_t ** const stp_p = - &stp->seg_seg[(va >> XSEGSHIFT) & (NSEGPG - 1)]; - if (__predict_false((stp = *stp_p) == NULL)) { - pmap_segtab_t *nstp = pmap_segtab_alloc(); + pmap_segtab_t ** const stb_p = + &stb->seg_seg[(va >> XSEGSHIFT) & (NSEGPG - 1)]; + if (__predict_false((stb = *stb_p) == NULL)) { + pmap_segtab_t *nstb = pmap_segtab_alloc(); #ifdef MULTIPROCESSOR - pmap_segtab_t *ostp = atomic_cas_ptr(stp_p, NULL, nstp); - if (__predict_false(ostp != NULL)) { - pmap_check_stp(nstp, __func__, "reserve"); - pmap_segtab_free(nstp); - nstp = ostp; + pmap_segtab_t *ostb = atomic_cas_ptr(stb_p, NULL, nstb); + if (__predict_false(ostb != NULL)) { + pmap_check_stb(nstb, __func__, "reserve"); + pmap_segtab_free(nstb); + nstb = ostb; } #else - *stp_p = nstp; + *stb_p = nstb; #endif /* MULTIPROCESSOR */ - stp = nstp; + stb = nstb; } - KASSERT(stp == pmap->pm_segtab->seg_seg[(va >> XSEGSHIFT) & (NSEGPG - 1)]); + KASSERT(stb == pmap->pm_segtab->seg_seg[(va >> XSEGSHIFT) & (NSEGPG - 1)]); #endif /* _LP64 */ struct vm_page *pg = NULL; #ifdef PMAP_PTP_CACHE @@ -551,7 +551,7 @@ pmap_pte_reserve(pmap_t pmap, vaddr_t va const paddr_t pa = VM_PAGE_TO_PHYS(pg); pte = (pt_entry_t *)PMAP_MAP_POOLPAGE(pa); pt_entry_t ** const pte_p = - &stp->seg_tab[(va >> SEGSHIFT) & (PMAP_SEGTABSIZE - 1)]; + &stb->seg_tab[(va >> SEGSHIFT) & (PMAP_SEGTABSIZE - 1)]; #ifdef MULTIPROCESSOR pt_entry_t *opte = atomic_cas_ptr(pte_p, NULL, pte); /* @@ -573,7 +573,7 @@ pmap_pte_reserve(pmap_t pmap, vaddr_t va #else *pte_p = pte; #endif - KASSERT(pte == stp->seg_tab[(va >> SEGSHIFT) & (PMAP_SEGTABSIZE - 1)]); + KASSERT(pte == stb->seg_tab[(va >> SEGSHIFT) & (PMAP_SEGTABSIZE - 1)]); UVMHIST_CALLARGS(pmapsegtabhist, "pm=%#jx va=%#jx -> tab[%jd]=%#jx", (uintptr_t)pmap, (uintptr_t)va, (va >> SEGSHIFT) & (PMAP_SEGTABSIZE - 1), (uintptr_t)pte);