diff options
-rw-r--r-- | sys/vm/vm_map.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 8ea43b6..38fe0e2 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -363,15 +363,16 @@ vmspace_swap_count(struct vmspace *vmspace) vm_object_t object; if ((cur->eflags & MAP_ENTRY_IS_SUB_MAP) == 0 && - (object = cur->object.vm_object) != NULL && - object->type == OBJT_SWAP - ) { - int n = (cur->end - cur->start) / PAGE_SIZE; + (object = cur->object.vm_object) != NULL) { + VM_OBJECT_LOCK(object); + if (object->type == OBJT_SWAP && + object->un_pager.swp.swp_bcount != 0) { + int n = (cur->end - cur->start) / PAGE_SIZE; - if (object->un_pager.swp.swp_bcount) { count += object->un_pager.swp.swp_bcount * SWAP_META_PAGES * n / object->size + 1; } + VM_OBJECT_UNLOCK(object); } } return (count); |