Source-Changes-HG archive

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

[src/trunk]: src/sys/uvm/pmap Move some code before pmap_enter_pv in pmap_ent...



details:   https://anonhg.NetBSD.org/src/rev/c822a6357c77
branches:  trunk
changeset: 348153:c822a6357c77
user:      skrll <skrll%NetBSD.org@localhost>
date:      Wed Oct 05 20:50:00 2016 +0000

description:
Move some code before pmap_enter_pv in pmap_enter so that when we are
re-mapping a VA to a new PA the old mapping is removed first.  This means
the cache alias code need to do less work and works better with the last
va tracking.

diffstat:

 sys/uvm/pmap/pmap.c |  37 +++++++++++++++++++++----------------
 1 files changed, 21 insertions(+), 16 deletions(-)

diffs (65 lines):

diff -r 4af6a8cfb088 -r c822a6357c77 sys/uvm/pmap/pmap.c
--- a/sys/uvm/pmap/pmap.c       Wed Oct 05 20:02:03 2016 +0000
+++ b/sys/uvm/pmap/pmap.c       Wed Oct 05 20:50:00 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.23 2016/09/30 12:10:40 skrll Exp $  */
+/*     $NetBSD: pmap.c,v 1.24 2016/10/05 20:50:00 skrll Exp $  */
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.23 2016/09/30 12:10:40 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.24 2016/10/05 20:50:00 skrll Exp $");
 
 /*
  *     Manages physical address maps.
@@ -1254,6 +1254,25 @@
                return ENOMEM;
        }
        const pt_entry_t opte = *ptep;
+       const bool resident = pte_valid_p(opte);
+       bool remap = false;
+       if (resident) {
+               if (pte_to_paddr(opte) != pa) {
+                       KASSERT(!is_kernel_pmap_p);
+                       const pt_entry_t rpte = pte_nv_entry(false);
+
+                       pmap_addr_range_check(pmap, va, va + NBPG, __func__);
+                       pmap_pte_process(pmap, va, va + NBPG, pmap_pte_remove,
+                           rpte);
+                       PMAP_COUNT(user_mappings_changed);
+                       remap = true;
+               }
+               update_flags |= PMAP_TLB_NEED_IPI;
+       }
+
+       if (!resident || remap) {
+               pmap->pm_stats.resident_count++;
+       }
 
        /* Done after case that may sleep/return. */
        if (pg)
@@ -1273,20 +1292,6 @@
            pte_value(npte), pa, 0, 0);
 
        KASSERT(pte_valid_p(npte));
-       const bool resident = pte_valid_p(opte);
-       bool remap = false;
-       if (resident) {
-               if (pte_to_paddr(opte) != pa) {
-                       pmap_remove(pmap, va, va + NBPG);
-                       PMAP_COUNT(user_mappings_changed);
-                       remap = true;
-               }
-               update_flags |= PMAP_TLB_NEED_IPI;
-       }
-
-       if (!resident || remap) {
-               pmap->pm_stats.resident_count++;
-       }
 
        pmap_md_tlb_miss_lock_enter();
        *ptep = npte;



Home | Main Index | Thread Index | Old Index