Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/alpha/alpha Remove the PTP and PV entry stealing co...



details:   https://anonhg.NetBSD.org/src/rev/32f5f8b20738
branches:  trunk
changeset: 509025:32f5f8b20738
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Tue Apr 24 20:53:43 2001 +0000

description:
Remove the PTP and PV entry stealing code.  Now that the pmap
module can fail gracefully, it serves little purpose, and the
code is a bit complicated and adds overhead to the context
switching code.

diffstat:

 sys/arch/alpha/alpha/pmap.c |  382 +++----------------------------------------
 1 files changed, 34 insertions(+), 348 deletions(-)

diffs (truncated from 584 to 300 lines):

diff -r 9c6bd1b7aad2 -r 32f5f8b20738 sys/arch/alpha/alpha/pmap.c
--- a/sys/arch/alpha/alpha/pmap.c       Tue Apr 24 20:16:36 2001 +0000
+++ b/sys/arch/alpha/alpha/pmap.c       Tue Apr 24 20:53:43 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.170 2001/04/24 20:14:45 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.171 2001/04/24 20:53:43 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -154,7 +154,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.170 2001/04/24 20:14:45 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.171 2001/04/24 20:53:43 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -476,25 +476,12 @@
 }
 
 /*
- * Optional argument passed to pmap_remove_mapping() for stealing mapping
- * resources.
- */
-struct prm_thief {
-       int     prmt_flags;             /* flags; what to steal */
-       struct pv_entry *prmt_pv;       /* the stolen PV entry */
-       pt_entry_t *prmt_ptp;           /* the stolen PT page */
-};
-
-#define        PRMT_PV         0x0001          /* steal the PV entry */
-#define        PRMT_PTP        0x0002          /* steal the PT page */
-
-/*
  * Internal routines
  */
 void   alpha_protection_init(void);
 void   pmap_do_remove(pmap_t, vaddr_t, vaddr_t, boolean_t);
 boolean_t pmap_remove_mapping(pmap_t, vaddr_t, pt_entry_t *,
-           boolean_t, long, struct prm_thief *);
+           boolean_t, long);
 void   pmap_changebit(paddr_t, pt_entry_t, pt_entry_t, long);
 
 /*
@@ -503,10 +490,8 @@
 int    pmap_lev1map_create(pmap_t, long);
 void   pmap_lev1map_destroy(pmap_t, long);
 int    pmap_ptpage_alloc(pmap_t, pt_entry_t *, int);
-boolean_t pmap_ptpage_steal(pmap_t, int, paddr_t *);
-void   pmap_ptpage_free(pmap_t, pt_entry_t *, pt_entry_t **);
-void   pmap_l3pt_delref(pmap_t, vaddr_t, pt_entry_t *, long,
-           pt_entry_t **);
+void   pmap_ptpage_free(pmap_t, pt_entry_t *);
+void   pmap_l3pt_delref(pmap_t, vaddr_t, pt_entry_t *, long);
 void   pmap_l2pt_delref(pmap_t, pt_entry_t *, pt_entry_t *, long);
 void   pmap_l1pt_delref(pmap_t, pt_entry_t *, long);
 
@@ -519,16 +504,16 @@
  * PV table management functions.
  */
 int    pmap_pv_enter(pmap_t, paddr_t, vaddr_t, pt_entry_t *, boolean_t);
-void   pmap_pv_remove(pmap_t, paddr_t, vaddr_t, boolean_t,
-           struct pv_entry **);
-struct pv_entry *pmap_pv_alloc(void);
-void   pmap_pv_free(struct pv_entry *);
+void   pmap_pv_remove(pmap_t, paddr_t, vaddr_t, boolean_t);
 void   *pmap_pv_page_alloc(u_long, int, int);
 void   pmap_pv_page_free(void *, u_long, int);
 #ifdef DEBUG
 void   pmap_pv_dump(paddr_t);
 #endif
 
+#define        pmap_pv_alloc()         pool_get(&pmap_pv_pool, PR_NOWAIT)
+#define        pmap_pv_free(pv)        pool_put(&pmap_pv_pool, (pv))
+
 /*
  * ASN management functions.
  */
