Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/atari/atari Comply with the changes Jason suggested...



details:   https://anonhg.NetBSD.org/src/rev/4bc6e3042970
branches:  trunk
changeset: 473734:4bc6e3042970
user:      leo <leo%NetBSD.org@localhost>
date:      Thu Jun 17 07:59:16 1999 +0000

description:
Comply with the changes Jason suggested yesterday. A copy of his log message:
  Don't (ab)use uvm_map_pageable() to allocate PT pages.  Instead, do
  some internal reference counting on PT pages.  We still allocate them
  with the page fault routine (a wire-fault, now), but no longer free
  PT pages from pmap_pageable().

diffstat:

 sys/arch/atari/atari/pmap.c |  564 +++++++++++++++++++++++++++----------------
 1 files changed, 353 insertions(+), 211 deletions(-)

diffs (truncated from 662 to 300 lines):

diff -r e1a65904c15e -r 4bc6e3042970 sys/arch/atari/atari/pmap.c
--- a/sys/arch/atari/atari/pmap.c       Thu Jun 17 06:59:05 1999 +0000
+++ b/sys/arch/atari/atari/pmap.c       Thu Jun 17 07:59:16 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.45 1999/05/26 19:16:30 thorpej Exp $        */
+/*     $NetBSD: pmap.c,v 1.46 1999/06/17 07:59:16 leo Exp $    */
 
 /* 
  * Copyright (c) 1991 Regents of the University of California.
@@ -267,10 +267,19 @@
 static struct pv_entry* pmap_alloc_pv __P((void));
 static void            pmap_free_pv __P((struct pv_entry *));
 static void            pmap_pinit __P((pmap_t));
+static void            pmap_ptpage_addref __P((vaddr_t));
+static int             pmap_ptpage_delref __P((vaddr_t));
 static void            pmap_release __P((pmap_t));
+static void            pmap_remove_mapping __P((pmap_t, vaddr_t, pt_entry_t *,
+                                                       int));
 static void            atari_protection_init __P((void));
 static void            pmap_collect1 __P((pmap_t, paddr_t, paddr_t));  
 
+/* pmap_remove_mapping flags */
+#define        PRM_TFLUSH      0x01
+#define        PRM_CFLUSH      0x02
+#define        PRM_KEEPPTPAGE  0x04
+
 /*
  * All those kernel PT submaps that BSD is so fond of
  */
@@ -862,16 +871,9 @@
        register paddr_t pa;
        register vaddr_t va;
        register u_int *pte;
-       register pv_entry_t pv, npv;
-       pmap_t ptpmap;
-       int *ste, s, bits;
-       boolean_t flushcache = FALSE;
-#if defined(M68040) || defined(M68060)
-       int i;
-#endif
+       int flags;
+
 #ifdef DEBUG
-       u_int opte;
-
        if (pmapdebug & (PDB_FOLLOW|PDB_REMOVE|PDB_PROTECT))
                printf("pmap_remove(%p, %lx, %lx)\n", pmap, sva, eva);
 #endif
@@ -882,6 +884,7 @@
 #ifdef DEBUG
        remove_stats.calls++;
 #endif
