diff options
author | alc <alc@FreeBSD.org> | 2002-04-30 21:24:47 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 2002-04-30 21:24:47 +0000 |
commit | 0e84366ae7583110f2684fcbdb18db042f76b8f8 (patch) | |
tree | c5f35bae8d320258ac37d8af8de09a74b4704a43 /sys | |
parent | 5ae616a5165c9c27092407c80d77d6e506af9777 (diff) | |
download | FreeBSD-src-0e84366ae7583110f2684fcbdb18db042f76b8f8.zip FreeBSD-src-0e84366ae7583110f2684fcbdb18db042f76b8f8.tar.gz |
o Convert the vm_page buckets mutex to a spin lock. (This resolves
an issue on the Alpha platform found by jeff@.)
o Simplify vm_page_lookup().
Reviewed by: jhb
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/subr_witness.c | 1 | ||||
-rw-r--r-- | sys/vm/vm_page.c | 25 |
2 files changed, 12 insertions, 14 deletions
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c index 8040787..59cf2ca 100644 --- a/sys/kern/subr_witness.c +++ b/sys/kern/subr_witness.c @@ -217,6 +217,7 @@ static struct witness_order_list_entry order_lists[] = { * leaf locks */ { "allpmaps", &lock_class_mtx_spin }, + { "vm page buckets mutex", &lock_class_mtx_spin }, { "icu", &lock_class_mtx_spin }, #ifdef SMP { "smp rendezvous", &lock_class_mtx_spin }, diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index 431ac70..d984e24 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -253,7 +253,7 @@ vm_page_startup(vm_offset_t starta, vm_offset_t enda, vm_offset_t vaddr) VM_PROT_READ | VM_PROT_WRITE); bzero((caddr_t) mapped, end - new_end); - mtx_init(&vm_page_buckets_mtx, "vm page buckets mutex", NULL, MTX_DEF); + mtx_init(&vm_page_buckets_mtx, "vm page buckets mutex", NULL, MTX_SPIN); vm_page_buckets = (struct vm_page **)mapped; bucket = vm_page_buckets; for (i = 0; i < vm_page_bucket_count; i++) { @@ -599,10 +599,10 @@ vm_page_insert(vm_page_t m, vm_object_t object, vm_pindex_t pindex) * Insert it into the object_object/offset hash table */ bucket = &vm_page_buckets[vm_page_hash(object, pindex)]; - mtx_lock(&vm_page_buckets_mtx); + mtx_lock_spin(&vm_page_buckets_mtx); m->hnext = *bucket; *bucket = m; - mtx_unlock(&vm_page_buckets_mtx); + mtx_unlock_spin(&vm_page_buckets_mtx); /* * Now link into the object's list of backed pages. @@ -662,7 +662,7 @@ vm_page_remove(vm_page_t m) * must be on the hash queue, we will panic if it isn't */ bucket = &vm_page_buckets[vm_page_hash(m->object, m->pindex)]; - mtx_lock(&vm_page_buckets_mtx); + mtx_lock_spin(&vm_page_buckets_mtx); while (*bucket != m) { if (*bucket == NULL) panic("vm_page_remove(): page not found in hash"); @@ -670,7 +670,7 @@ vm_page_remove(vm_page_t m) } *bucket = m->hnext; m->hnext = NULL; - mtx_unlock(&vm_page_buckets_mtx); + mtx_unlock_spin(&vm_page_buckets_mtx); /* * Now remove from the object's list of backed pages. @@ -706,15 +706,12 @@ vm_page_lookup(vm_object_t object, vm_pindex_t pindex) * Search the hash table for this object/offset pair */ bucket = &vm_page_buckets[vm_page_hash(object, pindex)]; - mtx_lock(&vm_page_buckets_mtx); - for (m = *bucket; m != NULL; m = m->hnext) { - if ((m->object == object) && (m->pindex == pindex)) { - mtx_unlock(&vm_page_buckets_mtx); - return (m); - } - } - mtx_unlock(&vm_page_buckets_mtx); - return (NULL); + mtx_lock_spin(&vm_page_buckets_mtx); + for (m = *bucket; m != NULL; m = m->hnext) + if (m->object == object && m->pindex == pindex) + break; + mtx_unlock_spin(&vm_page_buckets_mtx); + return (m); } /* |