vm_meter.c (108551) | vm_meter.c (108585) |
---|---|
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 108551 2003-01-02 09:09:27Z alc $ | 34 * $FreeBSD: head/sys/vm/vm_meter.c 108585 2003-01-03 05:52:02Z 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> --- 104 unchanged lines hidden (view full) --- 147 } 148 } 149 } 150 mtx_unlock_spin(&sched_lock); 151 /* 152 * Note active objects. 153 */ 154 paging = 0; | 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> --- 104 unchanged lines hidden (view full) --- 147 } 148 } 149 } 150 mtx_unlock_spin(&sched_lock); 151 /* 152 * Note active objects. 153 */ 154 paging = 0; |
155 for (map = &p->p_vmspace->vm_map, entry = map->header.next; | 155 map = &p->p_vmspace->vm_map; 156 vm_map_lock_read(map); 157 for (entry = map->header.next; |
156 entry != &map->header; entry = entry->next) { 157 if ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) || | 158 entry != &map->header; entry = entry->next) { 159 if ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) || |
158 entry->object.vm_object == NULL) | 160 (object = entry->object.vm_object) == NULL) |
159 continue; | 161 continue; |
160 vm_object_set_flag(entry->object.vm_object, OBJ_ACTIVE); 161 paging |= entry->object.vm_object->paging_in_progress; | 162 vm_object_lock(object); 163 vm_object_set_flag(object, OBJ_ACTIVE); 164 paging |= object->paging_in_progress; 165 vm_object_unlock(object); |
162 } | 166 } |
167 vm_map_unlock_read(map); |
|
163 if (paging) 164 totalp->t_pw++; 165 } 166 sx_sunlock(&allproc_lock); 167 /* 168 * Calculate object memory usage statistics. 169 */ 170 mtx_lock(&vm_object_list_mtx); 171 TAILQ_FOREACH(object, &vm_object_list, object_list) { | 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); |
|
172 /* 173 * devices, like /dev/mem, will badly skew our totals 174 */ | 178 /* 179 * devices, like /dev/mem, will badly skew our totals 180 */ |
175 if (object->type == OBJT_DEVICE) | 181 if (object->type == OBJT_DEVICE) { 182 vm_object_unlock(object); |
176 continue; | 183 continue; |
184 } |
|
177 totalp->t_vm += object->size; 178 totalp->t_rm += object->resident_page_count; 179 if (object->flags & OBJ_ACTIVE) { 180 totalp->t_avm += object->size; 181 totalp->t_arm += object->resident_page_count; 182 } 183 if (object->shadow_count > 1) { 184 /* shared object */ 185 totalp->t_vmshr += object->size; 186 totalp->t_rmshr += object->resident_page_count; 187 if (object->flags & OBJ_ACTIVE) { 188 totalp->t_avmshr += object->size; 189 totalp->t_armshr += object->resident_page_count; 190 } 191 } | 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); |
|
192 } 193 mtx_unlock(&vm_object_list_mtx); 194 totalp->t_free = cnt.v_free_count + cnt.v_cache_count; 195 return (sysctl_handle_opaque(oidp, totalp, sizeof total, req)); 196} 197 198/* 199 * 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 --- |