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 --- 16 unchanged lines hidden (view full) --- 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)vm_meter.c 8.4 (Berkeley) 1/4/94 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/vm/vm_meter.c 263620 2014-03-22 10:26:09Z bdrewery $"); |
34 35#include <sys/param.h> 36#include <sys/systm.h> 37#include <sys/kernel.h> 38#include <sys/lock.h> 39#include <sys/mutex.h> 40#include <sys/proc.h> 41#include <sys/resource.h> --- 6 unchanged lines hidden (view full) --- 48#include <vm/vm_page.h> 49#include <vm/vm_extern.h> 50#include <vm/vm_param.h> 51#include <vm/pmap.h> 52#include <vm/vm_map.h> 53#include <vm/vm_object.h> 54#include <sys/sysctl.h> 55 |
56struct vmmeter vm_cnt; |
57 58SYSCTL_UINT(_vm, VM_V_FREE_MIN, v_free_min, |
59 CTLFLAG_RW, &vm_cnt.v_free_min, 0, "Minimum low-free-pages threshold"); |
60SYSCTL_UINT(_vm, VM_V_FREE_TARGET, v_free_target, |
61 CTLFLAG_RW, &vm_cnt.v_free_target, 0, "Desired free pages"); |
62SYSCTL_UINT(_vm, VM_V_FREE_RESERVED, v_free_reserved, |
63 CTLFLAG_RW, &vm_cnt.v_free_reserved, 0, "Pages reserved for deadlock"); |
64SYSCTL_UINT(_vm, VM_V_INACTIVE_TARGET, v_inactive_target, |
65 CTLFLAG_RW, &vm_cnt.v_inactive_target, 0, "Pages desired inactive"); |
66SYSCTL_UINT(_vm, VM_V_CACHE_MIN, v_cache_min, |
67 CTLFLAG_RW, &vm_cnt.v_cache_min, 0, "Min pages on cache queue"); |
68SYSCTL_UINT(_vm, VM_V_CACHE_MAX, v_cache_max, |
69 CTLFLAG_RW, &vm_cnt.v_cache_max, 0, "Max pages on cache queue"); |
70SYSCTL_UINT(_vm, VM_V_PAGEOUT_FREE_MIN, v_pageout_free_min, |
71 CTLFLAG_RW, &vm_cnt.v_pageout_free_min, 0, "Min pages reserved for kernel"); |
72SYSCTL_UINT(_vm, OID_AUTO, v_free_severe, |
73 CTLFLAG_RW, &vm_cnt.v_free_severe, 0, "Severe page depletion point"); |
74 75static int 76sysctl_vm_loadavg(SYSCTL_HANDLER_ARGS) 77{ 78 79#ifdef SCTL_MASK32 80 u_int32_t la[4]; 81 --- 144 unchanged lines hidden (view full) --- 226 total.t_rmshr += object->resident_page_count; 227 if (object->flags & OBJ_ACTIVE) { 228 total.t_avmshr += object->size; 229 total.t_armshr += object->resident_page_count; 230 } 231 } 232 } 233 mtx_unlock(&vm_object_list_mtx); |
234 total.t_free = vm_cnt.v_free_count + vm_cnt.v_cache_count; |
235 return (sysctl_handle_opaque(oidp, &total, sizeof(total), req)); 236} 237 238/* 239 * vcnt() - accumulate statistics from all cpus and the global cnt 240 * structure. 241 * 242 * The vmmeter structure is now per-cpu as well as global. Those 243 * statistics which can be kept on a per-cpu basis (to avoid cache 244 * stalls between cpus) can be moved to the per-cpu vmmeter. Remaining 245 * statistics, such as v_free_reserved, are left in the global 246 * structure. 247 * 248 * (sysctl_oid *oidp, void *arg1, int arg2, struct sysctl_req *req) 249 */ 250static int 251vcnt(SYSCTL_HANDLER_ARGS) 252{ 253 int count = *(int *)arg1; |
254 int offset = (char *)arg1 - (char *)&vm_cnt; |
255 int i; 256 257 CPU_FOREACH(i) { 258 struct pcpu *pcpu = pcpu_find(i); 259 count += *(int *)((char *)&pcpu->pc_cnt + offset); 260 } 261 return (SYSCTL_OUT(req, &count, sizeof(int))); 262} --- 5 unchanged lines hidden (view full) --- 268static SYSCTL_NODE(_vm_stats, OID_AUTO, sys, CTLFLAG_RW, 0, 269 "VM meter sys stats"); 270static SYSCTL_NODE(_vm_stats, OID_AUTO, vm, CTLFLAG_RW, 0, 271 "VM meter vm stats"); 272SYSCTL_NODE(_vm_stats, OID_AUTO, misc, CTLFLAG_RW, 0, "VM meter misc stats"); 273 274#define VM_STATS(parent, var, descr) \ 275 SYSCTL_PROC(parent, OID_AUTO, var, \ |
276 CTLTYPE_UINT | CTLFLAG_RD | CTLFLAG_MPSAFE, &vm_cnt.var, 0, vcnt, \ |
277 "IU", descr) 278#define VM_STATS_VM(var, descr) VM_STATS(_vm_stats_vm, var, descr) 279#define VM_STATS_SYS(var, descr) VM_STATS(_vm_stats_sys, var, descr) 280 281VM_STATS_SYS(v_swtch, "Context switches"); 282VM_STATS_SYS(v_trap, "Traps"); 283VM_STATS_SYS(v_syscall, "System calls"); 284VM_STATS_SYS(v_intr, "Device interrupts"); --- 49 unchanged lines hidden --- |