From 059358675e33663d46950029853178e89172d145 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Fri, 25 Jul 2003 18:58:39 +0000 Subject: [PATCH] MFi386 revision 1.416 Add vm object locking to pmap_prefault(). Note: powerpc and sparc64 do not implement this function. --- sys/alpha/alpha/pmap.c | 17 ++++++++++------- sys/amd64/amd64/pmap.c | 17 ++++++++++------- sys/ia64/ia64/pmap.c | 17 ++++++++++------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/sys/alpha/alpha/pmap.c b/sys/alpha/alpha/pmap.c index 715a10e2d559..93671dada8bf 100644 --- a/sys/alpha/alpha/pmap.c +++ b/sys/alpha/alpha/pmap.c @@ -2130,7 +2130,7 @@ pmap_prefault(pmap, addra, entry) mpte = NULL; for (i = 0; i < PAGEORDER_SIZE; i++) { - vm_object_t lobject; + vm_object_t backing_object, lobject; pt_entry_t *pte; addr = addra + pmap_prefault_pageorder[i]; @@ -2150,15 +2150,18 @@ pmap_prefault(pmap, addra, entry) pindex = ((addr - entry->start) + entry->offset) >> PAGE_SHIFT; lobject = object; - for (m = vm_page_lookup(lobject, pindex); - (!m && (lobject->type == OBJT_DEFAULT) && (lobject->backing_object)); - lobject = lobject->backing_object) { + VM_OBJECT_LOCK(lobject); + while ((m = vm_page_lookup(lobject, pindex)) == NULL && + lobject->type == OBJT_DEFAULT && + (backing_object = lobject->backing_object) != NULL) { if (lobject->backing_object_offset & PAGE_MASK) break; - pindex += (lobject->backing_object_offset >> PAGE_SHIFT); - m = vm_page_lookup(lobject->backing_object, pindex); + pindex += lobject->backing_object_offset >> PAGE_SHIFT; + VM_OBJECT_LOCK(backing_object); + VM_OBJECT_UNLOCK(lobject); + lobject = backing_object; } - + VM_OBJECT_UNLOCK(lobject); /* * give-up when a page is not in memory */ diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 4faf8840b7ad..68bbc9e34cf5 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -2176,7 +2176,7 @@ pmap_prefault(pmap, addra, entry) mpte = NULL; for (i = 0; i < PAGEORDER_SIZE; i++) { - vm_object_t lobject; + vm_object_t backing_object, lobject; pt_entry_t *pte; addr = addra + pmap_prefault_pageorder[i]; @@ -2196,15 +2196,18 @@ pmap_prefault(pmap, addra, entry) pindex = ((addr - entry->start) + entry->offset) >> PAGE_SHIFT; lobject = object; - for (m = vm_page_lookup(lobject, pindex); - (!m && (lobject->type == OBJT_DEFAULT) && (lobject->backing_object)); - lobject = lobject->backing_object) { + VM_OBJECT_LOCK(lobject); + while ((m = vm_page_lookup(lobject, pindex)) == NULL && + lobject->type == OBJT_DEFAULT && + (backing_object = lobject->backing_object) != NULL) { if (lobject->backing_object_offset & PAGE_MASK) break; - pindex += (lobject->backing_object_offset >> PAGE_SHIFT); - m = vm_page_lookup(lobject->backing_object, pindex); + pindex += lobject->backing_object_offset >> PAGE_SHIFT; + VM_OBJECT_LOCK(backing_object); + VM_OBJECT_UNLOCK(lobject); + lobject = backing_object; } - + VM_OBJECT_UNLOCK(lobject); /* * give-up when a page is not in memory */ diff --git a/sys/ia64/ia64/pmap.c b/sys/ia64/ia64/pmap.c index 42204d74e322..5fedbf0dc59e 100644 --- a/sys/ia64/ia64/pmap.c +++ b/sys/ia64/ia64/pmap.c @@ -1811,7 +1811,7 @@ pmap_prefault(pmap, addra, entry) mpte = NULL; for (i = 0; i < PAGEORDER_SIZE; i++) { - vm_object_t lobject; + vm_object_t backing_object, lobject; struct ia64_lpte *pte; addr = addra + pmap_prefault_pageorder[i]; @@ -1827,15 +1827,18 @@ pmap_prefault(pmap, addra, entry) pindex = ((addr - entry->start) + entry->offset) >> PAGE_SHIFT; lobject = object; - for (m = vm_page_lookup(lobject, pindex); - (!m && (lobject->type == OBJT_DEFAULT) && (lobject->backing_object)); - lobject = lobject->backing_object) { + VM_OBJECT_LOCK(lobject); + while ((m = vm_page_lookup(lobject, pindex)) == NULL && + lobject->type == OBJT_DEFAULT && + (backing_object = lobject->backing_object) != NULL) { if (lobject->backing_object_offset & PAGE_MASK) break; - pindex += (lobject->backing_object_offset >> PAGE_SHIFT); - m = vm_page_lookup(lobject->backing_object, pindex); + pindex += lobject->backing_object_offset >> PAGE_SHIFT; + VM_OBJECT_LOCK(backing_object); + VM_OBJECT_UNLOCK(lobject); + lobject = backing_object; } - + VM_OBJECT_UNLOCK(lobject); /* * give-up when a page is not in memory */