vm_meter.c (109097) | vm_meter.c (113448) |
---|---|
1/* 2 * Copyright (c) 1982, 1986, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)vm_meter.c 8.4 (Berkeley) 1/4/94 | 1/* 2 * Copyright (c) 1982, 1986, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)vm_meter.c 8.4 (Berkeley) 1/4/94 |
34 * $FreeBSD: head/sys/vm/vm_meter.c 109097 2003-01-11 07:29:47Z dillon $ | 34 * $FreeBSD: head/sys/vm/vm_meter.c 113448 2003-04-13 19:36:18Z alc $ |
35 */ 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/kernel.h> 40#include <sys/lock.h> 41#include <sys/mutex.h> 42#include <sys/proc.h> --- 50 unchanged lines hidden (view full) --- 93 totalp = &total; 94 bzero(totalp, sizeof *totalp); 95 /* 96 * Mark all objects as inactive. 97 */ 98 GIANT_REQUIRED; 99 mtx_lock(&vm_object_list_mtx); 100 TAILQ_FOREACH(object, &vm_object_list, object_list) { | 35 */ 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/kernel.h> 40#include <sys/lock.h> 41#include <sys/mutex.h> 42#include <sys/proc.h> --- 50 unchanged lines hidden (view full) --- 93 totalp = &total; 94 bzero(totalp, sizeof *totalp); 95 /* 96 * Mark all objects as inactive. 97 */ 98 GIANT_REQUIRED; 99 mtx_lock(&vm_object_list_mtx); 100 TAILQ_FOREACH(object, &vm_object_list, object_list) { |
101 vm_object_lock(object); | 101 VM_OBJECT_LOCK(object); |
102 vm_object_clear_flag(object, OBJ_ACTIVE); | 102 vm_object_clear_flag(object, OBJ_ACTIVE); |
103 vm_object_unlock(object); | 103 VM_OBJECT_UNLOCK(object); |
104 } 105 mtx_unlock(&vm_object_list_mtx); 106 /* 107 * Calculate process statistics. 108 */ 109 sx_slock(&allproc_lock); 110 FOREACH_PROC_IN_SYSTEM(p) { 111 if (p->p_flag & P_SYSTEM) --- 42 unchanged lines hidden (view full) --- 154 paging = 0; 155 map = &p->p_vmspace->vm_map; 156 vm_map_lock_read(map); 157 for (entry = map->header.next; 158 entry != &map->header; entry = entry->next) { 159 if ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) || 160 (object = entry->object.vm_object) == NULL) 161 continue; | 104 } 105 mtx_unlock(&vm_object_list_mtx); 106 /* 107 * Calculate process statistics. 108 */ 109 sx_slock(&allproc_lock); 110 FOREACH_PROC_IN_SYSTEM(p) { 111 if (p->p_flag & P_SYSTEM) --- 42 unchanged lines hidden (view full) --- 154 paging = 0; 155 map = &p->p_vmspace->vm_map; 156 vm_map_lock_read(map); 157 for (entry = map->header.next; 158 entry != &map->header; entry = entry->next) { 159 if ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) || 160 (object = entry->object.vm_object) == NULL) 161 continue; |
162 vm_object_lock(object); | 162 VM_OBJECT_LOCK(object); |
163 vm_object_set_flag(object, OBJ_ACTIVE); 164 paging |= object->paging_in_progress; | 163 vm_object_set_flag(object, OBJ_ACTIVE); 164 paging |= object->paging_in_progress; |
165 vm_object_unlock(object); | 165 VM_OBJECT_UNLOCK(object); |
166 } 167 vm_map_unlock_read(map); 168 if (paging) 169 totalp->t_pw++; 170 } 171 sx_sunlock(&allproc_lock); 172 /* 173 * Calculate object memory usage statistics. 174 */ 175 mtx_lock(&vm_object_list_mtx); 176 TAILQ_FOREACH(object, &vm_object_list, object_list) { | 166 } 167 vm_map_unlock_read(map); 168 if (paging) 169 totalp->t_pw++; 170 } 171 sx_sunlock(&allproc_lock); 172 /* 173 * Calculate object memory usage statistics. 174 */ 175 mtx_lock(&vm_object_list_mtx); 176 TAILQ_FOREACH(object, &vm_object_list, object_list) { |
177 vm_object_lock(object); | 177 VM_OBJECT_LOCK(object); |
178 /* 179 * devices, like /dev/mem, will badly skew our totals 180 */ 181 if (object->type == OBJT_DEVICE) { | 178 /* 179 * devices, like /dev/mem, will badly skew our totals 180 */ 181 if (object->type == OBJT_DEVICE) { |
182 vm_object_unlock(object); | 182 VM_OBJECT_UNLOCK(object); |
183 continue; 184 } 185 totalp->t_vm += object->size; 186 totalp->t_rm += object->resident_page_count; 187 if (object->flags & OBJ_ACTIVE) { 188 totalp->t_avm += object->size; 189 totalp->t_arm += object->resident_page_count; 190 } 191 if (object->shadow_count > 1) { 192 /* shared object */ 193 totalp->t_vmshr += object->size; 194 totalp->t_rmshr += object->resident_page_count; 195 if (object->flags & OBJ_ACTIVE) { 196 totalp->t_avmshr += object->size; 197 totalp->t_armshr += object->resident_page_count; 198 } 199 } | 183 continue; 184 } 185 totalp->t_vm += object->size; 186 totalp->t_rm += object->resident_page_count; 187 if (object->flags & OBJ_ACTIVE) { 188 totalp->t_avm += object->size; 189 totalp->t_arm += object->resident_page_count; 190 } 191 if (object->shadow_count > 1) { 192 /* shared object */ 193 totalp->t_vmshr += object->size; 194 totalp->t_rmshr += object->resident_page_count; 195 if (object->flags & OBJ_ACTIVE) { 196 totalp->t_avmshr += object->size; 197 totalp->t_armshr += object->resident_page_count; 198 } 199 } |
200 vm_object_unlock(object); | 200 VM_OBJECT_UNLOCK(object); |
201 } 202 mtx_unlock(&vm_object_list_mtx); 203 totalp->t_free = cnt.v_free_count + cnt.v_cache_count; 204 return (sysctl_handle_opaque(oidp, totalp, sizeof total, req)); 205} 206 207/* 208 * vcnt() - accumulate statistics from all cpus and the global cnt --- 148 unchanged lines hidden --- | 201 } 202 mtx_unlock(&vm_object_list_mtx); 203 totalp->t_free = cnt.v_free_count + cnt.v_cache_count; 204 return (sysctl_handle_opaque(oidp, totalp, sizeof total, req)); 205} 206 207/* 208 * vcnt() - accumulate statistics from all cpus and the global cnt --- 148 unchanged lines hidden --- |