FreeBSD virtual memory subsystem code
|
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/resource.h>
#include <sys/rwlock.h>
#include <sys/sx.h>
#include <sys/vmmeter.h>
#include <sys/smp.h>
#include <vm/vm.h>
#include <vm/vm_page.h>
#include <vm/vm_extern.h>
#include <vm/vm_param.h>
#include <vm/vm_phys.h>
#include <vm/vm_pagequeue.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
#include <vm/vm_object.h>
#include <sys/sysctl.h>
Go to the source code of this file.
Macros | |
#define | VM_STATS(parent, var, descr) |
#define | VM_STATS_VM(var, descr) VM_STATS(_vm_stats_vm, var, descr) |
#define | VM_STATS_SYS(var, descr) VM_STATS(_vm_stats_sys, var, descr) |
#define | VM_STATS_PROC(var, descr, fn) |
#define | VM_STATS_UINT(var, descr) SYSCTL_UINT(_vm_stats_vm, OID_AUTO, var, CTLFLAG_RD, &vm_cnt.var, 0, descr) |
#define | VM_STATS_ULONG(var, descr) SYSCTL_ULONG(_vm_stats_vm, OID_AUTO, var, CTLFLAG_RD, &vm_cnt.var, 0, descr) |
Functions | |
__FBSDID ("$FreeBSD$") | |
static void | vmcounter_startup (void) |
SYSINIT (counter, SI_SUB_KMEM, SI_ORDER_FIRST, vmcounter_startup, NULL) | |
SYSCTL_UINT (_vm, VM_V_FREE_MIN, v_free_min, CTLFLAG_RW, &vm_cnt.v_free_min, 0, "Minimum low-free-pages threshold") | |
SYSCTL_UINT (_vm, VM_V_FREE_TARGET, v_free_target, CTLFLAG_RW, &vm_cnt.v_free_target, 0, "Desired free pages") | |
SYSCTL_UINT (_vm, VM_V_FREE_RESERVED, v_free_reserved, CTLFLAG_RW, &vm_cnt.v_free_reserved, 0, "Pages reserved for deadlock") | |
SYSCTL_UINT (_vm, VM_V_INACTIVE_TARGET, v_inactive_target, CTLFLAG_RW, &vm_cnt.v_inactive_target, 0, "Pages desired inactive") | |
SYSCTL_UINT (_vm, VM_V_PAGEOUT_FREE_MIN, v_pageout_free_min, CTLFLAG_RW, &vm_cnt.v_pageout_free_min, 0, "Min pages reserved for kernel") | |
SYSCTL_UINT (_vm, OID_AUTO, v_free_severe, CTLFLAG_RW, &vm_cnt.v_free_severe, 0, "Severe page depletion point") | |
static int | sysctl_vm_loadavg (SYSCTL_HANDLER_ARGS) |
SYSCTL_PROC (_vm, VM_LOADAVG, loadavg, CTLTYPE_STRUCT|CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, 0, sysctl_vm_loadavg, "S,loadavg", "Machine loadaverage history") | |
static int | vmtotal (SYSCTL_HANDLER_ARGS) |
SYSCTL_PROC (_vm, VM_TOTAL, vmtotal, CTLTYPE_OPAQUE|CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, 0, vmtotal, "S,vmtotal", "System virtual memory statistics") | |
SYSCTL_NODE (_vm, OID_AUTO, stats, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "VM meter stats") | |
static | SYSCTL_NODE (_vm_stats, OID_AUTO, sys, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "VM meter sys stats") |
static | SYSCTL_NODE (_vm_stats, OID_AUTO, vm, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "VM meter vm stats") |
SYSCTL_NODE (_vm_stats, OID_AUTO, misc, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "VM meter misc stats") | |
static int | sysctl_handle_vmstat (SYSCTL_HANDLER_ARGS) |
VM_STATS_SYS (v_swtch, "Context switches") | |
VM_STATS_SYS (v_trap, "Traps") | |
VM_STATS_SYS (v_syscall, "System calls") | |
VM_STATS_SYS (v_intr, "Device interrupts") | |
VM_STATS_SYS (v_soft, "Software interrupts") | |
VM_STATS_VM (v_vm_faults, "Address memory faults") | |
VM_STATS_VM (v_io_faults, "Page faults requiring I/O") | |
VM_STATS_VM (v_cow_faults, "Copy-on-write faults") | |
VM_STATS_VM (v_cow_optim, "Optimized COW faults") | |
VM_STATS_VM (v_zfod, "Pages zero-filled on demand") | |
VM_STATS_VM (v_ozfod, "Optimized zero fill pages") | |
VM_STATS_VM (v_swapin, "Swap pager pageins") | |
VM_STATS_VM (v_swapout, "Swap pager pageouts") | |
VM_STATS_VM (v_swappgsin, "Swap pages swapped in") | |
VM_STATS_VM (v_swappgsout, "Swap pages swapped out") | |
VM_STATS_VM (v_vnodein, "Vnode pager pageins") | |
VM_STATS_VM (v_vnodeout, "Vnode pager pageouts") | |
VM_STATS_VM (v_vnodepgsin, "Vnode pages paged in") | |
VM_STATS_VM (v_vnodepgsout, "Vnode pages paged out") | |
VM_STATS_VM (v_intrans, "In transit page faults") | |
VM_STATS_VM (v_reactivated, "Pages reactivated by pagedaemon") | |
VM_STATS_VM (v_pdwakeups, "Pagedaemon wakeups") | |
VM_STATS_VM (v_pdshortfalls, "Page reclamation shortfalls") | |
VM_STATS_VM (v_dfree, "Pages freed by pagedaemon") | |
VM_STATS_VM (v_pfree, "Pages freed by exiting processes") | |
VM_STATS_VM (v_tfree, "Total pages freed") | |
VM_STATS_VM (v_forks, "Number of fork() calls") | |
VM_STATS_VM (v_vforks, "Number of vfork() calls") | |
VM_STATS_VM (v_rforks, "Number of rfork() calls") | |
VM_STATS_VM (v_kthreads, "Number of fork() calls by kernel") | |
VM_STATS_VM (v_forkpages, "VM pages affected by fork()") | |
VM_STATS_VM (v_vforkpages, "VM pages affected by vfork()") | |
VM_STATS_VM (v_rforkpages, "VM pages affected by rfork()") | |
VM_STATS_VM (v_kthreadpages, "VM pages affected by fork() by kernel") | |
static int | sysctl_handle_vmstat_proc (SYSCTL_HANDLER_ARGS) |
VM_STATS_UINT (v_page_size, "Page size in bytes") | |
VM_STATS_UINT (v_page_count, "Total number of pages in system") | |
VM_STATS_UINT (v_free_reserved, "Pages reserved for deadlock") | |
VM_STATS_UINT (v_free_target, "Pages desired free") | |
VM_STATS_UINT (v_free_min, "Minimum low-free-pages threshold") | |
VM_STATS_PROC (v_free_count, "Free pages", vm_free_count) | |
VM_STATS_PROC (v_wire_count, "Wired pages", vm_wire_count) | |
VM_STATS_PROC (v_active_count, "Active pages", vm_active_count) | |
VM_STATS_UINT (v_inactive_target, "Desired inactive pages") | |
VM_STATS_PROC (v_inactive_count, "Inactive pages", vm_inactive_count) | |
VM_STATS_PROC (v_laundry_count, "Pages eligible for laundering", vm_laundry_count) | |
VM_STATS_UINT (v_pageout_free_min, "Min pages reserved for kernel") | |
VM_STATS_UINT (v_interrupt_free_min, "Reserved pages for interrupt code") | |
VM_STATS_UINT (v_free_severe, "Severe page depletion point") | |
SYSCTL_ULONG (_vm_stats_vm, OID_AUTO, v_user_wire_count, CTLFLAG_RD, &vm_user_wire_count, 0, "User-wired virtual memory") | |
u_int | vm_free_count (void) |
static u_int | vm_pagequeue_count (int pq) |
u_int | vm_active_count (void) |
u_int | vm_inactive_count (void) |
u_int | vm_laundry_count (void) |
static int | sysctl_vm_pdpages (SYSCTL_HANDLER_ARGS) |
SYSCTL_PROC (_vm_stats_vm, OID_AUTO, v_pdpages, CTLTYPE_U64|CTLFLAG_MPSAFE|CTLFLAG_RD, NULL, 0, sysctl_vm_pdpages, "QU", "Pages analyzed by pagedaemon") | |
static void | vm_domain_stats_init (struct vm_domain *vmd, struct sysctl_oid *parent) |
static void | vm_stats_init (void *arg __unused) |
SYSINIT (vmstats_init, SI_SUB_VM_CONF, SI_ORDER_FIRST, vm_stats_init, NULL) | |
Variables | |
struct vmmeter __read_mostly | vm_cnt |
u_long __exclusive_cache_line | vm_user_wire_count |
#define VM_STATS | ( | parent, | |
var, | |||
descr | |||
) |
Definition at line 328 of file vm_meter.c.
#define VM_STATS_PROC | ( | var, | |
descr, | |||
fn | |||
) |
Definition at line 380 of file vm_meter.c.
#define VM_STATS_SYS | ( | var, | |
descr | |||
) | VM_STATS(_vm_stats_sys, var, descr) |
Definition at line 332 of file vm_meter.c.
#define VM_STATS_UINT | ( | var, | |
descr | |||
) | SYSCTL_UINT(_vm_stats_vm, OID_AUTO, var, CTLFLAG_RD, &vm_cnt.var, 0, descr) |
Definition at line 384 of file vm_meter.c.
#define VM_STATS_ULONG | ( | var, | |
descr | |||
) | SYSCTL_ULONG(_vm_stats_vm, OID_AUTO, var, CTLFLAG_RD, &vm_cnt.var, 0, descr) |
Definition at line 386 of file vm_meter.c.
#define VM_STATS_VM | ( | var, | |
descr | |||
) | VM_STATS(_vm_stats_vm, var, descr) |
Definition at line 331 of file vm_meter.c.
__FBSDID | ( | "$FreeBSD$" | ) |
|
static |
Definition at line 311 of file vm_meter.c.
|
static |
Definition at line 370 of file vm_meter.c.
SYSCTL_NODE | ( | _vm | , |
OID_AUTO | , | ||
stats | , | ||
CTLFLAG_RW| | CTLFLAG_MPSAFE, | ||
0 | , | ||
"VM meter stats" | |||
) |
SYSCTL_NODE | ( | _vm_stats | , |
OID_AUTO | , | ||
misc | , | ||
CTLFLAG_RW| | CTLFLAG_MPSAFE, | ||
0 | , | ||
"VM meter misc stats" | |||
) |
|
static |
|
static |
SYSCTL_PROC | ( | _vm | , |
VM_LOADAVG | , | ||
loadavg | , | ||
CTLTYPE_STRUCT|CTLFLAG_RD| | CTLFLAG_MPSAFE, | ||
NULL | , | ||
0 | , | ||
sysctl_vm_loadavg | , | ||
" | S, | ||
loadavg" | , | ||
"Machine loadaverage history" | |||
) |
SYSCTL_PROC | ( | _vm | , |
VM_TOTAL | , | ||
vmtotal | , | ||
CTLTYPE_OPAQUE|CTLFLAG_RD| | CTLFLAG_MPSAFE, | ||
NULL | , | ||
0 | , | ||
vmtotal | , | ||
" | S, | ||
vmtotal" | , | ||
"System virtual memory statistics" | |||
) |
SYSCTL_PROC | ( | _vm_stats_vm | , |
OID_AUTO | , | ||
v_pdpages | , | ||
CTLTYPE_U64|CTLFLAG_MPSAFE| | CTLFLAG_RD, | ||
NULL | , | ||
0 | , | ||
sysctl_vm_pdpages | , | ||
"QU" | , | ||
"Pages analyzed by pagedaemon" | |||
) |
SYSCTL_UINT | ( | _vm | , |
OID_AUTO | , | ||
v_free_severe | , | ||
CTLFLAG_RW | , | ||
&vm_cnt. | v_free_severe, | ||
0 | , | ||
"Severe page depletion point" | |||
) |
SYSCTL_UINT | ( | _vm | , |
VM_V_FREE_MIN | , | ||
v_free_min | , | ||
CTLFLAG_RW | , | ||
&vm_cnt. | v_free_min, | ||
0 | , | ||
"Minimum low-free-pages threshold" | |||
) |
SYSCTL_UINT | ( | _vm | , |
VM_V_FREE_RESERVED | , | ||
v_free_reserved | , | ||
CTLFLAG_RW | , | ||
&vm_cnt. | v_free_reserved, | ||
0 | , | ||
"Pages reserved for deadlock" | |||
) |
SYSCTL_UINT | ( | _vm | , |
VM_V_FREE_TARGET | , | ||
v_free_target | , | ||
CTLFLAG_RW | , | ||
&vm_cnt. | v_free_target, | ||
0 | , | ||
"Desired free pages" | |||
) |
SYSCTL_UINT | ( | _vm | , |
VM_V_INACTIVE_TARGET | , | ||
v_inactive_target | , | ||
CTLFLAG_RW | , | ||
&vm_cnt. | v_inactive_target, | ||
0 | , | ||
"Pages desired inactive" | |||
) |
SYSCTL_UINT | ( | _vm | , |
VM_V_PAGEOUT_FREE_MIN | , | ||
v_pageout_free_min | , | ||
CTLFLAG_RW | , | ||
&vm_cnt. | v_pageout_free_min, | ||
0 | , | ||
"Min pages reserved for kernel" | |||
) |
SYSCTL_ULONG | ( | _vm_stats_vm | , |
OID_AUTO | , | ||
v_user_wire_count | , | ||
CTLFLAG_RD | , | ||
& | vm_user_wire_count, | ||
0 | , | ||
"User-wired virtual memory" | |||
) |
|
static |
Definition at line 125 of file vm_meter.c.
|
static |
Definition at line 467 of file vm_meter.c.
References PQ_COUNT, vm_pagequeue::pq_pdpages, vm_cnt, VM_DOMAIN, and vm_ndomains.
SYSINIT | ( | counter | , |
SI_SUB_KMEM | , | ||
SI_ORDER_FIRST | , | ||
vmcounter_startup | , | ||
NULL | |||
) |
SYSINIT | ( | vmstats_init | , |
SI_SUB_VM_CONF | , | ||
SI_ORDER_FIRST | , | ||
vm_stats_init | , | ||
NULL | |||
) |
u_int vm_active_count | ( | void | ) |
Definition at line 446 of file vm_meter.c.
References PQ_ACTIVE, and vm_pagequeue_count().
|
static |
Definition at line 486 of file vm_meter.c.
References PQ_ACTIVE, vm_pagequeue::pq_cnt, PQ_INACTIVE, PQ_LAUNDRY, vm_pagequeue::pq_pdpages, PQ_UNSWAPPABLE, vm_domain::vmd_free_min, vm_domain::vmd_free_reserved, vm_domain::vmd_free_severe, vm_domain::vmd_free_target, vm_domain::vmd_inactive_pps, vm_domain::vmd_inactive_target, vm_domain::vmd_name, vm_domain::vmd_oid, and vm_domain::vmd_pagequeues.
Referenced by vm_stats_init().
u_int vm_free_count | ( | void | ) |
Definition at line 420 of file vm_meter.c.
References vm_dom, and vm_ndomains.
Referenced by swapoff_one(), and vmtotal().
u_int vm_inactive_count | ( | void | ) |
Definition at line 453 of file vm_meter.c.
References PQ_INACTIVE, and vm_pagequeue_count().
u_int vm_laundry_count | ( | void | ) |
Definition at line 460 of file vm_meter.c.
References PQ_LAUNDRY, and vm_pagequeue_count().
|
static |
Definition at line 433 of file vm_meter.c.
References pq_cnt, vm_dom, vm_ndomains, and vmd_pagequeues.
Referenced by vm_active_count(), vm_inactive_count(), and vm_laundry_count().
|
static |
Definition at line 547 of file vm_meter.c.
References VM_DOMAIN, vm_domain_stats_init(), and vm_ndomains.
VM_STATS_PROC | ( | v_active_count | , |
"Active pages" | , | ||
vm_active_count | |||
) |
VM_STATS_PROC | ( | v_free_count | , |
"Free pages" | , | ||
vm_free_count | |||
) |
VM_STATS_PROC | ( | v_inactive_count | , |
"Inactive pages" | , | ||
vm_inactive_count | |||
) |
VM_STATS_PROC | ( | v_laundry_count | , |
"Pages eligible for laundering" | , | ||
vm_laundry_count | |||
) |
VM_STATS_PROC | ( | v_wire_count | , |
"Wired pages" | , | ||
vm_wire_count | |||
) |
VM_STATS_SYS | ( | v_intr | , |
"Device interrupts" | |||
) |
VM_STATS_SYS | ( | v_soft | , |
"Software interrupts" | |||
) |
VM_STATS_SYS | ( | v_swtch | , |
"Context switches" | |||
) |
VM_STATS_SYS | ( | v_syscall | , |
"System calls" | |||
) |
VM_STATS_SYS | ( | v_trap | , |
"Traps" | |||
) |
VM_STATS_UINT | ( | v_free_min | , |
"Minimum low-free-pages threshold" | |||
) |
VM_STATS_UINT | ( | v_free_reserved | , |
"Pages reserved for deadlock" | |||
) |
VM_STATS_UINT | ( | v_free_severe | , |
"Severe page depletion point" | |||
) |
VM_STATS_UINT | ( | v_free_target | , |
"Pages desired free" | |||
) |
VM_STATS_UINT | ( | v_inactive_target | , |
"Desired inactive pages" | |||
) |
VM_STATS_UINT | ( | v_interrupt_free_min | , |
"Reserved pages for interrupt code" | |||
) |
VM_STATS_UINT | ( | v_page_count | , |
"Total number of pages in system" | |||
) |
VM_STATS_UINT | ( | v_page_size | , |
"Page size in bytes" | |||
) |
VM_STATS_UINT | ( | v_pageout_free_min | , |
"Min pages reserved for kernel" | |||
) |
VM_STATS_VM | ( | v_cow_faults | , |
"Copy-on-write faults" | |||
) |
VM_STATS_VM | ( | v_cow_optim | , |
"Optimized COW faults" | |||
) |
VM_STATS_VM | ( | v_dfree | , |
"Pages freed by pagedaemon" | |||
) |
VM_STATS_VM | ( | v_forkpages | , |
"VM pages affected by fork()" | |||
) |
VM_STATS_VM | ( | v_forks | , |
"Number of fork() calls" | |||
) |
VM_STATS_VM | ( | v_intrans | , |
"In transit page faults" | |||
) |
VM_STATS_VM | ( | v_io_faults | , |
"Page faults requiring I/O" | |||
) |
VM_STATS_VM | ( | v_kthreadpages | , |
"VM pages affected by fork() by kernel" | |||
) |
VM_STATS_VM | ( | v_kthreads | , |
"Number of fork() calls by kernel" | |||
) |
VM_STATS_VM | ( | v_ozfod | , |
"Optimized zero fill pages" | |||
) |
VM_STATS_VM | ( | v_pdshortfalls | , |
"Page reclamation shortfalls" | |||
) |
VM_STATS_VM | ( | v_pdwakeups | , |
"Pagedaemon wakeups" | |||
) |
VM_STATS_VM | ( | v_pfree | , |
"Pages freed by exiting processes" | |||
) |
VM_STATS_VM | ( | v_reactivated | , |
"Pages reactivated by pagedaemon" | |||
) |
VM_STATS_VM | ( | v_rforkpages | , |
"VM pages affected by rfork()" | |||
) |
VM_STATS_VM | ( | v_rforks | , |
"Number of rfork() calls" | |||
) |
VM_STATS_VM | ( | v_swapin | , |
"Swap pager pageins" | |||
) |
VM_STATS_VM | ( | v_swapout | , |
"Swap pager pageouts" | |||
) |
VM_STATS_VM | ( | v_swappgsin | , |
"Swap pages swapped in" | |||
) |
VM_STATS_VM | ( | v_swappgsout | , |
"Swap pages swapped out" | |||
) |
VM_STATS_VM | ( | v_tfree | , |
"Total pages freed" | |||
) |
VM_STATS_VM | ( | v_vforkpages | , |
"VM pages affected by vfork()" | |||
) |
VM_STATS_VM | ( | v_vforks | , |
"Number of vfork() calls" | |||
) |
VM_STATS_VM | ( | v_vm_faults | , |
"Address memory faults" | |||
) |
VM_STATS_VM | ( | v_vnodein | , |
"Vnode pager pageins" | |||
) |
VM_STATS_VM | ( | v_vnodeout | , |
"Vnode pager pageouts" | |||
) |
VM_STATS_VM | ( | v_vnodepgsin | , |
"Vnode pages paged in" | |||
) |
VM_STATS_VM | ( | v_vnodepgsout | , |
"Vnode pages paged out" | |||
) |
VM_STATS_VM | ( | v_zfod | , |
"Pages zero-filled on demand" | |||
) |
|
static |
Definition at line 103 of file vm_meter.c.
References vm_cnt.
|
static |
Definition at line 165 of file vm_meter.c.
References OBJ_ANON, OBJ_FICTITIOUS, OBJ_SWAP, vm_free_count(), vm_object_is_active(), vm_object_list, vm_object_list_mtx, vm_wait_count(), and vmtotal().
Referenced by vmtotal().
struct vmmeter __read_mostly vm_cnt |
Definition at line 61 of file vm_meter.c.
Referenced by kmem_bootstrap_free(), memguard_fudge(), swap_pager_swap_init(), swap_reserve_by_cred(), sysctl_vm_pdpages(), vm_page_startup(), vm_pageout_init(), vm_radix_reserve_kva(), vm_set_page_size(), and vmcounter_startup().
u_long __exclusive_cache_line vm_user_wire_count |
Definition at line 100 of file vm_meter.c.
Referenced by vm_map_wire_user_count_add().