summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2003-04-19 21:15:44 +0000
committeralc <alc@FreeBSD.org>2003-04-19 21:15:44 +0000
commitef4e8a19cfc9fb054dbda2b5efdaef60ef82438c (patch)
tree1252eafc53a186512ad8520018edf2e4e5639731 /sys
parentd558a7a53b5bf20f012c13da1c784b62854e09b1 (diff)
downloadFreeBSD-src-ef4e8a19cfc9fb054dbda2b5efdaef60ef82438c.zip
FreeBSD-src-ef4e8a19cfc9fb054dbda2b5efdaef60ef82438c.tar.gz
- Lock the vm_object when performing vm_object_pip_wakeupn().
- Assert that the vm_object lock is held in vm_object_pip_wakeupn(). - Add a new macro VM_OBJECT_LOCK_ASSERT().
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/vfs_bio.c7
-rw-r--r--sys/vm/swap_pager.c5
-rw-r--r--sys/vm/vm_object.c1
-rw-r--r--sys/vm/vm_object.h2
4 files changed, 13 insertions, 2 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 6893c8a..4125781 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -3193,8 +3193,11 @@ bufdone(struct buf *bp)
iosize -= resid;
}
vm_page_unlock_queues();
- if (obj)
+ if (obj != NULL) {
+ VM_OBJECT_LOCK(obj);
vm_object_pip_wakeupn(obj, 0);
+ VM_OBJECT_UNLOCK(obj);
+ }
}
/*
@@ -3231,6 +3234,7 @@ vfs_unbusy_pages(struct buf * bp)
vm_object_t obj;
obj = bp->b_object;
+ VM_OBJECT_LOCK(obj);
vm_page_lock_queues();
for (i = 0; i < bp->b_npages; i++) {
vm_page_t m = bp->b_pages[i];
@@ -3249,6 +3253,7 @@ vfs_unbusy_pages(struct buf * bp)
}
vm_page_unlock_queues();
vm_object_pip_wakeupn(obj, 0);
+ VM_OBJECT_UNLOCK(obj);
}
}
diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c
index 0fb5d22..997e682 100644
--- a/sys/vm/swap_pager.c
+++ b/sys/vm/swap_pager.c
@@ -1613,8 +1613,11 @@ swp_pager_async_iodone(bp)
* adjust pip. NOTE: the original parent may still have its own
* pip refs on the object.
*/
- if (object)
+ if (object != NULL) {
+ VM_OBJECT_LOCK(object);
vm_object_pip_wakeupn(object, bp->b_npages);
+ VM_OBJECT_UNLOCK(object);
+ }
/*
* release the physical I/O buffer
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
index a079d83..4f784b0 100644
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -296,6 +296,7 @@ void
vm_object_pip_wakeupn(vm_object_t object, short i)
{
GIANT_REQUIRED;
+ VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
if (i)
object->paging_in_progress -= i;
if ((object->flags & OBJ_PIPWNT) && object->paging_in_progress == 0) {
diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h
index 4f4f77b..9dd0ab9 100644
--- a/sys/vm/vm_object.h
+++ b/sys/vm/vm_object.h
@@ -171,6 +171,8 @@ extern vm_object_t kernel_object; /* the single kernel object */
extern vm_object_t kmem_object;
#define VM_OBJECT_LOCK(object) mtx_lock(&(object)->mtx)
+#define VM_OBJECT_LOCK_ASSERT(object, type) \
+ mtx_assert(&(object)->mtx, (type))
#define VM_OBJECT_UNLOCK(object) mtx_unlock(&(object)->mtx)
#define vm_object_lock(object) \
OpenPOWER on IntegriCloud