diff options
author | avg <avg@FreeBSD.org> | 2012-05-23 12:51:49 +0000 |
---|---|---|
committer | avg <avg@FreeBSD.org> | 2012-05-23 12:51:49 +0000 |
commit | ea96526248e89c13c464597f4973614e622c1e5c (patch) | |
tree | cf2d60d400042727d224a2bf4626c9535cc52379 /sys/vm/vm_pager.c | |
parent | 25827ad38231373971b6f50b964c0996497ad3b3 (diff) | |
download | FreeBSD-src-ea96526248e89c13c464597f4973614e622c1e5c.zip FreeBSD-src-ea96526248e89c13c464597f4973614e622c1e5c.tar.gz |
vm_pager_object_lookup: small performance optimization
do not needlessly lock an object if its handle doesn't match
Reviewed by: kib, alc
MFC after: 1 week
Diffstat (limited to 'sys/vm/vm_pager.c')
-rw-r--r-- | sys/vm/vm_pager.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c index 8c652e2..6ed64ea 100644 --- a/sys/vm/vm_pager.c +++ b/sys/vm/vm_pager.c @@ -271,14 +271,15 @@ vm_pager_object_lookup(struct pagerlst *pg_list, void *handle) vm_object_t object; TAILQ_FOREACH(object, pg_list, pager_object_list) { - VM_OBJECT_LOCK(object); - if (object->handle == handle && - (object->flags & OBJ_DEAD) == 0) { - vm_object_reference_locked(object); + if (object->handle == handle) { + VM_OBJECT_LOCK(object); + if ((object->flags & OBJ_DEAD) == 0) { + vm_object_reference_locked(object); + VM_OBJECT_UNLOCK(object); + break; + } VM_OBJECT_UNLOCK(object); - break; } - VM_OBJECT_UNLOCK(object); } return (object); } |