@@ -1396,7 +1381,7 @@
                                            sva);
 #endif
                                needisync |= pmap_remove_mapping(pmap, sva,
-                                   l3pte, TRUE, cpu_id, NULL);
+                                   l3pte, TRUE, cpu_id);
                        }
                        sva += PAGE_SIZE;
                }
@@ -1473,7 +1458,7 @@
                                                            pmap_remove_mapping(
                                                                pmap, sva,
                                                                l3pte, TRUE,
-                                                               cpu_id, NULL);
+                                                               cpu_id);
                                                }
                                        }
 
@@ -1483,7 +1468,7 @@
                                         * may free the L3 table.
                                         */
                                        pmap_l3pt_delref(pmap, vptva,
-                                           saved_l3pte, cpu_id, NULL);
+                                           saved_l3pte, cpu_id);
                                }
                        }
 
@@ -1565,7 +1550,7 @@
 #endif
                if (pmap_pte_w(pv->pv_pte) == 0) {
                        if (pmap_remove_mapping(pmap, pv->pv_va, pv->pv_pte,
-                           FALSE, cpu_id, NULL) == TRUE) {
+                           FALSE, cpu_id) == TRUE) {
                                if (pmap == pmap_kernel())
                                        needkisync |= TRUE;
                                else
@@ -1890,7 +1875,7 @@
                 */
                pmap_physpage_addref(pte);
        }
-       needisync |= pmap_remove_mapping(pmap, va, pte, TRUE, cpu_id, NULL);
+       needisync |= pmap_remove_mapping(pmap, va, pte, TRUE, cpu_id);
 
  validate_enterpv:
        /*
@@ -1899,7 +1884,7 @@
        if (managed) {
                error = pmap_pv_enter(pmap, pa, va, pte, TRUE);
                if (error) {
-                       pmap_l3pt_delref(pmap, va, pte, cpu_id, NULL);
+                       pmap_l3pt_delref(pmap, va, pte, cpu_id);
                        if (flags & PMAP_CANFAIL)
                                return (error);
                        panic("pmap_enter: unable to enter mapping in PV "
@@ -2305,14 +2290,6 @@
         */
        atomic_setbits_ulong(&pmap->pm_cpus, (1UL << cpu_id));
 
-       /*
-        * Move the pmap to the end of the LRU list.
-        */
-       simple_lock(&pmap_all_pmaps_slock);
-       TAILQ_REMOVE(&pmap_all_pmaps, pmap, pm_list);
-       TAILQ_INSERT_TAIL(&pmap_all_pmaps, pmap, pm_list);
-       simple_unlock(&pmap_all_pmaps_slock);
-
        PMAP_LOCK(pmap);
 
        /*
@@ -2660,36 +2637,20 @@
  */
 boolean_t
 pmap_remove_mapping(pmap_t pmap, vaddr_t va, pt_entry_t *pte,
-    boolean_t dolock, long cpu_id, struct prm_thief *prmt)
+    boolean_t dolock, long cpu_id)
 {
        paddr_t pa;
        boolean_t onpv;
        boolean_t hadasm;
        boolean_t isactive;
        boolean_t needisync = FALSE;
-       struct pv_entry **pvp;
-       pt_entry_t **ptp;
 
 #ifdef DEBUG
        if (pmapdebug & (PDB_FOLLOW|PDB_REMOVE|PDB_PROTECT))
-               printf("pmap_remove_mapping(%p, %lx, %p, %d, %ld, %p)\n",
-                      pmap, va, pte, dolock, cpu_id, pvp);
+               printf("pmap_remove_mapping(%p, %lx, %p, %d, %ld)\n",
+                      pmap, va, pte, dolock, cpu_id);
 #endif
 
-       if (prmt != NULL) {
-               if (prmt->prmt_flags & PRMT_PV)
-                       pvp = &prmt->prmt_pv;
-               else
-                       pvp = NULL;
-               if (prmt->prmt_flags & PRMT_PTP)
-                       ptp = &prmt->prmt_ptp;
-               else
-                       ptp = NULL;
-       } else {
-               pvp = NULL;
-               ptp = NULL;
-       }
-
        /*
         * PTE not provided, compute it from pmap and va.
         */
@@ -2748,24 +2709,19 @@
                 * delete references on the level 2 and 1 tables as
                 * appropriate.
                 */
-               pmap_l3pt_delref(pmap, va, pte, cpu_id, ptp);
+               pmap_l3pt_delref(pmap, va, pte, cpu_id);
        }
 
        /*
         * If the mapping wasn't enterd on the PV list, we're all done.
         */
