Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc/sparc Avoid using demap_lock early in pmap_bo...



details:   https://anonhg.NetBSD.org/src/rev/394fb2ef7ef0
branches:  trunk
changeset: 754283:394fb2ef7ef0
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Apr 26 09:26:25 2010 +0000

description:
Avoid using demap_lock early in pmap_bootstrap before it is initialized.

diffstat:

 sys/arch/sparc/sparc/pmap.c |  20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diffs (82 lines):

diff -r 4b36757a64ce -r 394fb2ef7ef0 sys/arch/sparc/sparc/pmap.c
--- a/sys/arch/sparc/sparc/pmap.c       Mon Apr 26 07:51:36 2010 +0000
+++ b/sys/arch/sparc/sparc/pmap.c       Mon Apr 26 09:26:25 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.339 2009/12/20 03:48:30 mrg Exp $ */
+/*     $NetBSD: pmap.c,v 1.340 2010/04/26 09:26:25 martin Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -56,7 +56,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.339 2009/12/20 03:48:30 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.340 2010/04/26 09:26:25 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -316,6 +316,7 @@
 int    reginval;               /* [4/3mmu] the invalid region number */
 
 static kmutex_t demap_lock;
+static bool    lock_available = false; /* demap_lock has been initialized */
 
 /*
  * (sun4/4c)
@@ -781,12 +782,14 @@
 {
        int oldval, swapval;
        volatile int *vpte = (volatile int *)pte;
+       bool can_lock = lock_available;
 
        /*
         * Can only be one of these happening in the system
         * at any one time.
         */
-       mutex_spin_enter(&demap_lock);
+       if (__predict_true(can_lock))
+               mutex_spin_enter(&demap_lock);
 
        /*
         * The idea is to loop swapping zero into the pte, flushing
@@ -805,7 +808,8 @@
        swapval = (oldval & ~bic) | bis;
        swap(vpte, swapval);
 
-       mutex_spin_exit(&demap_lock);
+       if (__predict_true(can_lock))
+               mutex_spin_exit(&demap_lock);
 
        return (oldval);
 }
@@ -3028,6 +3032,7 @@
        pmap_page_upload();
        mutex_init(&demap_lock, MUTEX_DEFAULT, IPL_VM);
        mutex_init(&ctx_lock, MUTEX_DEFAULT, IPL_SCHED);
+       lock_available = true;
 }
 
 #if defined(SUN4) || defined(SUN4C)
@@ -6746,6 +6751,7 @@
        struct segmap *sp;
        int pte;
        int vr, vs, s, v = false;
+       bool can_lock = lock_available;
 
        vr = VA_VREG(va);
        vs = VA_VSEG(va);
@@ -6789,9 +6795,11 @@
                 * the middle of the PTE update protocol. So, acquire the
                 * demap lock and retry.
                 */
-               mutex_spin_enter(&demap_lock);
+               if (__predict_true(can_lock))
+                       mutex_spin_enter(&demap_lock);
                pte = sp->sg_pte[VA_SUN4M_VPG(va)];
-               mutex_spin_exit(&demap_lock);
+               if (__predict_true(can_lock))
+                       mutex_spin_exit(&demap_lock);
                if ((pte & SRMMU_TETYPE) != SRMMU_TEPTE)
                        goto out;
        }



Home | Main Index | Thread Index | Old Index