From owner-svn-src-all@FreeBSD.ORG Fri Jun 1 04:26:50 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CB984106566B; Fri, 1 Jun 2012 04:26:50 +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 ABD528FC15; Fri, 1 Jun 2012 04:26:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q514Qour083217; Fri, 1 Jun 2012 04:26:50 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q514Qo0w083212; Fri, 1 Jun 2012 04:26:50 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201206010426.q514Qo0w083212@svn.freebsd.org> From: Alan Cox Date: Fri, 1 Jun 2012 04:26:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236378 - in head/sys: amd64/amd64 i386/i386 i386/xen X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Jun 2012 04:26:50 -0000 Author: alc Date: Fri Jun 1 04:26:50 2012 New Revision: 236378 URL: http://svn.freebsd.org/changeset/base/236378 Log: Eliminate code duplication in free_pv_entry() and pmap_remove_pages() by introducing free_pv_chunk(). Modified: head/sys/amd64/amd64/pmap.c head/sys/i386/i386/pmap.c head/sys/i386/xen/pmap.c Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Fri Jun 1 04:23:20 2012 (r236377) +++ head/sys/amd64/amd64/pmap.c Fri Jun 1 04:26:50 2012 (r236378) @@ -218,6 +218,7 @@ caddr_t CADDR1 = 0; */ static caddr_t crashdumpmap; +static void free_pv_chunk(struct pv_chunk *pc); static void free_pv_entry(pmap_t pmap, pv_entry_t pv); static pv_entry_t get_pv_entry(pmap_t pmap, boolean_t try); static void pmap_pv_demote_pde(pmap_t pmap, vm_offset_t va, vm_paddr_t pa); @@ -2174,7 +2175,6 @@ pmap_pv_reclaim(pmap_t locked_pmap) static void free_pv_entry(pmap_t pmap, pv_entry_t pv) { - vm_page_t m; struct pv_chunk *pc; int idx, field, bit; @@ -2198,6 +2198,14 @@ free_pv_entry(pmap_t pmap, pv_entry_t pv return; } TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list); + free_pv_chunk(pc); +} + +static void +free_pv_chunk(struct pv_chunk *pc) +{ + vm_page_t m; + TAILQ_REMOVE(&pv_chunks, pc, pc_lru); PV_STAT(pv_entry_spare -= _NPCPV); PV_STAT(pc_chunk_count--); @@ -4211,15 +4219,8 @@ pmap_remove_pages(pmap_t pmap) } } if (allfree) { - PV_STAT(pv_entry_spare -= _NPCPV); - PV_STAT(pc_chunk_count--); - PV_STAT(pc_chunk_frees++); TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list); - TAILQ_REMOVE(&pv_chunks, pc, pc_lru); - m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)pc)); - dump_drop_page(m->phys_addr); - vm_page_unwire(m, 0); - vm_page_free(m); + free_pv_chunk(pc); } } pmap_invalidate_all(pmap); Modified: head/sys/i386/i386/pmap.c ============================================================================== --- head/sys/i386/i386/pmap.c Fri Jun 1 04:23:20 2012 (r236377) +++ head/sys/i386/i386/pmap.c Fri Jun 1 04:26:50 2012 (r236378) @@ -286,6 +286,7 @@ SYSCTL_INT(_debug, OID_AUTO, PMAP1unchan "Number of times pmap_pte_quick didn't change PMAP1"); static struct mtx PMAP2mutex; +static void free_pv_chunk(struct pv_chunk *pc); static void free_pv_entry(pmap_t pmap, pv_entry_t pv); static pv_entry_t get_pv_entry(pmap_t pmap, boolean_t try); static void pmap_pv_demote_pde(pmap_t pmap, vm_offset_t va, vm_paddr_t pa); @@ -2343,7 +2344,6 @@ out: static void free_pv_entry(pmap_t pmap, pv_entry_t pv) { - vm_page_t m; struct pv_chunk *pc; int idx, field, bit; @@ -2364,6 +2364,14 @@ free_pv_entry(pmap_t pmap, pv_entry_t pv TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list); return; } + free_pv_chunk(pc); +} + +static void +free_pv_chunk(struct pv_chunk *pc) +{ + vm_page_t m; + TAILQ_REMOVE(&pv_chunks, pc, pc_lru); PV_STAT(pv_entry_spare -= _NPCPV); PV_STAT(pc_chunk_count--); @@ -4445,16 +4453,8 @@ pmap_remove_pages(pmap_t pmap) } } if (allfree) { - PV_STAT(pv_entry_spare -= _NPCPV); - PV_STAT(pc_chunk_count--); - PV_STAT(pc_chunk_frees++); TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list); - TAILQ_REMOVE(&pv_chunks, pc, pc_lru); - m = PHYS_TO_VM_PAGE(pmap_kextract((vm_offset_t)pc)); - pmap_qremove((vm_offset_t)pc, 1); - vm_page_unwire(m, 0); - vm_page_free(m); - pmap_ptelist_free(&pv_vafree, (vm_offset_t)pc); + free_pv_chunk(pc); } } sched_unpin(); Modified: head/sys/i386/xen/pmap.c ============================================================================== --- head/sys/i386/xen/pmap.c Fri Jun 1 04:23:20 2012 (r236377) +++ head/sys/i386/xen/pmap.c Fri Jun 1 04:26:50 2012 (r236378) @@ -277,6 +277,7 @@ SYSCTL_INT(_debug, OID_AUTO, PMAP1unchan "Number of times pmap_pte_quick didn't change PMAP1"); static struct mtx PMAP2mutex; +static void free_pv_chunk(struct pv_chunk *pc); static void free_pv_entry(pmap_t pmap, pv_entry_t pv); static pv_entry_t get_pv_entry(pmap_t pmap, boolean_t try); static void pmap_pvh_free(struct md_page *pvh, pmap_t pmap, vm_offset_t va); @@ -2094,7 +2095,6 @@ out: static void free_pv_entry(pmap_t pmap, pv_entry_t pv) { - vm_page_t m; struct pv_chunk *pc; int idx, field, bit; @@ -2115,6 +2115,14 @@ free_pv_entry(pmap_t pmap, pv_entry_t pv TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list); return; } + free_pv_chunk(pc); +} + +static void +free_pv_chunk(struct pv_chunk *pc) +{ + vm_page_t m; + TAILQ_REMOVE(&pv_chunks, pc, pc_lru); PV_STAT(pv_entry_spare -= _NPCPV); PV_STAT(pc_chunk_count--); @@ -3591,16 +3599,8 @@ pmap_remove_pages(pmap_t pmap) } PT_UPDATES_FLUSH(); if (allfree) { - PV_STAT(pv_entry_spare -= _NPCPV); - PV_STAT(pc_chunk_count--); - PV_STAT(pc_chunk_frees++); TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list); - TAILQ_REMOVE(&pv_chunks, pc, pc_lru); - m = PHYS_TO_VM_PAGE(pmap_kextract((vm_offset_t)pc)); - pmap_qremove((vm_offset_t)pc, 1); - vm_page_unwire(m, 0); - vm_page_free(m); - pmap_ptelist_free(&pv_vafree, (vm_offset_t)pc); + free_pv_chunk(pc); } } PT_UPDATES_FLUSH();