Date: Mon, 7 Jun 2004 22:21:42 GMT From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 54357 for review Message-ID: <200406072221.i57MLg6W045290@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=54357 Change 54357 by peter@peter_daintree on 2004/06/07 22:21:10 "Fix" the swap problem. This includes fixing the same problem in two other places. The pmap_remove() bug was replicated into pmap_protect() and pmap_copy(), although fortunately, it wouldn't have mattered much there (if at all). While here, rename a variable to a better name, and fix a #define POLA problem. Affected files ... .. //depot/projects/hammer/sys/amd64/amd64/pmap.c#73 edit .. //depot/projects/hammer/sys/amd64/include/param.h#17 edit Differences ... ==== //depot/projects/hammer/sys/amd64/amd64/pmap.c#73 (text+ko) ==== @@ -1562,7 +1562,9 @@ void pmap_remove(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) { - vm_offset_t pdnxt; + vm_offset_t va_next; + pml4_entry_t *pml4e; + pdp_entry_t *pdpe; pd_entry_t ptpaddr, *pde; pt_entry_t *pte; int anyvalid; @@ -1588,15 +1590,27 @@ anyvalid = 0; - for (; sva < eva; sva = pdnxt) { + for (; sva < eva; sva = va_next) { if (pmap->pm_stats.resident_count == 0) break; + pml4e = pmap_pml4e(pmap, sva); + if (pml4e == 0) { + va_next = (sva + NBPML4) & ~PML4MASK; + continue; + } + + pdpe = pmap_pdpe(pmap, sva); + if (pdpe == 0) { + va_next = (sva + NBPDP) & ~PDPMASK; + continue; + } + /* * Calculate index for next page table. */ - pdnxt = (sva + NBPDR) & ~PDRMASK; + va_next = (sva + NBPDR) & ~PDRMASK; pde = pmap_pde(pmap, sva); if (pde == 0) @@ -1625,10 +1639,10 @@ * by the current page table page, or to the end of the * range being removed. */ - if (pdnxt > eva) - pdnxt = eva; + if (va_next > eva) + va_next = eva; - for (; sva != pdnxt; sva += PAGE_SIZE) { + for (; sva != va_next; sva += PAGE_SIZE) { pte = pmap_pte(pmap, sva); if (pte == NULL || *pte == 0) continue; @@ -1714,7 +1728,9 @@ void pmap_protect(pmap_t pmap, vm_offset_t sva, vm_offset_t eva, vm_prot_t prot) { - vm_offset_t pdnxt; + vm_offset_t va_next; + pml4_entry_t *pml4e; + pdp_entry_t *pdpe; pd_entry_t ptpaddr, *pde; int anychanged; @@ -1731,9 +1747,21 @@ anychanged = 0; - for (; sva < eva; sva = pdnxt) { + for (; sva < eva; sva = va_next) { + + pml4e = pmap_pml4e(pmap, sva); + if (pml4e == 0) { + va_next = (sva + NBPML4) & ~PML4MASK; + continue; + } + + pdpe = pmap_pdpe(pmap, sva); + if (pdpe == 0) { + va_next = (sva + NBPDP) & ~PDPMASK; + continue; + } - pdnxt = (sva + NBPDR) & ~PDRMASK; + va_next = (sva + NBPDR) & ~PDRMASK; pde = pmap_pde(pmap, sva); if (pde == NULL) @@ -1757,10 +1785,10 @@ continue; } - if (pdnxt > eva) - pdnxt = eva; + if (va_next > eva) + va_next = eva; - for (; sva != pdnxt; sva += PAGE_SIZE) { + for (; sva != va_next; sva += PAGE_SIZE) { pt_entry_t pbits; pt_entry_t *pte; vm_page_t m; @@ -2194,7 +2222,7 @@ { vm_offset_t addr; vm_offset_t end_addr = src_addr + len; - vm_offset_t pdnxt; + vm_offset_t va_next; vm_page_t m; if (dst_addr != src_addr) @@ -2203,9 +2231,11 @@ if (!pmap_is_current(src_pmap)) return; - for (addr = src_addr; addr < end_addr; addr = pdnxt) { + for (addr = src_addr; addr < end_addr; addr = va_next) { pt_entry_t *src_pte, *dst_pte; vm_page_t dstmpte, srcmpte; + pml4_entry_t *pml4e; + pdp_entry_t *pdpe; pd_entry_t srcptepaddr, *pde; vm_pindex_t ptepindex; @@ -2221,7 +2251,19 @@ pv_entry_count > pv_entry_high_water) break; - pdnxt = (addr + NBPDR) & ~PDRMASK; + pml4e = pmap_pml4e(src_pmap, addr); + if (pml4e == 0) { + va_next = (addr + NBPML4) & ~PML4MASK; + continue; + } + + pdpe = pmap_pdpe(src_pmap, addr); + if (pdpe == 0) { + va_next = (addr + NBPDP) & ~PDPMASK; + continue; + } + + va_next = (addr + NBPDR) & ~PDRMASK; ptepindex = pmap_pde_pindex(addr); pde = pmap_pde(src_pmap, addr); @@ -2253,11 +2295,11 @@ if (srcmpte->hold_count == 0 || (srcmpte->flags & PG_BUSY)) continue; - if (pdnxt > end_addr) - pdnxt = end_addr; + if (va_next > end_addr) + va_next = end_addr; src_pte = vtopte(addr); - while (addr < pdnxt) { + while (addr < va_next) { pt_entry_t ptetemp; ptetemp = *src_pte; /* ==== //depot/projects/hammer/sys/amd64/include/param.h#17 (text+ko) ==== @@ -115,9 +115,9 @@ /* Size of the level 4 page-map level-4 table units */ #define NPML4EPG (PAGE_SIZE/(sizeof (pml4_entry_t))) #define NPML4EPGSHIFT 9 /* LOG2(NPML4EPG) */ -#define PML4SHIFT 39 /* LOG2(NBPML4T) */ -#define NBPML4T (1ul<<PML4SHIFT)/* bytes/page map lev4 table */ -#define PML4MASK (NBPML4T-1) +#define PML4SHIFT 39 /* LOG2(NBPML4) */ +#define NBPML4 (1ul<<PML4SHIFT)/* bytes/page map lev4 table */ +#define PML4MASK (NBPML4-1) #define IOPAGES 2 /* pages of i/o permission bitmap */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200406072221.i57MLg6W045290>