From 8ba20a48bd70ea00df3b2c827e3acc1b427bf547 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Wed, 30 Apr 2003 00:43:17 +0000 Subject: [PATCH] Add vm_object locking to vmspace_swap_count(). --- sys/vm/vm_map.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 8ea43b6d0403..38fe0e216fde 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);