1 /*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 1982, 1986, 1989, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. Neither the name of the University nor the names of its contributors 16 * may be used to endorse or promote products derived from this software 17 * without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 * 31 * @(#)vm_meter.c 8.4 (Berkeley) 1/4/94 32 */ 33 34 #include <sys/cdefs.h> 35 __FBSDID("$FreeBSD$"); 36 37 #include <sys/param.h> 38 #include <sys/systm.h> 39 #include <sys/kernel.h> 40 #include <sys/lock.h> 41 #include <sys/malloc.h> 42 #include <sys/mutex.h> 43 #include <sys/proc.h> 44 #include <sys/resource.h> 45 #include <sys/rwlock.h> 46 #include <sys/sx.h> 47 #include <sys/vmmeter.h> 48 #include <sys/smp.h> 49 50 #include <vm/vm.h> 51 #include <vm/vm_page.h> 52 #include <vm/vm_extern.h> 53 #include <vm/vm_param.h> 54 #include <vm/vm_phys.h> 55 #include <vm/vm_pagequeue.h> 56 #include <vm/pmap.h> 57 #include <vm/vm_map.h> 58 #include <vm/vm_object.h> 59 #include <sys/sysctl.h> 60 61 struct vmmeter __read_mostly vm_cnt = { 62 .v_swtch = EARLY_COUNTER, 63 .v_trap = EARLY_COUNTER, 64 .v_syscall = EARLY_COUNTER, 65 .v_intr = EARLY_COUNTER, 66 .v_soft = EARLY_COUNTER, 67 .v_vm_faults = EARLY_COUNTER, 68 .v_io_faults = EARLY_COUNTER, 69 .v_cow_faults = EARLY_COUNTER, 70 .v_cow_optim = EARLY_COUNTER, 71 .v_zfod = EARLY_COUNTER, 72 .v_ozfod = EARLY_COUNTER, 73 .v_swapin = EARLY_COUNTER, 74 .v_swapout = EARLY_COUNTER, 75 .v_swappgsin = EARLY_COUNTER, 76 .v_swappgsout = EARLY_COUNTER, 77 .v_vnodein = EARLY_COUNTER, 78 .v_vnodeout = EARLY_COUNTER, 79 .v_vnodepgsin = EARLY_COUNTER, 80 .v_vnodepgsout = EARLY_COUNTER, 81 .v_intrans = EARLY_COUNTER, 82 .v_reactivated = EARLY_COUNTER, 83 .v_pdwakeups = EARLY_COUNTER, 84 .v_pdpages = EARLY_COUNTER, 85 .v_pdshortfalls = EARLY_COUNTER, 86 .v_dfree = EARLY_COUNTER, 87 .v_pfree = EARLY_COUNTER, 88 .v_tfree = EARLY_COUNTER, 89 .v_forks = EARLY_COUNTER, 90 .v_vforks = EARLY_COUNTER, 91 .v_rforks = EARLY_COUNTER, 92 .v_kthreads = EARLY_COUNTER, 93 .v_forkpages = EARLY_COUNTER, 94 .v_vforkpages = EARLY_COUNTER, 95 .v_rforkpages = EARLY_COUNTER, 96 .v_kthreadpages = EARLY_COUNTER, 97 .v_wire_count = EARLY_COUNTER, 98 }; 99 100 u_long __exclusive_cache_line vm_user_wire_count; 101 102 static void 103 vmcounter_startup(void) 104 { 105 counter_u64_t *cnt = (counter_u64_t *)&vm_cnt; 106 107 COUNTER_ARRAY_ALLOC(cnt, VM_METER_NCOUNTERS, M_WAITOK); 108 } 109 SYSINIT(counter, SI_SUB_KMEM, SI_ORDER_FIRST, vmcounter_startup, NULL); 110 111 SYSCTL_UINT(_vm, VM_V_FREE_MIN, v_free_min, 112 CTLFLAG_RW, &vm_cnt.v_free_min, 0, "Minimum low-free-pages threshold"); 113 SYSCTL_UINT(_vm, VM_V_FREE_TARGET, v_free_target, 114 CTLFLAG_RW, &vm_cnt.v_free_target, 0, "Desired free pages"); 115 SYSCTL_UINT(_vm, VM_V_FREE_RESERVED, v_free_reserved, 116 CTLFLAG_RW, &vm_cnt.v_free_reserved, 0, "Pages reserved for deadlock"); 117 SYSCTL_UINT(_vm, VM_V_INACTIVE_TARGET, v_inactive_target, 118 CTLFLAG_RW, &vm_cnt.v_inactive_target, 0, "Pages desired inactive"); 119 SYSCTL_UINT(_vm, VM_V_PAGEOUT_FREE_MIN, v_pageout_free_min, 120 CTLFLAG_RW, &vm_cnt.v_pageout_free_min, 0, "Min pages reserved for kernel"); 121 SYSCTL_UINT(_vm, OID_AUTO, v_free_severe, 122 CTLFLAG_RW, &vm_cnt.v_free_severe, 0, "Severe page depletion point"); 123 124 static int 125 sysctl_vm_loadavg(SYSCTL_HANDLER_ARGS) 126 { 127 128 #ifdef SCTL_MASK32 129 uint32_t la[4]; 130 131 if (req->flags & SCTL_MASK32) { 132 la[0] = averunnable.ldavg[0]; 133 la[1] = averunnable.ldavg[1]; 134 la[2] = averunnable.ldavg[2]; 135 la[3] = averunnable.fscale; 136 return SYSCTL_OUT(req, la, sizeof(la)); 137 } else 138 #endif 139 return SYSCTL_OUT(req, &averunnable, sizeof(averunnable)); 140 } 141 SYSCTL_PROC(_vm, VM_LOADAVG, loadavg, CTLTYPE_STRUCT | CTLFLAG_RD | 142 CTLFLAG_MPSAFE, NULL, 0, sysctl_vm_loadavg, "S,loadavg", 143 "Machine loadaverage history"); 144 145 #if defined(COMPAT_FREEBSD11) 146 struct vmtotal11 { 147 int16_t t_rq; 148 int16_t t_dw; 149 int16_t t_pw; 150 int16_t t_sl; 151 int16_t t_sw; 152 int32_t t_vm; 153 int32_t t_avm; 154 int32_t t_rm; 155 int32_t t_arm; 156 int32_t t_vmshr; 157 int32_t t_avmshr; 158 int32_t t_rmshr; 159 int32_t t_armshr; 160 int32_t t_free; 161 }; 162 #endif 163 164 static int 165 vmtotal(SYSCTL_HANDLER_ARGS) 166 { 167 struct vmtotal total; 168 #if defined(COMPAT_FREEBSD11) 169 struct vmtotal11 total11; 170 #endif 171 vm_object_t object; 172 struct proc *p; 173 struct thread *td; 174 175 if (req->oldptr == NULL) { 176 #if defined(COMPAT_FREEBSD11) 177 if (curproc->p_osrel < P_OSREL_VMTOTAL64) 178 return (SYSCTL_OUT(req, NULL, sizeof(total11))); 179 #endif 180 return (SYSCTL_OUT(req, NULL, sizeof(total))); 181 } 182 bzero(&total, sizeof(total)); 183 184 /* 185 * Calculate process statistics. 186 */ 187 sx_slock(&allproc_lock); 188 FOREACH_PROC_IN_SYSTEM(p) { 189 if ((p->p_flag & P_SYSTEM) != 0) 190 continue; 191 PROC_LOCK(p); 192 if (p->p_state != PRS_NEW) { 193 FOREACH_THREAD_IN_PROC(p, td) { 194 thread_lock(td); 195 switch (TD_GET_STATE(td)) { 196 case TDS_INHIBITED: 197 if (TD_IS_SWAPPED(td)) 198 total.t_sw++; 199 else if (TD_IS_SLEEPING(td)) { 200 if (td->td_priority <= PZERO) 201 total.t_dw++; 202 else 203 total.t_sl++; 204 } 205 break; 206 case TDS_CAN_RUN: 207 total.t_sw++; 208 break; 209 case TDS_RUNQ: 210 case TDS_RUNNING: 211 total.t_rq++; 212 break; 213 default: 214 break; 215 } 216 thread_unlock(td); 217 } 218 } 219 PROC_UNLOCK(p); 220 } 221 sx_sunlock(&allproc_lock); 222 /* 223 * Calculate object memory usage statistics. 224 */ 225 mtx_lock(&vm_object_list_mtx); 226 TAILQ_FOREACH(object, &vm_object_list, object_list) { 227 /* 228 * Perform unsynchronized reads on the object. In 229 * this case, the lack of synchronization should not 230 * impair the accuracy of the reported statistics. 231 */ 232 if ((object->flags & OBJ_FICTITIOUS) != 0) { 233 /* 234 * Devices, like /dev/mem, will badly skew our totals. 235 */ 236 continue; 237 } 238 if (object->ref_count == 0) { 239 /* 240 * Also skip unreferenced objects, including 241 * vnodes representing mounted file systems. 242 */ 243 continue; 244 } 245 if (object->ref_count == 1 && 246 (object->flags & (OBJ_ANON | OBJ_SWAP)) == OBJ_SWAP) { 247 /* 248 * Also skip otherwise unreferenced swap 249 * objects backing tmpfs vnodes, and POSIX or 250 * SysV shared memory. 251 */ 252 continue; 253 } 254 total.t_vm += object->size; 255 total.t_rm += object->resident_page_count; 256 if (vm_object_is_active(object)) { 257 total.t_avm += object->size; 258 total.t_arm += object->resident_page_count; 259 } 260 if (object->shadow_count > 1) { 261 /* shared object */ 262 total.t_vmshr += object->size; 263 total.t_rmshr += object->resident_page_count; 264 if (vm_object_is_active(object)) { 265 total.t_avmshr += object->size; 266 total.t_armshr += object->resident_page_count; 267 } 268 } 269 } 270 mtx_unlock(&vm_object_list_mtx); 271 total.t_pw = vm_wait_count(); 272 total.t_free = vm_free_count(); 273 #if defined(COMPAT_FREEBSD11) 274 /* sysctl(8) allocates twice as much memory as reported by sysctl(3) */ 275 if (curproc->p_osrel < P_OSREL_VMTOTAL64 && (req->oldlen == 276 sizeof(total11) || req->oldlen == 2 * sizeof(total11))) { 277 bzero(&total11, sizeof(total11)); 278 total11.t_rq = total.t_rq; 279 total11.t_dw = total.t_dw; 280 total11.t_pw = total.t_pw; 281 total11.t_sl = total.t_sl; 282 total11.t_sw = total.t_sw; 283 total11.t_vm = total.t_vm; /* truncate */ 284 total11.t_avm = total.t_avm; /* truncate */ 285 total11.t_rm = total.t_rm; /* truncate */ 286 total11.t_arm = total.t_arm; /* truncate */ 287 total11.t_vmshr = total.t_vmshr; /* truncate */ 288 total11.t_avmshr = total.t_avmshr; /* truncate */ 289 total11.t_rmshr = total.t_rmshr; /* truncate */ 290 total11.t_armshr = total.t_armshr; /* truncate */ 291 total11.t_free = total.t_free; /* truncate */ 292 return (SYSCTL_OUT(req, &total11, sizeof(total11))); 293 } 294 #endif 295 return (SYSCTL_OUT(req, &total, sizeof(total))); 296 } 297 298 SYSCTL_PROC(_vm, VM_TOTAL, vmtotal, CTLTYPE_OPAQUE | CTLFLAG_RD | 299 CTLFLAG_MPSAFE, NULL, 0, vmtotal, "S,vmtotal", 300 "System virtual memory statistics"); 301 SYSCTL_NODE(_vm, OID_AUTO, stats, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 302 "VM meter stats"); 303 static SYSCTL_NODE(_vm_stats, OID_AUTO, sys, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 304 "VM meter sys stats"); 305 static SYSCTL_NODE(_vm_stats, OID_AUTO, vm, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 306 "VM meter vm stats"); 307 SYSCTL_NODE(_vm_stats, OID_AUTO, misc, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 308 "VM meter misc stats"); 309 310 static int 311 sysctl_handle_vmstat(SYSCTL_HANDLER_ARGS) 312 { 313 uint64_t val; 314 #ifdef COMPAT_FREEBSD11 315 uint32_t val32; 316 #endif 317 318 val = counter_u64_fetch(*(counter_u64_t *)arg1); 319 #ifdef COMPAT_FREEBSD11 320 if (req->oldlen == sizeof(val32)) { 321 val32 = val; /* truncate */ 322 return (SYSCTL_OUT(req, &val32, sizeof(val32))); 323 } 324 #endif 325 return (SYSCTL_OUT(req, &val, sizeof(val))); 326 } 327 328 #define VM_STATS(parent, var, descr) \ 329 SYSCTL_OID(parent, OID_AUTO, var, CTLTYPE_U64 | CTLFLAG_MPSAFE | \ 330 CTLFLAG_RD, &vm_cnt.var, 0, sysctl_handle_vmstat, "QU", descr) 331 #define VM_STATS_VM(var, descr) VM_STATS(_vm_stats_vm, var, descr) 332 #define VM_STATS_SYS(var, descr) VM_STATS(_vm_stats_sys, var, descr) 333 334 VM_STATS_SYS(v_swtch, "Context switches"); 335 VM_STATS_SYS(v_trap, "Traps"); 336 VM_STATS_SYS(v_syscall, "System calls"); 337 VM_STATS_SYS(v_intr, "Device interrupts"); 338 VM_STATS_SYS(v_soft, "Software interrupts"); 339 VM_STATS_VM(v_vm_faults, "Address memory faults"); 340 VM_STATS_VM(v_io_faults, "Page faults requiring I/O"); 341 VM_STATS_VM(v_cow_faults, "Copy-on-write faults"); 342 VM_STATS_VM(v_cow_optim, "Optimized COW faults"); 343 VM_STATS_VM(v_zfod, "Pages zero-filled on demand"); 344 VM_STATS_VM(v_ozfod, "Optimized zero fill pages"); 345 VM_STATS_VM(v_swapin, "Swap pager pageins"); 346 VM_STATS_VM(v_swapout, "Swap pager pageouts"); 347 VM_STATS_VM(v_swappgsin, "Swap pages swapped in"); 348 VM_STATS_VM(v_swappgsout, "Swap pages swapped out"); 349 VM_STATS_VM(v_vnodein, "Vnode pager pageins"); 350 VM_STATS_VM(v_vnodeout, "Vnode pager pageouts"); 351 VM_STATS_VM(v_vnodepgsin, "Vnode pages paged in"); 352 VM_STATS_VM(v_vnodepgsout, "Vnode pages paged out"); 353 VM_STATS_VM(v_intrans, "In transit page faults"); 354 VM_STATS_VM(v_reactivated, "Pages reactivated by pagedaemon"); 355 VM_STATS_VM(v_pdwakeups, "Pagedaemon wakeups"); 356 VM_STATS_VM(v_pdshortfalls, "Page reclamation shortfalls"); 357 VM_STATS_VM(v_dfree, "Pages freed by pagedaemon"); 358 VM_STATS_VM(v_pfree, "Pages freed by exiting processes"); 359 VM_STATS_VM(v_tfree, "Total pages freed"); 360 VM_STATS_VM(v_forks, "Number of fork() calls"); 361 VM_STATS_VM(v_vforks, "Number of vfork() calls"); 362 VM_STATS_VM(v_rforks, "Number of rfork() calls"); 363 VM_STATS_VM(v_kthreads, "Number of fork() calls by kernel"); 364 VM_STATS_VM(v_forkpages, "VM pages affected by fork()"); 365 VM_STATS_VM(v_vforkpages, "VM pages affected by vfork()"); 366 VM_STATS_VM(v_rforkpages, "VM pages affected by rfork()"); 367 VM_STATS_VM(v_kthreadpages, "VM pages affected by fork() by kernel"); 368 369 static int 370 sysctl_handle_vmstat_proc(SYSCTL_HANDLER_ARGS) 371 { 372 u_int (*fn)(void); 373 uint32_t val; 374 375 fn = arg1; 376 val = fn(); 377 return (SYSCTL_OUT(req, &val, sizeof(val))); 378 } 379 380 #define VM_STATS_PROC(var, descr, fn) \ 381 SYSCTL_OID(_vm_stats_vm, OID_AUTO, var, CTLTYPE_U32 | CTLFLAG_MPSAFE | \ 382 CTLFLAG_RD, fn, 0, sysctl_handle_vmstat_proc, "IU", descr) 383 384 #define VM_STATS_UINT(var, descr) \ 385 SYSCTL_UINT(_vm_stats_vm, OID_AUTO, var, CTLFLAG_RD, &vm_cnt.var, 0, descr) 386 #define VM_STATS_ULONG(var, descr) \ 387 SYSCTL_ULONG(_vm_stats_vm, OID_AUTO, var, CTLFLAG_RD, &vm_cnt.var, 0, descr) 388 389 VM_STATS_UINT(v_page_size, "Page size in bytes"); 390 VM_STATS_UINT(v_page_count, "Total number of pages in system"); 391 VM_STATS_UINT(v_free_reserved, "Pages reserved for deadlock"); 392 VM_STATS_UINT(v_free_target, "Pages desired free"); 393 VM_STATS_UINT(v_free_min, "Minimum low-free-pages threshold"); 394 VM_STATS_PROC(v_free_count, "Free pages", vm_free_count); 395 VM_STATS_PROC(v_wire_count, "Wired pages", vm_wire_count); 396 VM_STATS_PROC(v_active_count, "Active pages", vm_active_count); 397 VM_STATS_UINT(v_inactive_target, "Desired inactive pages"); 398 VM_STATS_PROC(v_inactive_count, "Inactive pages", vm_inactive_count); 399 VM_STATS_PROC(v_laundry_count, "Pages eligible for laundering", 400 vm_laundry_count); 401 VM_STATS_UINT(v_pageout_free_min, "Min pages reserved for kernel"); 402 VM_STATS_UINT(v_interrupt_free_min, "Reserved pages for interrupt code"); 403 VM_STATS_UINT(v_free_severe, "Severe page depletion point"); 404 405 SYSCTL_ULONG(_vm_stats_vm, OID_AUTO, v_user_wire_count, CTLFLAG_RD, 406 &vm_user_wire_count, 0, "User-wired virtual memory"); 407 408 #ifdef COMPAT_FREEBSD11 409 /* 410 * Provide compatibility sysctls for the benefit of old utilities which exit 411 * with an error if they cannot be found. 412 */ 413 SYSCTL_UINT(_vm_stats_vm, OID_AUTO, v_cache_count, CTLFLAG_RD, 414 SYSCTL_NULL_UINT_PTR, 0, "Dummy for compatibility"); 415 SYSCTL_UINT(_vm_stats_vm, OID_AUTO, v_tcached, CTLFLAG_RD, 416 SYSCTL_NULL_UINT_PTR, 0, "Dummy for compatibility"); 417 #endif 418 419 u_int 420 vm_free_count(void) 421 { 422 u_int v; 423 int i; 424 425 v = 0; 426 for (i = 0; i < vm_ndomains; i++) 427 v += vm_dom[i].vmd_free_count; 428 429 return (v); 430 } 431 432 static u_int 433 vm_pagequeue_count(int pq) 434 { 435 u_int v; 436 int i; 437 438 v = 0; 439 for (i = 0; i < vm_ndomains; i++) 440 v += vm_dom[i].vmd_pagequeues[pq].pq_cnt; 441 442 return (v); 443 } 444 445 u_int 446 vm_active_count(void) 447 { 448 449 return (vm_pagequeue_count(PQ_ACTIVE)); 450 } 451 452 u_int 453 vm_inactive_count(void) 454 { 455 456 return (vm_pagequeue_count(PQ_INACTIVE)); 457 } 458 459 u_int 460 vm_laundry_count(void) 461 { 462 463 return (vm_pagequeue_count(PQ_LAUNDRY)); 464 } 465 466 static int 467 sysctl_vm_pdpages(SYSCTL_HANDLER_ARGS) 468 { 469 struct vm_pagequeue *pq; 470 uint64_t ret; 471 int dom, i; 472 473 ret = counter_u64_fetch(vm_cnt.v_pdpages); 474 for (dom = 0; dom < vm_ndomains; dom++) 475 for (i = 0; i < PQ_COUNT; i++) { 476 pq = &VM_DOMAIN(dom)->vmd_pagequeues[i]; 477 ret += pq->pq_pdpages; 478 } 479 return (SYSCTL_OUT(req, &ret, sizeof(ret))); 480 } 481 SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_pdpages, 482 CTLTYPE_U64 | CTLFLAG_MPSAFE | CTLFLAG_RD, NULL, 0, sysctl_vm_pdpages, "QU", 483 "Pages analyzed by pagedaemon"); 484 485 static void 486 vm_domain_stats_init(struct vm_domain *vmd, struct sysctl_oid *parent) 487 { 488 struct sysctl_oid *oid; 489 490 vmd->vmd_oid = SYSCTL_ADD_NODE(NULL, SYSCTL_CHILDREN(parent), OID_AUTO, 491 vmd->vmd_name, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, ""); 492 oid = SYSCTL_ADD_NODE(NULL, SYSCTL_CHILDREN(vmd->vmd_oid), OID_AUTO, 493 "stats", CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, ""); 494 SYSCTL_ADD_UINT(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, 495 "free_count", CTLFLAG_RD, &vmd->vmd_free_count, 0, 496 "Free pages"); 497 SYSCTL_ADD_UINT(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, 498 "active", CTLFLAG_RD, &vmd->vmd_pagequeues[PQ_ACTIVE].pq_cnt, 0, 499 "Active pages"); 500 SYSCTL_ADD_U64(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, 501 "actpdpgs", CTLFLAG_RD, 502 &vmd->vmd_pagequeues[PQ_ACTIVE].pq_pdpages, 0, 503 "Active pages scanned by the page daemon"); 504 SYSCTL_ADD_UINT(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, 505 "inactive", CTLFLAG_RD, &vmd->vmd_pagequeues[PQ_INACTIVE].pq_cnt, 0, 506 "Inactive pages"); 507 SYSCTL_ADD_U64(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, 508 "inactpdpgs", CTLFLAG_RD, 509 &vmd->vmd_pagequeues[PQ_INACTIVE].pq_pdpages, 0, 510 "Inactive pages scanned by the page daemon"); 511 SYSCTL_ADD_UINT(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, 512 "laundry", CTLFLAG_RD, &vmd->vmd_pagequeues[PQ_LAUNDRY].pq_cnt, 0, 513 "laundry pages"); 514 SYSCTL_ADD_U64(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, 515 "laundpdpgs", CTLFLAG_RD, 516 &vmd->vmd_pagequeues[PQ_LAUNDRY].pq_pdpages, 0, 517 "Laundry pages scanned by the page daemon"); 518 SYSCTL_ADD_UINT(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, "unswappable", 519 CTLFLAG_RD, &vmd->vmd_pagequeues[PQ_UNSWAPPABLE].pq_cnt, 0, 520 "Unswappable pages"); 521 SYSCTL_ADD_U64(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, 522 "unswppdpgs", CTLFLAG_RD, 523 &vmd->vmd_pagequeues[PQ_UNSWAPPABLE].pq_pdpages, 0, 524 "Unswappable pages scanned by the page daemon"); 525 SYSCTL_ADD_UINT(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, 526 "inactive_target", CTLFLAG_RD, &vmd->vmd_inactive_target, 0, 527 "Target inactive pages"); 528 SYSCTL_ADD_UINT(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, 529 "free_target", CTLFLAG_RD, &vmd->vmd_free_target, 0, 530 "Target free pages"); 531 SYSCTL_ADD_UINT(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, 532 "free_reserved", CTLFLAG_RD, &vmd->vmd_free_reserved, 0, 533 "Reserved free pages"); 534 SYSCTL_ADD_UINT(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, 535 "free_min", CTLFLAG_RD, &vmd->vmd_free_min, 0, 536 "Minimum free pages"); 537 SYSCTL_ADD_UINT(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, 538 "free_severe", CTLFLAG_RD, &vmd->vmd_free_severe, 0, 539 "Severe free pages"); 540 SYSCTL_ADD_UINT(NULL, SYSCTL_CHILDREN(oid), OID_AUTO, 541 "inactive_pps", CTLFLAG_RD, &vmd->vmd_inactive_pps, 0, 542 "inactive pages freed/second"); 543 544 } 545 546 static void 547 vm_stats_init(void *arg __unused) 548 { 549 struct sysctl_oid *oid; 550 int i; 551 552 oid = SYSCTL_ADD_NODE(NULL, SYSCTL_STATIC_CHILDREN(_vm), OID_AUTO, 553 "domain", CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, ""); 554 for (i = 0; i < vm_ndomains; i++) 555 vm_domain_stats_init(VM_DOMAIN(i), oid); 556 } 557 558 SYSINIT(vmstats_init, SI_SUB_VM_CONF, SI_ORDER_FIRST, vm_stats_init, NULL); 559