-       if (onpv == FALSE) {
-#ifdef DIAGNOSTIC
-               if (pvp != NULL)
-                       panic("pmap_removing_mapping: onpv / pvp inconsistent");
-#endif
+       if (onpv == FALSE)
                return (needisync);
-       }
 
        /*
         * Remove it from the PV table.
         */
-       pmap_pv_remove(pmap, pa, va, dolock, pvp);
+       pmap_pv_remove(pmap, pa, va, dolock);
 
        return (needisync);
 }
@@ -3100,8 +3056,7 @@
  *     Remove a physical->virtual entry from the pv_table.
  */
 void
-pmap_pv_remove(pmap_t pmap, paddr_t pa, vaddr_t va, boolean_t dolock,
-    struct pv_entry **pvp)
+pmap_pv_remove(pmap_t pmap, paddr_t pa, vaddr_t va, boolean_t dolock)
 {
        struct pv_head *pvh;
        pv_entry_t pv;
@@ -3129,112 +3084,7 @@
        if (dolock)
                simple_unlock(&pvh->pvh_slock);
 
-       /*
-        * If pvp is not NULL, this is pmap_pv_alloc() stealing an
-        * entry from another mapping, and we return the now unused
-        * entry in it.  Otherwise, free the pv_entry.
-        */
-       if (pvp != NULL)
-               *pvp = pv;
-       else
-               pmap_pv_free(pv);
-}
-
-/*
- * pmap_pv_alloc:
- *
- *     Allocate a pv_entry.
- */
-struct pv_entry *
-pmap_pv_alloc(void)
-{
-       struct pv_head *pvh;
-       struct pv_entry *pv;
-       int bank, npg, pg;
-       pt_entry_t *pte;
-       pmap_t pvpmap;
-       u_long cpu_id;
-       struct prm_thief prmt;
-
-       pv = pool_get(&pmap_pv_pool, PR_NOWAIT);
-       if (pv != NULL)
-               return (pv);
-
-       prmt.prmt_flags = PRMT_PV;
-
-       /*
-        * We were unable to allocate one from the pool.  Try to
-        * steal one from another mapping.  At this point we know that:
-        *
-        *      (1) We have not locked the pv table, and we already have
-        *          the map-to-head lock, so it is safe for us to do so here.
-        *
-        *      (2) The pmap that wants this entry *is* locked.  We must
-        *          use simple_lock_try() to prevent deadlock from occurring.
-        *
-        * XXX Note that in case #2, there is an exception; it *is* safe to
-        * steal a mapping from the pmap that wants this entry!  We may want
-        * to consider passing the pmap to this function so that we can take
-        * advantage of this.
-        */
-
-       /* XXX This search could probably be improved. */
-       for (bank = 0; bank < vm_nphysseg; bank++) {
-               npg = vm_physmem[bank].end - vm_physmem[bank].start;
-               for (pg = 0; pg < npg; pg++) {
-                       pvh = &vm_physmem[bank].pmseg.pvhead[pg];
-                       simple_lock(&pvh->pvh_slock);
-                       for (pv = LIST_FIRST(&pvh->pvh_list);
-                            pv != NULL; pv = LIST_NEXT(pv, pv_list)) {
-                               pvpmap = pv->pv_pmap;
-
-                               /* Don't steal from kernel pmap. */
-                               if (pvpmap == pmap_kernel())
-                                       continue;
-
-                               if (simple_lock_try(&pvpmap->pm_slock) == 0)
-                                       continue;
-
-                               pte = pv->pv_pte;
-
-                               /* Don't steal wired mappings. */
-                               if (pmap_pte_w(pte)) {



Home | Main Index | Thread Index | Old Index