Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/i386/i386 merge in a bit from the MP branch to cut ...
details: https://anonhg.NetBSD.org/src/rev/ada89b0a24d5
branches: trunk
changeset: 520043:ada89b0a24d5
user: chs <chs%NetBSD.org@localhost>
date: Tue Jan 01 22:52:11 2002 +0000
description:
merge in a bit from the MP branch to cut down on LOCKDEBUG spew:
Use optimistic locking in pmap_create() so that we don't lock against
ourself if allocating the page directory causes pmap_growkernel() to
be called.
diffstat:
sys/arch/i386/i386/pmap.c | 24 +++++++++++++++++-------
1 files changed, 17 insertions(+), 7 deletions(-)
diffs (70 lines):
diff -r 097723bd34b1 -r ada89b0a24d5 sys/arch/i386/i386/pmap.c
--- a/sys/arch/i386/i386/pmap.c Tue Jan 01 22:51:10 2002 +0000
+++ b/sys/arch/i386/i386/pmap.c Tue Jan 01 22:52:11 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.131 2001/11/15 07:03:30 lukem Exp $ */
+/* $NetBSD: pmap.c,v 1.132 2002/01/01 22:52:11 chs Exp $ */
/*
*
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.131 2001/11/15 07:03:30 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.132 2002/01/01 22:52:11 chs Exp $");
#include "opt_cputype.h"
#include "opt_user_ldt.h"
@@ -353,6 +353,7 @@
struct pool pmap_pdp_pool;
struct pool_cache pmap_pdp_cache;
+u_int pmap_pdp_cache_generation;
int pmap_pdp_ctor(void *, void *, int);
@@ -1452,6 +1453,7 @@
pmap_create()
{
struct pmap *pmap;
+ u_int gen;
pmap = pool_get(&pmap_pmap_pool, PR_WAITOK);
@@ -1479,15 +1481,21 @@
* malloc since malloc allocates out of a submap and we should
* have already allocated kernel PTPs to cover the range...
*
- * NOTE: WE MUST NOT BLOCK WHILE HOLDING THE `pmap_lock'!
+ * NOTE: WE MUST NOT BLOCK WHILE HOLDING THE `pmap_lock', nor
+ * must we call pmap_growkernel() while holding it!
*/
+ try_again:
+ gen = pmap_pdp_cache_generation;
+ pmap->pm_pdir = pool_cache_get(&pmap_pdp_cache, PR_WAITOK);
+
simple_lock(&pmaps_lock);
- /* XXX Need a generic "I want memory" wchan */
- while ((pmap->pm_pdir =
- pool_cache_get(&pmap_pdp_cache, PR_NOWAIT)) == NULL)
- (void) ltsleep(&lbolt, PVM, "pmapcr", hz >> 3, &pmaps_lock);
+ if (gen != pmap_pdp_cache_generation) {
+ simple_unlock(&pmaps_lock);
+ pool_cache_destruct_object(&pmap_pdp_cache, pmap->pm_pdir);
+ goto try_again;
+ }
pmap->pm_pdirpa = pmap->pm_pdir[PDSLOT_PTE] & PG_FRAME;
@@ -2993,6 +3001,8 @@
/* Invalidate the PDP cache. */
pool_cache_invalidate(&pmap_pdp_cache);
+ pmap_pdp_cache_generation++;
+
simple_unlock(&pmaps_lock);
}
Home |
Main Index |
Thread Index |
Old Index