Module Name: src Committed By: tsutsui Date: Fri Jun 3 17:03:53 UTC 2011
Modified Files: src/sys/arch/m68k/include: pmap_motorola.h src/sys/arch/m68k/m68k: pmap_motorola.c src/sys/arch/sun2/include: pmap.h src/sys/arch/sun2/sun2: pmap.c src/sys/arch/sun3/include: pmap3.h pmap3x.h src/sys/arch/sun3/sun3: pmap.c src/sys/arch/sun3/sun3x: pmap.c Log Message: - remove simple_lock(9) and use atomic_ops(3) to account pmap reference count, perrequest from rmind@ - while here no need to export struct pmap on sun2/sun3/sun3x No particular problem for a week on hp300 and sun3x kernels with disabled tcp_vtw which has been broken for a month on low memory machines. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/arch/m68k/include/pmap_motorola.h cvs rdiff -u -r1.60 -r1.61 src/sys/arch/m68k/m68k/pmap_motorola.c cvs rdiff -u -r1.23 -r1.24 src/sys/arch/sun2/include/pmap.h cvs rdiff -u -r1.43 -r1.44 src/sys/arch/sun2/sun2/pmap.c cvs rdiff -u -r1.47 -r1.48 src/sys/arch/sun3/include/pmap3.h cvs rdiff -u -r1.28 -r1.29 src/sys/arch/sun3/include/pmap3x.h cvs rdiff -u -r1.165 -r1.166 src/sys/arch/sun3/sun3/pmap.c cvs rdiff -u -r1.111 -r1.112 src/sys/arch/sun3/sun3x/pmap.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/m68k/include/pmap_motorola.h diff -u src/sys/arch/m68k/include/pmap_motorola.h:1.32 src/sys/arch/m68k/include/pmap_motorola.h:1.33 --- src/sys/arch/m68k/include/pmap_motorola.h:1.32 Thu Jan 6 13:49:16 2011 +++ src/sys/arch/m68k/include/pmap_motorola.h Fri Jun 3 17:03:52 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_motorola.h,v 1.32 2011/01/06 13:49:16 tsutsui Exp $ */ +/* $NetBSD: pmap_motorola.h,v 1.33 2011/06/03 17:03:52 tsutsui Exp $ */ /* * Copyright (c) 1991, 1993 @@ -80,7 +80,6 @@ #include "opt_m68k_arch.h" #endif -#include <sys/simplelock.h> #include <machine/cpu.h> #include <machine/pte.h> @@ -93,8 +92,7 @@ u_int pm_stfree; /* 040: free lev2 blocks */ st_entry_t *pm_stpa; /* 040: ST phys addr */ uint16_t pm_sref; /* segment table ref count */ - uint16_t pm_count; /* pmap reference count */ - struct simplelock pm_lock; /* lock on pmap */ + u_int pm_count; /* pmap reference count */ struct pmap_statistics pm_stats; /* pmap statistics */ int pm_ptpages; /* more stats: PT pages */ }; Index: src/sys/arch/m68k/m68k/pmap_motorola.c diff -u src/sys/arch/m68k/m68k/pmap_motorola.c:1.60 src/sys/arch/m68k/m68k/pmap_motorola.c:1.61 --- src/sys/arch/m68k/m68k/pmap_motorola.c:1.60 Fri Jan 14 02:06:27 2011 +++ src/sys/arch/m68k/m68k/pmap_motorola.c Fri Jun 3 17:03:52 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_motorola.c,v 1.60 2011/01/14 02:06:27 rmind Exp $ */ +/* $NetBSD: pmap_motorola.c,v 1.61 2011/06/03 17:03:52 tsutsui Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -119,7 +119,7 @@ #include "opt_m68k_arch.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap_motorola.c,v 1.60 2011/01/14 02:06:27 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap_motorola.c,v 1.61 2011/06/03 17:03:52 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -127,6 +127,7 @@ #include <sys/malloc.h> #include <sys/pool.h> #include <sys/cpu.h> +#include <sys/atomic.h> #include <machine/pte.h> #include <machine/pcb.h> @@ -362,7 +363,6 @@ if (mmutype == MMU_68040) pmap_kernel()->pm_stfree = protostfree; #endif - simple_lock_init(&pmap_kernel()->pm_lock); pmap_kernel()->pm_count = 1; /* @@ -791,7 +791,6 @@ pmap->pm_stfree = protostfree; #endif pmap->pm_count = 1; - simple_lock_init(&pmap->pm_lock); } /* @@ -807,9 +806,7 @@ PMAP_DPRINTF(PDB_FOLLOW, ("pmap_destroy(%p)\n", pmap)); - simple_lock(&pmap->pm_lock); - count = --pmap->pm_count; - simple_unlock(&pmap->pm_lock); + count = atomic_dec_uint_nv(&pmap->pm_count); if (count == 0) { pmap_release(pmap); pool_put(&pmap_pmap_pool, pmap); @@ -831,7 +828,6 @@ #ifdef notdef /* DIAGNOSTIC */ /* count would be 0 from pmap_destroy... */ - simple_lock(&pmap->pm_lock); if (pmap->pm_count != 1) panic("pmap_release count"); #endif @@ -857,9 +853,7 @@ { PMAP_DPRINTF(PDB_FOLLOW, ("pmap_reference(%p)\n", pmap)); - simple_lock(&pmap->pm_lock); - pmap->pm_count++; - simple_unlock(&pmap->pm_lock); + atomic_inc_uint(&pmap->pm_count); } /* Index: src/sys/arch/sun2/include/pmap.h diff -u src/sys/arch/sun2/include/pmap.h:1.23 src/sys/arch/sun2/include/pmap.h:1.24 --- src/sys/arch/sun2/include/pmap.h:1.23 Fri Dec 11 18:31:27 2009 +++ src/sys/arch/sun2/include/pmap.h Fri Jun 3 17:03:52 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.23 2009/12/11 18:31:27 tsutsui Exp $ */ +/* $NetBSD: pmap.h,v 1.24 2011/06/03 17:03:52 tsutsui Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -29,22 +29,18 @@ #ifndef _MACHINE_PMAP_H #define _MACHINE_PMAP_H -#include <sys/simplelock.h> - +#ifdef _KERNEL /* * Physical map structures exported to the VM code. - * XXX - Does user-level code really see this struct? */ struct pmap { unsigned char *pm_segmap; /* soft copy of segmap */ int pm_ctxnum; /* MMU context number */ - struct simplelock pm_lock; /* lock on pmap */ - int pm_refcount; /* reference count */ + u_int pm_refcount; /* reference count */ int pm_version; }; -#ifdef _KERNEL /* * We give the pmap code a chance to resolve faults by * reloading translations that it was forced to unload. Index: src/sys/arch/sun2/sun2/pmap.c diff -u src/sys/arch/sun2/sun2/pmap.c:1.43 src/sys/arch/sun2/sun2/pmap.c:1.44 --- src/sys/arch/sun2/sun2/pmap.c:1.43 Fri Dec 11 13:56:16 2009 +++ src/sys/arch/sun2/sun2/pmap.c Fri Jun 3 17:03:52 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.43 2009/12/11 13:56:16 tsutsui Exp $ */ +/* $NetBSD: pmap.c,v 1.44 2011/06/03 17:03:52 tsutsui Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -82,7 +82,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.43 2009/12/11 13:56:16 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.44 2011/06/03 17:03:52 tsutsui Exp $"); #include "opt_ddb.h" #include "opt_pmap_debug.h" @@ -94,6 +94,7 @@ #include <sys/pool.h> #include <sys/queue.h> #include <sys/kcore.h> +#include <sys/atomic.h> #include <uvm/uvm.h> @@ -242,12 +243,6 @@ int ps_vac_recached; /* re-cached when bad alias gone */ } pmap_stats; -#define pmap_lock(pmap) simple_lock(&pmap->pm_lock) -#define pmap_unlock(pmap) simple_unlock(&pmap->pm_lock) -#define pmap_add_ref(pmap) ++pmap->pm_refcount -#define pmap_del_ref(pmap) --pmap->pm_refcount -#define pmap_refcount(pmap) pmap->pm_refcount - #ifdef PMAP_DEBUG #define CHECK_SPL() do { \ if ((getsr() & PSL_IPL) < PSL_IPL4) \ @@ -1486,7 +1481,6 @@ pmap->pm_refcount = 1; pmap->pm_version = pmap_version++; pmap->pm_ctxnum = EMPTY_CONTEXT; - simple_lock_init(&pmap->pm_lock); } /* @@ -1900,9 +1894,7 @@ #endif if (pmap == kernel_pmap) panic("pmap_destroy: kernel_pmap!"); - pmap_lock(pmap); - count = pmap_del_ref(pmap); - pmap_unlock(pmap); + count = atomic_dec_uint_nv(&pmap->pm_refcount); if (count == 0) { pmap_release(pmap); pool_put(&pmap_pmap_pool, pmap); @@ -1915,9 +1907,8 @@ void pmap_reference(pmap_t pmap) { - pmap_lock(pmap); - pmap_add_ref(pmap); - pmap_unlock(pmap); + + atomic_inc_uint(&pmap->pm_refcount); } Index: src/sys/arch/sun3/include/pmap3.h diff -u src/sys/arch/sun3/include/pmap3.h:1.47 src/sys/arch/sun3/include/pmap3.h:1.48 --- src/sys/arch/sun3/include/pmap3.h:1.47 Fri Dec 11 18:40:08 2009 +++ src/sys/arch/sun3/include/pmap3.h Fri Jun 3 17:03:52 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap3.h,v 1.47 2009/12/11 18:40:08 tsutsui Exp $ */ +/* $NetBSD: pmap3.h,v 1.48 2011/06/03 17:03:52 tsutsui Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -29,22 +29,18 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#ifdef _KERNEL /* * Physical map structures exported to the VM code. - * XXX - Does user-level code really see this struct? */ -#include <sys/simplelock.h> - struct pmap { unsigned char *pm_segmap; /* soft copy of segmap */ int pm_ctxnum; /* MMU context number */ - struct simplelock pm_lock; /* lock on pmap */ - int pm_refcount; /* reference count */ + u_int pm_refcount; /* reference count */ int pm_version; }; -#ifdef _KERNEL /* * We give the pmap code a chance to resolve faults by * reloading translations that it was forced to unload. Index: src/sys/arch/sun3/include/pmap3x.h diff -u src/sys/arch/sun3/include/pmap3x.h:1.28 src/sys/arch/sun3/include/pmap3x.h:1.29 --- src/sys/arch/sun3/include/pmap3x.h:1.28 Fri Dec 11 18:40:08 2009 +++ src/sys/arch/sun3/include/pmap3x.h Fri Jun 3 17:03:52 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap3x.h,v 1.28 2009/12/11 18:40:08 tsutsui Exp $ */ +/* $NetBSD: pmap3x.h,v 1.29 2011/06/03 17:03:52 tsutsui Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -29,22 +29,18 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#ifdef _KERNEL /* * Physical map structures exported to the VM code. - * XXX - Does user-level code really see this struct? */ -#include <sys/simplelock.h> - struct pmap { struct a_tmgr_struct *pm_a_tmgr; /* Level-A table manager */ - u_long pm_a_phys; /* MMU level-A phys addr */ - struct simplelock pm_lock; /* lock on pmap */ - int pm_refcount; /* reference count */ + paddr_t pm_a_phys; /* MMU level-A phys addr */ + u_int pm_refcount; /* reference count */ int pm_version; }; -#ifdef _KERNEL /* Common function for pmap_resident_count(), pmap_wired_count() */ segsz_t pmap_count(pmap_t, int); Index: src/sys/arch/sun3/sun3/pmap.c diff -u src/sys/arch/sun3/sun3/pmap.c:1.165 src/sys/arch/sun3/sun3/pmap.c:1.166 --- src/sys/arch/sun3/sun3/pmap.c:1.165 Fri Oct 15 15:55:53 2010 +++ src/sys/arch/sun3/sun3/pmap.c Fri Jun 3 17:03:53 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.165 2010/10/15 15:55:53 tsutsui Exp $ */ +/* $NetBSD: pmap.c,v 1.166 2011/06/03 17:03:53 tsutsui Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -80,7 +80,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.165 2010/10/15 15:55:53 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.166 2011/06/03 17:03:53 tsutsui Exp $"); #include "opt_ddb.h" #include "opt_pmap_debug.h" @@ -92,6 +92,7 @@ #include <sys/pool.h> #include <sys/queue.h> #include <sys/kcore.h> +#include <sys/atomic.h> #include <uvm/uvm.h> @@ -248,12 +249,6 @@ int ps_vac_recached; /* re-cached when bad alias gone */ } pmap_stats; -#define pmap_lock(pmap) simple_lock(&pmap->pm_lock) -#define pmap_unlock(pmap) simple_unlock(&pmap->pm_lock) -#define pmap_add_ref(pmap) ++pmap->pm_refcount -#define pmap_del_ref(pmap) --pmap->pm_refcount -#define pmap_refcount(pmap) pmap->pm_refcount - #ifdef PMAP_DEBUG #define CHECK_SPL() do { \ if ((getsr() & PSL_IPL) < PSL_IPL4) \ @@ -1490,7 +1485,6 @@ pmap->pm_refcount = 1; pmap->pm_version = pmap_version++; pmap->pm_ctxnum = EMPTY_CONTEXT; - simple_lock_init(&pmap->pm_lock); } /* @@ -1929,9 +1923,7 @@ #endif if (pmap == kernel_pmap) panic("pmap_destroy: kernel_pmap!"); - pmap_lock(pmap); - count = pmap_del_ref(pmap); - pmap_unlock(pmap); + count = atomic_dec_uint_nv(&pmap->pm_refcount); if (count == 0) { pmap_release(pmap); pool_put(&pmap_pmap_pool, pmap); @@ -1944,9 +1936,8 @@ void pmap_reference(pmap_t pmap) { - pmap_lock(pmap); - pmap_add_ref(pmap); - pmap_unlock(pmap); + + atomic_inc_uint(&pmap->pm_refcount); } Index: src/sys/arch/sun3/sun3x/pmap.c diff -u src/sys/arch/sun3/sun3x/pmap.c:1.111 src/sys/arch/sun3/sun3x/pmap.c:1.112 --- src/sys/arch/sun3/sun3x/pmap.c:1.111 Fri Oct 15 15:55:53 2010 +++ src/sys/arch/sun3/sun3x/pmap.c Fri Jun 3 17:03:53 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.111 2010/10/15 15:55:53 tsutsui Exp $ */ +/* $NetBSD: pmap.c,v 1.112 2011/06/03 17:03:53 tsutsui Exp $ */ /*- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. @@ -105,7 +105,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.111 2010/10/15 15:55:53 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.112 2011/06/03 17:03:53 tsutsui Exp $"); #include "opt_ddb.h" #include "opt_pmap_debug.h" @@ -117,6 +117,7 @@ #include <sys/pool.h> #include <sys/queue.h> #include <sys/kcore.h> +#include <sys/atomic.h> #include <uvm/uvm.h> @@ -356,12 +357,6 @@ #define NUM_KERN_PTES (KVAS_SIZE >> MMU_TIC_SHIFT) /*************************** MISCELANEOUS MACROS *************************/ -#define pmap_lock(pmap) simple_lock(&pmap->pm_lock) -#define pmap_unlock(pmap) simple_unlock(&pmap->pm_lock) -#define pmap_add_ref(pmap) ++pmap->pm_refcount -#define pmap_del_ref(pmap) --pmap->pm_refcount -#define pmap_refcount(pmap) pmap->pm_refcount - void *pmap_bootstrap_alloc(int); static INLINE void *mmu_ptov(paddr_t); @@ -835,7 +830,6 @@ kernel_pmap.pm_a_tmgr = NULL; kernel_pmap.pm_a_phys = kernAphys; kernel_pmap.pm_refcount = 1; /* always in use */ - simple_lock_init(&kernel_pmap.pm_lock); kernel_crp.rp_attr = MMU_LONG_DTE_LU | MMU_DT_LONG; kernel_crp.rp_addr = kernAphys; @@ -2530,7 +2524,6 @@ pmap->pm_a_tmgr = NULL; pmap->pm_a_phys = kernAphys; pmap->pm_refcount = 1; - simple_lock_init(&pmap->pm_lock); } /* pmap_create INTERFACE @@ -2601,9 +2594,8 @@ void pmap_reference(pmap_t pmap) { - pmap_lock(pmap); - pmap_add_ref(pmap); - pmap_unlock(pmap); + + atomic_inc_uint(&pmap->pm_refcount); } /* pmap_dereference INTERNAL @@ -2616,9 +2608,7 @@ { int rtn; - pmap_lock(pmap); - rtn = pmap_del_ref(pmap); - pmap_unlock(pmap); + rtn = atomic_dec_uint_nv(&pmap->pm_refcount); return rtn; }