+       flags = active_pmap(pmap) ? PRM_TFLUSH : 0;
        for (va = sva; va < eva; va += PAGE_SIZE) {
            /*
             * Weed out invalid mappings.
@@ -898,192 +901,7 @@
            pa = pmap_pte_pa(pte);
            if (pa == 0)
                continue;
-#ifdef DEBUG
-           opte = *pte;
-           remove_stats.removes++;
-#endif
-           /*
-            * Update statistics
-            */
-           if (pmap_pte_w(pte))
-               pmap->pm_stats.wired_count--;
-           pmap->pm_stats.resident_count--;
-
-           /*
-            * Invalidate the PTEs.
-            * XXX: should cluster them up and invalidate as many
-            * as possible at once.
-            */
-#ifdef DEBUG
-           if (pmapdebug & PDB_REMOVE)
-               printf("remove: invalidating %p\n", pte);
-#endif
-           bits = *(int *)pte & (PG_U|PG_M);
-           *(int *)pte = PG_NV;
-           if (active_pmap(pmap))
-               TBIS(va);
-
-           /*
-            * For user mappings decrement the wiring count on
-            * the PT page.  We do this after the PTE has been
-            * invalidated because vm_map_pageable winds up in
-            * pmap_pageable which clears the modify bit for the
-            * PT page.
-            */
-           if (pmap != pmap_kernel()) {
-               pte = pmap_pte(pmap, va);
-               (void) uvm_map_pageable(pt_map, trunc_page(pte),
-                                       round_page(pte+1), TRUE);
-#ifdef DEBUG
-               if (pmapdebug & PDB_WIRING)
-                       pmap_check_wiring("remove", trunc_page(pte));
-#endif
-           }
-           /*
-            * Remove from the PV table (raise IPL since we
-            * may be called at interrupt time).
-            */
-           if (!PAGE_IS_MANAGED(pa))
-               continue;
-           pv = pa_to_pvh(pa);
-           ste = (int *)0;
-           s = splimp();
-           /*
-            * If it is the first entry on the list, it is actually
-            * in the header and we must copy the following entry up
-            * to the header.  Otherwise we must search the list for
-            * the entry.  In either case we free the now unused entry.
-            */
-           if (pmap == pv->pv_pmap && va == pv->pv_va) {
-               ste = (int *)pv->pv_ptste;
-               ptpmap = pv->pv_ptpmap;
-               npv = pv->pv_next;
-               if (npv) {
-                       *pv = *npv;
-                       pmap_free_pv(npv);
-               } else
-                       pv->pv_pmap = NULL;
-#ifdef DEBUG
-               remove_stats.pvfirst++;
-#endif
-           } else {
-               for (npv = pv->pv_next; npv; npv = npv->pv_next) {
-#ifdef DEBUG
-                       remove_stats.pvsearch++;
-#endif
-                       if (pmap == npv->pv_pmap && va == npv->pv_va)
-                               break;
-                       pv = npv;
-               }
-#ifdef DEBUG
-               if (npv == NULL) {
-                       panic("pmap_remove: PA not in pv_list");
-               }
-#endif
-               ste = (int *)npv->pv_ptste;
-               ptpmap = npv->pv_ptpmap;
-               pv->pv_next = npv->pv_next;
-               pmap_free_pv(npv);
-               pv = pa_to_pvh(pa);
-           }
-           /*
-            * If this was a PT page we must also remove the
-            * mapping from the associated segment table.
-            */
-           if (ste) {
-#ifdef DEBUG
-               remove_stats.ptinvalid++;
-               if (pmapdebug & (PDB_REMOVE|PDB_PTPAGE)) {
-                       printf("remove: ste was %x@%p pte was %x@%p\n",
-                                      *ste, ste,
-                                      *(int *)&opte, pmap_pte(pmap, va));
-               }
-#endif
-#if defined(M68040) || defined(M68060)
-               if (mmutype == MMU_68040) {
-                   /*
-                    * On the 68040, the PT page contains NPTEPG/SG4_LEV3SIZE
-                    * page tables, so we need to remove all the associated
-                    * segment table entries
-                    * (This may be incorrect:  if a single page table is
-                    * being removed, the whole page should not be
-                    * removed.)
-                    */
-                   for (i = 0; i < NPTEPG / SG4_LEV3SIZE; ++i)
-                       *ste++ = SG_NV;
-                   ste -= NPTEPG / SG4_LEV3SIZE;
-#ifdef DEBUG
-                   if (pmapdebug &(PDB_REMOVE|PDB_SEGTAB|0x10000))
-                       printf("pmap_remove:PT at %lx removed\n", va);
-#endif
-               }
-               else
-#endif /* M68040 || M68060 */
-                   *ste = SG_NV;
-                   /*
-                    * If it was a user PT page, we decrement the
-                    * reference count on the segment table as well,
-                    * freeing it if it is now empty.
-                    */
-                   if (ptpmap != pmap_kernel()) {
-#ifdef DEBUG
-                               if (pmapdebug & (PDB_REMOVE|PDB_SEGTAB))
-                                       printf("remove: stab %p, refcnt %d\n",
-                                              ptpmap->pm_stab,
-                                              ptpmap->pm_sref - 1);
-                               if ((pmapdebug & PDB_PARANOIA) &&
-                                   ptpmap->pm_stab != (u_int *)trunc_page(ste))
-                                       panic("remove: bogus ste");
-#endif
-                       if (--(ptpmap->pm_sref) == 0) {
-#ifdef DEBUG
-                               if (pmapdebug&(PDB_REMOVE|PDB_SEGTAB))
-                               printf("remove: free stab %p\n",
-                                              ptpmap->pm_stab);
-#endif
-                               uvm_km_free_wakeup(kernel_map,
-                                                 (vaddr_t)ptpmap->pm_stab,
-                                                 ATARI_STSIZE);
-                               ptpmap->pm_stab = Segtabzero;
-                               ptpmap->pm_stpa = Segtabzeropa;
-#if defined(M68040) || defined(M68060)
-                               if (mmutype == MMU_68040)
-                                       ptpmap->pm_stfree = protostfree;
-#endif
-                               /*
-                                * XXX may have changed segment table
-                                * pointer for current process so
-                                * update now to reload hardware.
-                                */
-                               if (active_user_pmap(ptpmap))
-                                       PMAP_ACTIVATE(ptpmap, 1);
-                       }
-                   }
-                   if (ptpmap == pmap_kernel())
-                               TBIAS();
-                   else
-                               TBIAU();
-                   pv->pv_flags &= ~PV_PTPAGE;
-                   ptpmap->pm_ptpages--;
-           }
-           /*
-            * Update saved attributes for managed page
-            */
-           *pa_to_attribute(pa) |= bits;
-           splx(s);
-       }
-       if (flushcache) {
-               if (pmap == pmap_kernel()) {
-                       DCIS();
-#ifdef DEBUG
-                       remove_stats.sflushes++;
-#endif
-               } else {
-                       DCIU();
-#ifdef DEBUG
-                       remove_stats.uflushes++;
-#endif
-               }
+           pmap_remove_mapping(pmap, va, pte, flags);
        }
 }
 
