summaryrefslogtreecommitdiffstats
path: root/sys/vm
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2003-01-03 05:52:02 +0000
committeralc <alc@FreeBSD.org>2003-01-03 05:52:02 +0000
commited9a027a4af44624e146aba2ff4c73032ea9e9ad (patch)
tree13d0e520274b7ff311908df0e68d4d39c4d1b41b /sys/vm
parentbfabff54fefc317170877a2d6fcaabd812fa6ffe (diff)
downloadFreeBSD-src-ed9a027a4af44624e146aba2ff4c73032ea9e9ad.zip
FreeBSD-src-ed9a027a4af44624e146aba2ff4c73032ea9e9ad.tar.gz
Add vm map and vm object locking to vmtotal().
Diffstat (limited to 'sys/vm')
-rw-r--r--sys/vm/vm_meter.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/sys/vm/vm_meter.c b/sys/vm/vm_meter.c
index 534644c..cc50d7f 100644
--- a/sys/vm/vm_meter.c
+++ b/sys/vm/vm_meter.c
@@ -152,14 +152,19 @@ vmtotal(SYSCTL_HANDLER_ARGS)
* Note active objects.
*/
paging = 0;
- for (map = &p->p_vmspace->vm_map, entry = map->header.next;
+ map = &p->p_vmspace->vm_map;
+ vm_map_lock_read(map);
+ for (entry = map->header.next;
entry != &map->header; entry = entry->next) {
if ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) ||
- entry->object.vm_object == NULL)
+ (object = entry->object.vm_object) == NULL)
continue;
- vm_object_set_flag(entry->object.vm_object, OBJ_ACTIVE);
- paging |= entry->object.vm_object->paging_in_progress;
+ vm_object_lock(object);
+ vm_object_set_flag(object, OBJ_ACTIVE);
+ paging |= object->paging_in_progress;
+ vm_object_unlock(object);
}
+ vm_map_unlock_read(map);
if (paging)
totalp->t_pw++;
}
@@ -169,11 +174,14 @@ vmtotal(SYSCTL_HANDLER_ARGS)
*/
mtx_lock(&vm_object_list_mtx);
TAILQ_FOREACH(object, &vm_object_list, object_list) {
+ vm_object_lock(object);
/*
* devices, like /dev/mem, will badly skew our totals
*/
- if (object->type == OBJT_DEVICE)
+ if (object->type == OBJT_DEVICE) {
+ vm_object_unlock(object);
continue;
+ }
totalp->t_vm += object->size;
totalp->t_rm += object->resident_page_count;
if (object->flags & OBJ_ACTIVE) {
@@ -189,6 +197,7 @@ vmtotal(SYSCTL_HANDLER_ARGS)
totalp->t_armshr += object->resident_page_count;
}
}
+ vm_object_unlock(object);
}
mtx_unlock(&vm_object_list_mtx);
totalp->t_free = cnt.v_free_count + cnt.v_cache_count;
OpenPOWER on IntegriCloud