Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Do not clobber pmap_kernel()'s pdir unnecessarily w...



details:   https://anonhg.NetBSD.org/src/rev/21aa02cf5ad7
branches:  trunk
changeset: 772967:21aa02cf5ad7
user:      cherry <cherry%NetBSD.org@localhost>
date:      Sun Jan 22 18:16:34 2012 +0000

description:
Do not clobber pmap_kernel()'s pdir unnecessarily while syncing per-cpu pdirs

diffstat:

 sys/arch/x86/x86/pmap.c     |   8 +-----
 sys/arch/xen/x86/xen_pmap.c |  50 ++++++++++++++++++++------------------------
 2 files changed, 25 insertions(+), 33 deletions(-)

diffs (128 lines):

diff -r 2dcd9f906bd2 -r 21aa02cf5ad7 sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c   Sun Jan 22 17:51:39 2012 +0000
+++ b/sys/arch/x86/x86/pmap.c   Sun Jan 22 18:16:34 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.153 2012/01/09 12:58:49 cherry Exp $        */
+/*     $NetBSD: pmap.c,v 1.154 2012/01/22 18:16:35 cherry Exp $        */
 
 /*-
  * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
@@ -171,7 +171,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.153 2012/01/09 12:58:49 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.154 2012/01/22 18:16:35 cherry Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -1883,7 +1883,6 @@
                 * on any cpu, clear it before freeing
                 */
                if (level == PTP_LEVELS - 1) {
-                       pmap_pte_set(&pmap_kernel()->pm_pdir[index], 0);
                        /*
                         * Update the per-cpu PD on all cpus the current
                         * pmap is active on 
@@ -1987,9 +1986,6 @@
                 * if pmap is curmap and modifying top level (PGD)
                 */
                if(i == PTP_LEVELS && pmap != pmap_kernel()) {
-                       pmap_pte_set(&pmap_kernel()->pm_pdir[index],
-                               (pd_entry_t) (pmap_pa2pte(pa)
-                                       | PG_u | PG_RW | PG_V));
                        /*
                         * Update the per-cpu PD on all cpus the current
                         * pmap is active on 
diff -r 2dcd9f906bd2 -r 21aa02cf5ad7 sys/arch/xen/x86/xen_pmap.c
--- a/sys/arch/xen/x86/xen_pmap.c       Sun Jan 22 17:51:39 2012 +0000
+++ b/sys/arch/xen/x86/xen_pmap.c       Sun Jan 22 18:16:34 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: xen_pmap.c,v 1.14 2012/01/19 22:04:05 bouyer Exp $     */
+/*     $NetBSD: xen_pmap.c,v 1.15 2012/01/22 18:16:34 cherry Exp $     */
 
 /*
  * Copyright (c) 2007 Manuel Bouyer.
@@ -102,7 +102,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xen_pmap.c,v 1.14 2012/01/19 22:04:05 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_pmap.c,v 1.15 2012/01/22 18:16:34 cherry Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -555,16 +555,19 @@
 
 extern struct cpu_info * (*xpq_cpu)(void);
 static __inline void
-pmap_kpm_setpte(struct cpu_info *ci, int index)
+pmap_kpm_setpte(struct cpu_info *ci, struct pmap *pmap, int index)
 {
+       if (pmap == pmap_kernel()) {
+               KASSERT(index >= PDIR_SLOT_KERN);
+       }
 #ifdef PAE
-               xpq_queue_pte_update(
-                       xpmap_ptetomach(&ci->ci_kpm_pdir[l2tol2(index)]),
-                       pmap_kernel()->pm_pdir[index]);
+       xpq_queue_pte_update(
+               xpmap_ptetomach(&ci->ci_kpm_pdir[l2tol2(index)]),
+               pmap->pm_pdir[index]);
 #elif defined(__x86_64__)
-               xpq_queue_pte_update(
-                       xpmap_ptetomach(&ci->ci_kpm_pdir[index]),
-                       pmap_kernel()->pm_pdir[index]);
+       xpq_queue_pte_update(
+               xpmap_ptetomach(&ci->ci_kpm_pdir[index]),
+               pmap->pm_pdir[index]);
 #endif /* PAE */
 }
 
@@ -580,27 +583,20 @@
        
        struct cpu_info *ci = xpq_cpu();
 
-       if (pmap == pmap_kernel()) {
-               KASSERT(index >= PDIR_SLOT_KERN);
-               pmap_kpm_setpte(ci, index);
-               pmap_pte_flush();
+#ifdef PAE
+       KASSERTMSG(pmap == pmap_kernel(), "%s not allowed for PAE user pmaps", __func__);
+#endif /* PAE */
+
+       if (__predict_true(pmap != pmap_kernel()) &&
+           pmap != ci->ci_pmap) {
+               /* User pmap changed. Nothing to do. */
                return;
        }
 
-#ifdef PAE
-       KASSERTMSG(false, "%s not allowed for PAE user pmaps", __func__);
+       /* Update per-cpu kpm */
+       pmap_kpm_setpte(ci, pmap, index);
+       pmap_pte_flush();
        return;
-#else /* __x86_64__ */
-       
-       if (ci->ci_pmap != pmap) {
-               /* pmap changed. Nothing to do. */
-               return;
-       }
-       
-       pmap_pte_set(&ci->ci_kpm_pdir[index],
-           pmap->pm_pdir[index]);
-       pmap_pte_flush();
-#endif /* PAE || __x86_64__ */
 }
 
 /*
@@ -626,7 +622,7 @@
                        }
                        if (pmap == pmap_kernel() ||
                            ci->ci_cpumask & pmap->pm_cpus) {
-                               pmap_kpm_setpte(ci, index);
+                               pmap_kpm_setpte(ci, pmap, index);
                        }
                }
                pmap_pte_flush();



Home | Main Index | Thread Index | Old Index