Deleted Added
sdiff udiff text old ( 108551 ) new ( 108585 )
full compact
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 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;
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);
163 vm_object_set_flag(object, OBJ_ACTIVE);
164 paging |= object->paging_in_progress;
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) {
177 vm_object_lock(object);
178 /*
179 * devices, like /dev/mem, will badly skew our totals
180 */
181 if (object->type == OBJT_DEVICE) {
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 }
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 ---