Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch - remove simple_lock(9) and use atomic_ops(3) to ac...



details:   https://anonhg.NetBSD.org/src/rev/efb2a12a44f5
branches:  trunk
changeset: 765714:efb2a12a44f5
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Fri Jun 03 17:03:52 2011 +0000

description:
- 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.

diffstat:

 sys/arch/m68k/include/pmap_motorola.h |   6 ++----
 sys/arch/m68k/m68k/pmap_motorola.c    |  16 +++++-----------
 sys/arch/sun2/include/pmap.h          |  10 +++-------
 sys/arch/sun2/sun2/pmap.c             |  21 ++++++---------------
 sys/arch/sun3/include/pmap3.h         |  10 +++-------
 sys/arch/sun3/include/pmap3x.h        |  12 ++++--------
 sys/arch/sun3/sun3/pmap.c             |  21 ++++++---------------
 sys/arch/sun3/sun3x/pmap.c            |  22 ++++++----------------
 8 files changed, 35 insertions(+), 83 deletions(-)

diffs (truncated from 420 to 300 lines):

diff -r fcc189bbd82c -r efb2a12a44f5 sys/arch/m68k/include/pmap_motorola.h
--- a/sys/arch/m68k/include/pmap_motorola.h     Fri Jun 03 16:35:35 2011 +0000
+++ b/sys/arch/m68k/include/pmap_motorola.h     Fri Jun 03 17:03:52 2011 +0000
@@ -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 */
 };
diff -r fcc189bbd82c -r efb2a12a44f5 sys/arch/m68k/m68k/pmap_motorola.c
--- a/sys/arch/m68k/m68k/pmap_motorola.c        Fri Jun 03 16:35:35 2011 +0000
+++ b/sys/arch/m68k/m68k/pmap_motorola.c        Fri Jun 03 17:03:52 2011 +0000
@@ -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);
 }
 
 /*
diff -r fcc189bbd82c -r efb2a12a44f5 sys/arch/sun2/include/pmap.h
--- a/sys/arch/sun2/include/pmap.h      Fri Jun 03 16:35:35 2011 +0000
+++ b/sys/arch/sun2/include/pmap.h      Fri Jun 03 17:03:52 2011 +0000
@@ -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.
diff -r fcc189bbd82c -r efb2a12a44f5 sys/arch/sun2/sun2/pmap.c
--- a/sys/arch/sun2/sun2/pmap.c Fri Jun 03 16:35:35 2011 +0000
+++ b/sys/arch/sun2/sun2/pmap.c Fri Jun 03 17:03:52 2011 +0000
@@ -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);
 }
 
 
diff -r fcc189bbd82c -r efb2a12a44f5 sys/arch/sun3/include/pmap3.h
--- a/sys/arch/sun3/include/pmap3.h     Fri Jun 03 16:35:35 2011 +0000
+++ b/sys/arch/sun3/include/pmap3.h     Fri Jun 03 17:03:52 2011 +0000
@@ -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.
diff -r fcc189bbd82c -r efb2a12a44f5 sys/arch/sun3/include/pmap3x.h
--- a/sys/arch/sun3/include/pmap3x.h    Fri Jun 03 16:35:35 2011 +0000
+++ b/sys/arch/sun3/include/pmap3x.h    Fri Jun 03 17:03:52 2011 +0000
@@ -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);
 
diff -r fcc189bbd82c -r efb2a12a44f5 sys/arch/sun3/sun3/pmap.c
--- a/sys/arch/sun3/sun3/pmap.c Fri Jun 03 16:35:35 2011 +0000
+++ b/sys/arch/sun3/sun3/pmap.c Fri Jun 03 17:03:52 2011 +0000
@@ -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 */



Home | Main Index | Thread Index | Old Index