Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/yamt-pagecache]: src/sys/arch/x86 share a lock among pmap uobjs
details: https://anonhg.NetBSD.org/src/rev/1654c83c6c78
branches: yamt-pagecache
changeset: 770833:1654c83c6c78
user: yamt <yamt%NetBSD.org@localhost>
date: Fri Nov 18 00:51:28 2011 +0000
description:
share a lock among pmap uobjs
diffstat:
sys/arch/x86/include/pmap.h | 9 +++------
sys/arch/x86/x86/pmap.c | 39 +++++++--------------------------------
2 files changed, 10 insertions(+), 38 deletions(-)
diffs (142 lines):
diff -r aed02cdc29eb -r 1654c83c6c78 sys/arch/x86/include/pmap.h
--- a/sys/arch/x86/include/pmap.h Mon Nov 14 14:24:54 2011 +0000
+++ b/sys/arch/x86/include/pmap.h Fri Nov 18 00:51:28 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.43.2.1 2011/11/10 14:31:43 yamt Exp $ */
+/* $NetBSD: pmap.h,v 1.43.2.2 2011/11/18 00:51:28 yamt Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -130,9 +130,7 @@
* note that the pm_obj contains the lock pointer, the reference count,
* page list, and number of PTPs within the pmap.
*
- * pm_lock is the same as the lock for vm object 0. Changes to
- * the other objects may only be made if that lock has been taken
- * (the other object locks are only used when uvm_pagealloc is called)
+ * pm_lock is shared among vm objects.
*
* XXX If we ever support processor numbers higher than 31, we'll have
* XXX to rethink the CPU mask.
@@ -140,8 +138,7 @@
struct pmap {
struct uvm_object pm_obj[PTP_LEVELS-1]; /* objects for lvl >= 1) */
-#define pm_lock pm_obj[0].vmobjlock
- kmutex_t pm_obj_lock[PTP_LEVELS-1]; /* locks for pm_objs */
+ kmutex_t pm_lock[1]; /* lock for pm_objs */
LIST_ENTRY(pmap) pm_list; /* list (lck by pm_list lock) */
pd_entry_t *pm_pdir; /* VA of PD (lck by object lock) */
paddr_t pm_pdirpa[PDP_SIZE]; /* PA of PDs (read-only after create) */
diff -r aed02cdc29eb -r 1654c83c6c78 sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c Mon Nov 14 14:24:54 2011 +0000
+++ b/sys/arch/x86/x86/pmap.c Fri Nov 18 00:51:28 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.137.2.3 2011/11/10 14:32:36 yamt Exp $ */
+/* $NetBSD: pmap.c,v 1.137.2.4 2011/11/18 00:51:28 yamt Exp $ */
/*-
* Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
@@ -171,7 +171,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.137.2.3 2011/11/10 14:32:36 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.137.2.4 2011/11/18 00:51:28 yamt Exp $");
#include "opt_user_ldt.h"
#include "opt_lockdebug.h"
@@ -324,24 +324,6 @@
static vaddr_t pmap_maxkvaddr;
/*
- * XXX kludge: dummy locking to make KASSERTs in uvm_page.c comfortable.
- * actual locking is done by pm_lock.
- */
-#if defined(DIAGNOSTIC)
-#define PMAP_SUBOBJ_LOCK(pm, idx) \
- KASSERT(mutex_owned((pm)->pm_lock)); \
- if ((idx) != 0) \
- mutex_enter((pm)->pm_obj[(idx)].vmobjlock)
-#define PMAP_SUBOBJ_UNLOCK(pm, idx) \
- KASSERT(mutex_owned((pm)->pm_lock)); \
- if ((idx) != 0) \
- mutex_exit((pm)->pm_obj[(idx)].vmobjlock)
-#else /* defined(DIAGNOSTIC) */
-#define PMAP_SUBOBJ_LOCK(pm, idx) /* nothing */
-#define PMAP_SUBOBJ_UNLOCK(pm, idx) /* nothing */
-#endif /* defined(DIAGNOSTIC) */
-
-/*
* Misc. event counters.
*/
struct evcnt pmap_iobmp_evcnt;
@@ -1224,10 +1206,10 @@
*/
kpm = pmap_kernel();
+ mutex_init(kpm->pm_lock, MUTEX_DEFAULT, IPL_NONE);
for (i = 0; i < PTP_LEVELS - 1; i++) {
- mutex_init(&kpm->pm_obj_lock[i], MUTEX_DEFAULT, IPL_NONE);
uvm_obj_init(&kpm->pm_obj[i], NULL, false, 1);
- uvm_obj_setlock(&kpm->pm_obj[i], &kpm->pm_obj_lock[i]);
+ uvm_obj_setlock(&kpm->pm_obj[i], kpm->pm_lock);
kpm->pm_ptphint[i] = NULL;
}
memset(&kpm->pm_list, 0, sizeof(kpm->pm_list)); /* pm_list not used */
@@ -1781,10 +1763,7 @@
pa == VM_PAGE_TO_PHYS(pmap->pm_ptphint[lidx])) {
return (pmap->pm_ptphint[lidx]);
}
- PMAP_SUBOBJ_LOCK(pmap, lidx);
pg = uvm_pagelookup(&pmap->pm_obj[lidx], ptp_va2o(va, level));
- PMAP_SUBOBJ_UNLOCK(pmap, lidx);
-
KASSERT(pg == NULL || pg->wire_count >= 1);
return pg;
}
@@ -1944,7 +1923,6 @@
obj = &pmap->pm_obj[i-2];
l = curlwp;
- PMAP_SUBOBJ_LOCK(pmap, i - 2);
ncsw = l->l_ncsw;
ptp = uvm_pagealloc(obj, ptp_va2o(va, i - 1), NULL,
UVM_PGA_USERESERVE|UVM_PGA_ZERO);
@@ -1957,13 +1935,10 @@
if (ptp != NULL) {
uvm_pagefree(ptp);
}
- PMAP_SUBOBJ_UNLOCK(pmap, i - 2);
/* XXX shut up the assertion in pmap_unmap_ptes */
pmap->pm_ncsw = l->l_ncsw;
return EAGAIN;
}
- PMAP_SUBOBJ_UNLOCK(pmap, i - 2);
-
if (ptp == NULL)
return ENOMEM;
@@ -2218,10 +2193,10 @@
pmap = pool_cache_get(&pmap_cache, PR_WAITOK);
/* init uvm_object */
+ mutex_init(pmap->pm_lock, MUTEX_DEFAULT, IPL_NONE);
for (i = 0; i < PTP_LEVELS - 1; i++) {
- mutex_init(&pmap->pm_obj_lock[i], MUTEX_DEFAULT, IPL_NONE);
uvm_obj_init(&pmap->pm_obj[i], NULL, false, 1);
- uvm_obj_setlock(&pmap->pm_obj[i], &pmap->pm_obj_lock[i]);
+ uvm_obj_setlock(&pmap->pm_obj[i], pmap->pm_lock);
pmap->pm_ptphint[i] = NULL;
}
pmap->pm_stats.wired_count = 0;
@@ -2393,8 +2368,8 @@
for (i = 0; i < PTP_LEVELS - 1; i++) {
uvm_obj_destroy(&pmap->pm_obj[i], false);
- mutex_destroy(&pmap->pm_obj_lock[i]);
}
+ mutex_destroy(pmap->pm_lock);
pool_cache_put(&pmap_cache, pmap);
}
Home |
Main Index |
Thread Index |
Old Index