@@ -1121,19 +939,33 @@
                pv = pa_to_pvh(pa);
                s = splimp();
                while (pv->pv_pmap != NULL) {
+                   pt_entry_t  *pte;
+
+                   pte = pmap_pte(pv->pv_pmap, pv->pv_va);
 #ifdef DEBUG
-                       if (!pmap_ste_v(pv->pv_pmap,pv->pv_va) ||
-                           pmap_pte_pa(pmap_pte(pv->pv_pmap,pv->pv_va)) != pa)
+                   if (!pmap_ste_v(pv->pv_pmap,pv->pv_va) ||
+                           pmap_pte_pa(pte) != pa)
 {
   printf ("pmap_page_protect: va %08lx, pmap_ste_v %d pmap_pte_pa %08x/%08lx\n",
     pv->pv_va, pmap_ste_v(pv->pv_pmap,pv->pv_va),
     pmap_pte_pa(pmap_pte(pv->pv_pmap,pv->pv_va)),pa);
   printf (" pvh %p pv %p pv_next %p\n", pa_to_pvh(pa), pv, pv->pv_next);
-                               panic("pmap_page_protect: bad mapping");
+                       panic("pmap_page_protect: bad mapping");
 }
 #endif
-                       pmap_remove(pv->pv_pmap, pv->pv_va,
-                                   pv->pv_va + PAGE_SIZE);
+                   if (!pmap_pte_w(pte))
+                       pmap_remove_mapping(pv->pv_pmap, pv->pv_va,
+                                               pte, PRM_TFLUSH|PRM_CFLUSH);
+                   else {
+                       pv = pv->pv_next;
+#ifdef DEBUG
+                       if (pmapdebug & PDB_PARANOIA)
+                               printf("%s wired mapping for %lx not removed\n",
+                                       "pmap_page_protect:", pa);
+#endif
+                       if (pv == NULL)
+                               break;
+                   }
                }
                splx(s);
                break;
@@ -1318,7 +1150,8 @@
                if (pmapdebug & PDB_ENTER)
                        printf("enter: removing old mapping %lx\n", va);
 #endif
-               pmap_remove(pmap, va, va + PAGE_SIZE);
+               pmap_remove_mapping(pmap, va, pte,
+                       PRM_TFLUSH|PRM_CFLUSH|PRM_KEEPPTPAGE);
 #ifdef DEBUG
                enter_stats.mchange++;
 #endif
@@ -1330,8 +1163,7 @@



Home | Main Index | Thread Index | Old Index