git: e7c544216282 - main - amd64: micro-optimize vptopte()/vtopde() further
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 02 Feb 2022 10:39:36 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e7c54421628231650d61edd90b271e6b5e322e36 commit e7c54421628231650d61edd90b271e6b5e322e36 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2022-01-08 05:09:09 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2022-02-02 09:40:04 +0000 amd64: micro-optimize vptopte()/vtopde() further Eliminate shlq $3,address shift after masking of the va is done, which is needed to convert pt_entry_t[] array index into byte offset. Do it by preshifting the mask, and compensating the right shift of va. Suggested by: alc Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D33786 --- sys/amd64/amd64/pmap.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 5f72ff3acf08..dafb6acb5c60 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -1516,28 +1516,28 @@ pmap_pt_page_count_adj(pmap_t pmap, int count) } } -pt_entry_t vtoptem __read_mostly = (1ul << (NPTEPGSHIFT + NPDEPGSHIFT + - NPDPEPGSHIFT + NPML4EPGSHIFT)) - 1; -pt_entry_t *PTmap __read_mostly = P4Tmap; +pt_entry_t vtoptem __read_mostly = ((1ul << (NPTEPGSHIFT + NPDEPGSHIFT + + NPDPEPGSHIFT + NPML4EPGSHIFT)) - 1) << 3; +vm_offset_t PTmap __read_mostly = (vm_offset_t)P4Tmap; PMAP_INLINE pt_entry_t * vtopte(vm_offset_t va) { KASSERT(va >= VM_MAXUSER_ADDRESS, ("vtopte on a uva/gpa 0x%0lx", va)); - return (PTmap + ((va >> PAGE_SHIFT) & vtoptem)); + return ((pt_entry_t *)(PTmap + ((va >> (PAGE_SHIFT - 3)) & vtoptem))); } -pd_entry_t vtopdem __read_mostly = (1ul << (NPDEPGSHIFT + NPDPEPGSHIFT + - NPML4EPGSHIFT)) - 1; -pd_entry_t *PDmap __read_mostly = P4Dmap; +pd_entry_t vtopdem __read_mostly = ((1ul << (NPDEPGSHIFT + NPDPEPGSHIFT + + NPML4EPGSHIFT)) - 1) << 3; +vm_offset_t PDmap __read_mostly = (vm_offset_t)P4Dmap; static __inline pd_entry_t * vtopde(vm_offset_t va) { KASSERT(va >= VM_MAXUSER_ADDRESS, ("vtopde on a uva/gpa 0x%0lx", va)); - return (PDmap + ((va >> PDRSHIFT) & vtopdem)); + return ((pt_entry_t *)(PDmap + ((va >> (PDRSHIFT - 3)) & vtopdem))); } static u_int64_t @@ -2229,12 +2229,12 @@ pmap_bootstrap_la57(void *arg __unused) */ v_pml5[PML5PML5I] = KPML5phys | X86_PG_RW | X86_PG_V | pg_nx; - vtoptem = (1ul << (NPTEPGSHIFT + NPDEPGSHIFT + NPDPEPGSHIFT + - NPML4EPGSHIFT + NPML5EPGSHIFT)) - 1; - PTmap = P5Tmap; - vtopdem = (1ul << (NPDEPGSHIFT + NPDPEPGSHIFT + - NPML4EPGSHIFT + NPML5EPGSHIFT)) - 1; - PDmap = P5Dmap; + vtoptem = ((1ul << (NPTEPGSHIFT + NPDEPGSHIFT + NPDPEPGSHIFT + + NPML4EPGSHIFT + NPML5EPGSHIFT)) - 1) << 3; + PTmap = (vm_offset_t)P5Tmap; + vtopdem = ((1ul << (NPDEPGSHIFT + NPDPEPGSHIFT + + NPML4EPGSHIFT + NPML5EPGSHIFT)) - 1) << 3; + PDmap = (vm_offset_t)P5Dmap; kernel_pmap->pm_cr3 = KPML5phys; kernel_pmap->pm_pmltop = v_pml5;