Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sh3/sh3 Sync with current i386 pmap.c.
details: https://anonhg.NetBSD.org/src/rev/84bb28b7cc61
branches: trunk
changeset: 485289:84bb28b7cc61
user: tsubai <tsubai%NetBSD.org@localhost>
date: Mon Apr 24 08:40:21 2000 +0000
description:
Sync with current i386 pmap.c.
diffstat:
sys/arch/sh3/sh3/pmap.c | 161 ++++++++++++++++++++++++++++-------------------
1 files changed, 95 insertions(+), 66 deletions(-)
diffs (truncated from 502 to 300 lines):
diff -r 4fc5e095c6b3 -r 84bb28b7cc61 sys/arch/sh3/sh3/pmap.c
--- a/sys/arch/sh3/sh3/pmap.c Mon Apr 24 07:03:27 2000 +0000
+++ b/sys/arch/sh3/sh3/pmap.c Mon Apr 24 08:40:21 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.6 2000/04/10 06:34:13 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.7 2000/04/24 08:40:21 tsubai Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -231,16 +231,6 @@
* this lock protects the list of active pmaps (headed by "pmaps").
* we lock it when adding or removing pmaps from this list.
*
- * - pmap_copy_page_lock
- * locks the tmp kernel PTE mappings we used to copy data
- *
- * - pmap_zero_page_lock
- * locks the tmp kernel PTE mapping we use to zero a page
- *
- * - pmap_tmpptp_lock
- * locks the tmp kernel PTE mapping we use to look at a PTP
- * in another process
- *
* XXX: would be nice to have per-CPU VAs for the above 4
*/
@@ -252,19 +242,16 @@
struct lock pmap_main_lock;
simple_lock_data_t pvalloc_lock;
simple_lock_data_t pmaps_lock;
-simple_lock_data_t pmap_copy_page_lock;
-simple_lock_data_t pmap_zero_page_lock;
-simple_lock_data_t pmap_tmpptp_lock;
#define PMAP_MAP_TO_HEAD_LOCK() \
- lockmgr(&pmap_main_lock, LK_SHARED, (void *) 0)
+ spinlockmgr(&pmap_main_lock, LK_SHARED, (void *) 0)
#define PMAP_MAP_TO_HEAD_UNLOCK() \
- lockmgr(&pmap_main_lock, LK_RELEASE, (void *) 0)
+ spinlockmgr(&pmap_main_lock, LK_RELEASE, (void *) 0)
#define PMAP_HEAD_TO_MAP_LOCK() \
- lockmgr(&pmap_main_lock, LK_EXCLUSIVE, (void *) 0)
+ spinlockmgr(&pmap_main_lock, LK_EXCLUSIVE, (void *) 0)
#define PMAP_HEAD_TO_MAP_UNLOCK() \
- lockmgr(&pmap_main_lock, LK_RELEASE, (void *) 0)
+ spinlockmgr(&pmap_main_lock, LK_RELEASE, (void *) 0)
#else
@@ -431,8 +418,6 @@
/*
* pmap_tmpmap_pa: map a page in for tmp usage
- *
- * => returns with pmap_tmpptp_lock held
*/
__inline static vaddr_t
@@ -449,8 +434,6 @@
/*
* pmap_tmpunmap_pa: unmap a tmp use page (undoes pmap_tmpmap_pa)
- *
- * => we release pmap_tmpptp_lock
*/
__inline static void
@@ -462,7 +445,6 @@
* pmap_tmpmap_pvepte: get a quick mapping of a PTE for a pv_entry
*
* => do NOT use this on kernel mappings [why? because pv_ptp may be NULL]
- * => we may grab pmap_tmpptp_lock and return with it held
*/
__inline static pt_entry_t *
@@ -484,8 +466,6 @@
/*
* pmap_tmpunmap_pvepte: release a mapping obtained with pmap_tmpmap_pvepte
- *
- * => we will release pmap_tmpptp_lock if we hold it
*/
__inline static void
@@ -782,12 +762,9 @@
*/
#if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
- lockinit(&pmap_main_lock, PVM, "pmaplk", 0, 0);
+ spinlockinit(&pmap_main_lock, "pmaplk", 0);
simple_lock_init(&pvalloc_lock);
simple_lock_init(&pmaps_lock);
- simple_lock_init(&pmap_copy_page_lock);
- simple_lock_init(&pmap_zero_page_lock);
- simple_lock_init(&pmap_tmpptp_lock);
#endif
LIST_INIT(&pmaps);
TAILQ_INIT(&pv_freepages);
@@ -1092,13 +1069,6 @@
}
}
- /*
- * done! if we didn't get a pv then we panic :(
- */
-
- if (pv == NULL)
- panic("pmap_alloc_pvpage");
-
return(pv);
}
@@ -1444,6 +1414,9 @@
if (just_try)
return(NULL);
ptp = pmap_steal_ptp(&pmap->pm_obj, ptp_i2o(pde_index));
+ if (ptp == NULL) {
+ return (NULL);
+ }
/* stole one; zero it. */
pmap_zero_page(VM_PAGE_TO_PHYS(ptp));
}
@@ -1476,21 +1449,26 @@
{
struct vm_page *ptp = NULL;
struct pmap *firstpmap;
+ struct uvm_object *curobj;
+ pt_entry_t *ptes;
int idx, lcv;
- pt_entry_t *ptes;
+ boolean_t caller_locked, we_locked;
simple_lock(&pmaps_lock);
-
if (pmaps_hand == NULL)
- pmaps_hand = pmaps.lh_first;
-
+ pmaps_hand = LIST_FIRST(&pmaps);
firstpmap = pmaps_hand;
- if (firstpmap == NULL)
- panic("pmap_steal_ptp: no pmaps to steal from!");
do { /* while we haven't looped back around to firstpmap */
- if (simple_lock_try(&pmaps_hand->pm_obj.vmobjlock)) {
- ptp = pmaps_hand->pm_obj.memq.tqh_first;
+
+ curobj = &pmaps_hand->pm_obj;
+ we_locked = FALSE;
+ caller_locked = (curobj == obj);
+ if (!caller_locked) {
+ we_locked = simple_lock_try(&curobj->vmobjlock);
+ }
+ if (caller_locked || we_locked) {
+ ptp = curobj->memq.tqh_first;
for (/*null*/; ptp != NULL; ptp = ptp->listq.tqe_next) {
/*
@@ -1499,9 +1477,11 @@
*/
idx = ptp_o2i(ptp->offset);
+#ifdef DIAGNOSTIC
if (VM_PAGE_TO_PHYS(ptp) !=
(pmaps_hand->pm_pdir[idx] & PG_FRAME))
panic("pmap_steal_ptp: PTP mismatch!");
+#endif
ptes = (pt_entry_t *)
pmap_tmpmap_pa(VM_PAGE_TO_PHYS(ptp));
@@ -1539,20 +1519,20 @@
uvm_pagerealloc(ptp, obj, offset);
break; /* break out of "for" loop */
}
- simple_unlock(&pmaps_hand->pm_obj.vmobjlock);
+ if (we_locked) {
+ simple_unlock(&curobj->vmobjlock);
+ }
}
/* advance the pmaps_hand */
- pmaps_hand = pmaps_hand->pm_list.le_next;
- if (pmaps_hand == NULL)
- pmaps_hand = pmaps.lh_first;
+ pmaps_hand = LIST_NEXT(pmaps_hand, pm_list);
+ if (pmaps_hand == NULL) {
+ pmaps_hand = LIST_FIRST(&pmaps);
+ }
} while (ptp == NULL && pmaps_hand != firstpmap);
simple_unlock(&pmaps_lock);
- if (ptp == NULL)
- panic("pmap_steal_ptp: failed to steal a PTP!");
-
return(ptp);
}
@@ -1580,8 +1560,10 @@
return(pmap->pm_ptphint);
ptp = uvm_pagelookup(&pmap->pm_obj, ptp_i2o(pde_index));
+#ifdef DIAGNOSTIC
if (ptp == NULL)
panic("pmap_get_ptp: unmanaged user PTP");
+#endif
pmap->pm_ptphint = ptp;
return(ptp);
}
@@ -1634,8 +1616,8 @@
pmap->pm_pdir = (pd_entry_t *) uvm_km_alloc(kernel_map, NBPG);
if (pmap->pm_pdir == NULL)
panic("pmap_pinit: kernel_map out of virtual space!");
- pmap_extract(pmap_kernel(), (vaddr_t)pmap->pm_pdir,
- (paddr_t *)&pmap->pm_pdirpa);
+ (void) pmap_extract(pmap_kernel(), (vaddr_t)pmap->pm_pdir,
+ (paddr_t *)&pmap->pm_pdirpa);
/* init PDP */
/* zero init area */
@@ -1657,8 +1639,6 @@
memset(&pmap->pm_pdir[PDSLOT_KERN + nkpde], 0,
NBPG - ((PDSLOT_KERN + nkpde) * sizeof(pd_entry_t)));
LIST_INSERT_HEAD(&pmaps, pmap, pm_list);
- if (pmaps_hand == NULL)
- pmaps_hand = pmap;
simple_unlock(&pmaps_lock);
}
@@ -1713,7 +1693,7 @@
simple_lock(&pmaps_lock);
if (pmap == pmaps_hand)
- pmaps_hand = pmaps_hand->pm_list.le_next;
+ pmaps_hand = LIST_NEXT(pmaps_hand, pm_list);
LIST_REMOVE(pmap, pm_list);
simple_unlock(&pmaps_lock);
@@ -1723,8 +1703,10 @@
while (pmap->pm_obj.memq.tqh_first != NULL) {
pg = pmap->pm_obj.memq.tqh_first;
+#ifdef DIAGNOSTIC
if (pg->flags & PG_BUSY)
panic("pmap_release: busy page table page");
+#endif
/* pmap_page_protect? currently no need for it. */
pg->wire_count = 0;
@@ -1964,9 +1946,11 @@
}
bank = vm_physseg_find(sh3_btop(opte & PG_FRAME), &off);
+#ifdef DIAGNOSTIC
if (bank == -1)
panic("pmap_remove_ptes: unmanaged page marked "
"PG_PVLIST");
+#endif
/* sync R/M bits */
simple_lock(&vm_physmem[bank].pmseg.pvhead[off].pvh_lock);
@@ -2038,8 +2022,10 @@
}
bank = vm_physseg_find(sh3_btop(opte & PG_FRAME), &off);
+#ifdef DIAGNOSTIC
if (bank == -1)
panic("pmap_remove_pte: unmanaged page marked PG_PVLIST");
+#endif
/* sync R/M bits */
simple_lock(&vm_physmem[bank].pmseg.pvhead[off].pvh_lock);
@@ -2100,9 +2086,11 @@
ptp = pmap->pm_ptphint;
} else {
ptp = PHYS_TO_VM_PAGE(ptppa);
+#ifdef DIAGNOSTIC
if (ptp == NULL)
panic("pmap_remove: unmanaged "
"PTP detected");
+#endif
}
}
@@ -2188,9 +2176,11 @@
ptp = pmap->pm_ptphint;
} else {
ptp = PHYS_TO_VM_PAGE(ptppa);
+#ifdef DIAGNOSTIC
if (ptp == NULL)
panic("pmap_remove: unmanaged PTP "
"detected");
+#endif
}
}
pmap_remove_ptes(pmap, prr, ptp,
@@ -2284,8 +2274,9 @@
pve->pv_pmap->pm_stats.wired_count--;
pve->pv_pmap->pm_stats.resident_count--;
Home |
Main Index |
Thread Index |
Old Index