From owner-svn-src-stable@FreeBSD.ORG Sun Mar 22 20:46:39 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BF6EB1065673; Sun, 22 Mar 2009 20:46:39 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AC3D18FC14; Sun, 22 Mar 2009 20:46:39 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2MKkc6T082805; Sun, 22 Mar 2009 20:46:38 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2MKkcUu082801; Sun, 22 Mar 2009 20:46:38 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <200903222046.n2MKkcUu082801@svn.freebsd.org> From: Alan Cox Date: Sun, 22 Mar 2009 20:46:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r190275 - in stable/7/sys: amd64/amd64 amd64/include i386/i386 i386/include X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Mar 2009 20:46:40 -0000 Author: alc Date: Sun Mar 22 20:46:37 2009 New Revision: 190275 URL: http://svn.freebsd.org/changeset/base/190275 Log: MFC r188932, r189785, r189795, and r190272 Optimize free_pv_entry(); specifically, avoid repeated TAILQ_REMOVE()s. Update the pmap's resident page count when a page table page is freed in pmap_remove_pde() and pmap_remove_pages(). Update stale comments. The alternate address space mapping was eliminated when PAE support was added to i386. The direct mapping exists on amd64. Modified: stable/7/sys/amd64/amd64/pmap.c stable/7/sys/amd64/include/pmap.h stable/7/sys/i386/i386/pmap.c stable/7/sys/i386/include/pmap.h Modified: stable/7/sys/amd64/amd64/pmap.c ============================================================================== --- stable/7/sys/amd64/amd64/pmap.c Sun Mar 22 20:36:37 2009 (r190274) +++ stable/7/sys/amd64/amd64/pmap.c Sun Mar 22 20:46:37 2009 (r190275) @@ -1905,15 +1905,15 @@ free_pv_entry(pmap_t pmap, pv_entry_t pv pc->pc_map[field] |= 1ul << bit; /* move to head of list */ TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list); - TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list); if (pc->pc_map[0] != PC_FREE0 || pc->pc_map[1] != PC_FREE1 || - pc->pc_map[2] != PC_FREE2) + pc->pc_map[2] != PC_FREE2) { + TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list); return; + } PV_STAT(pv_entry_spare -= _NPCPV); PV_STAT(pc_chunk_count--); PV_STAT(pc_chunk_frees++); /* entire chunk is free, return it */ - TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list); m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)pc)); dump_drop_page(m->phys_addr); vm_page_unwire(m, 0); @@ -2325,6 +2325,7 @@ pmap_remove_pde(pmap_t pmap, pd_entry_t mpte = pmap_lookup_pt_page(pmap, sva); if (mpte != NULL) { pmap_remove_pt_page(pmap, mpte); + pmap->pm_stats.resident_count--; KASSERT(mpte->wire_count == NPTEPG, ("pmap_remove_pde: pte page wire count error")); mpte->wire_count = 0; @@ -3797,6 +3798,7 @@ pmap_remove_pages(pmap_t pmap) mpte = pmap_lookup_pt_page(pmap, pv->pv_va); if (mpte != NULL) { pmap_remove_pt_page(pmap, mpte); + pmap->pm_stats.resident_count--; KASSERT(mpte->wire_count == NPTEPG, ("pmap_remove_pages: pte page wire count error")); mpte->wire_count = 0; Modified: stable/7/sys/amd64/include/pmap.h ============================================================================== --- stable/7/sys/amd64/include/pmap.h Sun Mar 22 20:36:37 2009 (r190274) +++ stable/7/sys/amd64/include/pmap.h Sun Mar 22 20:46:37 2009 (r190275) @@ -156,13 +156,7 @@ typedef u_int64_t pml4_entry_t; #define PDESHIFT (3) /* - * Address of current and alternate address space page table maps - * and directories. - * XXX it might be saner to just direct map all of physical memory - * into the kernel using 2MB pages. We have enough space to do - * it (2^47 bits of KVM, while current max physical addressability - * is 2^40 physical bits). Then we can get rid of the evil hole - * in the page tables and the evil overlapping. + * Address of current address space page table maps and directories. */ #ifdef _KERNEL #define addr_PTmap (KVADDR(PML4PML4I, 0, 0, 0)) Modified: stable/7/sys/i386/i386/pmap.c ============================================================================== --- stable/7/sys/i386/i386/pmap.c Sun Mar 22 20:36:37 2009 (r190274) +++ stable/7/sys/i386/i386/pmap.c Sun Mar 22 20:46:37 2009 (r190275) @@ -1973,15 +1973,15 @@ free_pv_entry(pmap_t pmap, pv_entry_t pv pc->pc_map[field] |= 1ul << bit; /* move to head of list */ TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list); - TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list); for (idx = 0; idx < _NPCM; idx++) - if (pc->pc_map[idx] != pc_freemask[idx]) + if (pc->pc_map[idx] != pc_freemask[idx]) { + TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list); return; + } PV_STAT(pv_entry_spare -= _NPCPV); PV_STAT(pc_chunk_count--); PV_STAT(pc_chunk_frees++); /* entire chunk is free, return it */ - TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list); m = PHYS_TO_VM_PAGE(pmap_kextract((vm_offset_t)pc)); pmap_qremove((vm_offset_t)pc, 1); vm_page_unwire(m, 0); @@ -2431,6 +2431,7 @@ pmap_remove_pde(pmap_t pmap, pd_entry_t mpte = pmap_lookup_pt_page(pmap, sva); if (mpte != NULL) { pmap_remove_pt_page(pmap, mpte); + pmap->pm_stats.resident_count--; KASSERT(mpte->wire_count == NPTEPG, ("pmap_remove_pde: pte page wire count error")); mpte->wire_count = 0; @@ -3935,6 +3936,7 @@ pmap_remove_pages(pmap_t pmap) mpte = pmap_lookup_pt_page(pmap, pv->pv_va); if (mpte != NULL) { pmap_remove_pt_page(pmap, mpte); + pmap->pm_stats.resident_count--; KASSERT(mpte->wire_count == NPTEPG, ("pmap_remove_pages: pte page wire count error")); mpte->wire_count = 0; Modified: stable/7/sys/i386/include/pmap.h ============================================================================== --- stable/7/sys/i386/include/pmap.h Sun Mar 22 20:36:37 2009 (r190274) +++ stable/7/sys/i386/include/pmap.h Sun Mar 22 20:46:37 2009 (r190275) @@ -174,8 +174,7 @@ typedef uint32_t pt_entry_t; #endif /* - * Address of current and alternate address space page table maps - * and directories. + * Address of current address space page table maps and directories. */ #ifdef _KERNEL extern pt_entry_t PTmap[];