FreeBSD virtual memory subsystem code
|
#include <sys/cdefs.h>
#include "opt_kstack_pages.h"
#include "opt_kstack_max_pages.h"
#include "opt_vm.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/limits.h>
#include <sys/kernel.h>
#include <sys/eventhandler.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/kthread.h>
#include <sys/ktr.h>
#include <sys/mount.h>
#include <sys/racct.h>
#include <sys/resourcevar.h>
#include <sys/refcount.h>
#include <sys/sched.h>
#include <sys/sdt.h>
#include <sys/signalvar.h>
#include <sys/smp.h>
#include <sys/time.h>
#include <sys/vnode.h>
#include <sys/vmmeter.h>
#include <sys/rwlock.h>
#include <sys/sx.h>
#include <sys/sysctl.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_kern.h>
#include <vm/vm_object.h>
#include <vm/vm_page.h>
#include <vm/vm_map.h>
#include <vm/vm_pageout.h>
#include <vm/vm_pager.h>
#include <vm/vm_phys.h>
#include <vm/swap_pager.h>
#include <vm/vm_extern.h>
#include <vm/uma.h>
Go to the source code of this file.
Macros | |
#define | VM_SWAP_NORMAL 1 |
#define | VM_SWAP_IDLE 2 |
#define | SWAPIN_INTERVAL (MAXSLP * hz / 2) |
Functions | |
__FBSDID ("$FreeBSD$") | |
static void | vm_daemon (void) |
SYSINIT (vmdaemon, SI_SUB_KTHREAD_VM, SI_ORDER_FIRST, kproc_start, &vm_kp) | |
SYSCTL_INT (_vm, VM_SWAPPING_ENABLED, swap_enabled, CTLFLAG_RW, &vm_swap_enabled, 0, "Enable entire process swapout") | |
SYSCTL_INT (_vm, OID_AUTO, swap_idle_enabled, CTLFLAG_RW, &vm_swap_idle_enabled, 0, "Allow swapout on idle criteria") | |
SYSCTL_INT (_vm, OID_AUTO, swap_idle_threshold1, CTLFLAG_RW, &swap_idle_threshold1, 0, "Guaranteed swapped in time for a process") | |
SYSCTL_INT (_vm, OID_AUTO, swap_idle_threshold2, CTLFLAG_RW, &swap_idle_threshold2, 0, "Time before a process will be swapped out") | |
SYSCTL_INT (_vm, OID_AUTO, vmdaemon_timeout, CTLFLAG_RW, &vm_daemon_timeout, 0, "Time between vmdaemon runs") | |
MTX_SYSINIT (vm_daemon, &vm_daemon_mtx, "vm daemon", MTX_DEF) | |
static void | swapclear (struct proc *) |
static int | swapout (struct proc *) |
static void | vm_swapout_map_deactivate_pages (vm_map_t, long) |
static void | vm_swapout_object_deactivate (pmap_t, vm_object_t, long) |
static void | swapout_procs (int action) |
static void | vm_req_vmdaemon (int req) |
static void | vm_thread_swapout (struct thread *td) |
static void | vm_swapout_object_deactivate_page (pmap_t pmap, vm_page_t m, bool unmap) |
void | vm_swapout_run (void) |
void | vm_swapout_run_idle (void) |
static void | vm_thread_swapin (struct thread *td, int oom_alloc) |
void | faultin (struct proc *p) |
static struct proc * | swapper_selector (bool wkilled_only) |
static bool | swapper_wkilled_only (void) |
void | swapper (void) |
Variables | |
static struct proc * | vmproc |
static struct kproc_desc | vm_kp |
static int | vm_swap_enabled = 1 |
static int | vm_swap_idle_enabled = 0 |
static int | swap_idle_threshold1 = 2 |
static int | swap_idle_threshold2 = 10 |
static int | vm_daemon_timeout = 0 |
static int | vm_pageout_req_swapout |
static int | vm_daemon_needed |
static struct mtx | vm_daemon_mtx |
static int | swapped_cnt |
static int | swap_inprogress |
static int | last_swapin |
#define SWAPIN_INTERVAL (MAXSLP * hz / 2) |
Definition at line 727 of file vm_swapout.c.
#define VM_SWAP_IDLE 2 |
Definition at line 333 of file vm_swapout.c.
#define VM_SWAP_NORMAL 1 |
Definition at line 332 of file vm_swapout.c.
__FBSDID | ( | "$FreeBSD$" | ) |
void faultin | ( | struct proc * | p | ) |
Definition at line 595 of file vm_swapout.c.
References last_swapin, swap_inprogress, swapclear(), swapped_cnt, VM_ALLOC_NORMAL, VM_ALLOC_SYSTEM, and vm_thread_swapin().
Referenced by swapper().
MTX_SYSINIT | ( | vm_daemon | , |
& | vm_daemon_mtx, | ||
"vm daemon" | , | ||
MTX_DEF | |||
) |
|
static |
Definition at line 870 of file vm_swapout.c.
Referenced by faultin(), and swapout().
|
static |
Definition at line 900 of file vm_swapout.c.
References swapclear(), vm_thread_swapout(), and vmspace_resident_count().
Referenced by swapout_procs().
|
static |
Definition at line 784 of file vm_swapout.c.
References swap_idle_threshold1, swap_idle_threshold2, swapout(), swapped_cnt, VM_SWAP_IDLE, and VM_SWAP_NORMAL.
Referenced by vm_daemon().
void swapper | ( | void | ) |
Definition at line 745 of file vm_swapout.c.
|
static |
Definition at line 662 of file vm_swapout.c.
References swapped_cnt.
Referenced by swapper().
|
static |
Definition at line 737 of file vm_swapout.c.
References all_domains, last_swapin, swap_inprogress, and SWAPIN_INTERVAL.
Referenced by swapper().
SYSCTL_INT | ( | _vm | , |
OID_AUTO | , | ||
swap_idle_enabled | , | ||
CTLFLAG_RW | , | ||
& | vm_swap_idle_enabled, | ||
0 | , | ||
"Allow swapout on idle criteria" | |||
) |
SYSCTL_INT | ( | _vm | , |
OID_AUTO | , | ||
swap_idle_threshold1 | , | ||
CTLFLAG_RW | , | ||
& | swap_idle_threshold1, | ||
0 | , | ||
"Guaranteed swapped in time for a process" | |||
) |
SYSCTL_INT | ( | _vm | , |
OID_AUTO | , | ||
swap_idle_threshold2 | , | ||
CTLFLAG_RW | , | ||
& | swap_idle_threshold2, | ||
0 | , | ||
"Time before a process will be swapped out" | |||
) |
SYSCTL_INT | ( | _vm | , |
OID_AUTO | , | ||
vmdaemon_timeout | , | ||
CTLFLAG_RW | , | ||
& | vm_daemon_timeout, | ||
0 | , | ||
"Time between vmdaemon runs" | |||
) |
SYSCTL_INT | ( | _vm | , |
VM_SWAPPING_ENABLED | , | ||
swap_enabled | , | ||
CTLFLAG_RW | , | ||
& | vm_swap_enabled, | ||
0 | , | ||
"Enable entire process swapout" | |||
) |
SYSINIT | ( | vmdaemon | , |
SI_SUB_KTHREAD_VM | , | ||
SI_ORDER_FIRST | , | ||
kproc_start | , | ||
& | vm_kp | ||
) |
|
static |
Definition at line 373 of file vm_swapout.c.
References IDX_TO_OFF, OFF_TO_IDX, swapout_procs(), vm_daemon_mtx, vm_daemon_needed, vm_daemon_timeout, vmspace::vm_map, vm_page_pqbatch_drain(), vm_pageout_req_swapout, VM_SWAP_NORMAL, vm_swapout_map_deactivate_pages(), vmspace_acquire_ref(), vmspace_free(), and vmspace_resident_count().
|
static |
Definition at line 359 of file vm_swapout.c.
References vm_daemon_mtx, vm_daemon_needed, and vm_pageout_req_swapout.
Referenced by vm_swapout_run(), and vm_swapout_run_idle().
|
static |
Definition at line 260 of file vm_swapout.c.
References vm_map_entry::eflags, MAP_ENTRY_IS_SUB_MAP, vm_map_entry::object, vm_map::pmap, pmap_remove(), pmap_resident_count, vm_object::resident_page_count, vm_object::shadow_count, VM_MAP_ENTRY_FOREACH, vm_map_max(), vm_map_min(), vm_map_pmap(), vm_map_trylock_read, vm_map_unlock_read, vm_map_object::vm_object, VM_OBJECT_RLOCK, VM_OBJECT_RUNLOCK, VM_OBJECT_TRYRLOCK, vm_swapout_object_deactivate(), and vm_map_entry::wired_count.
Referenced by vm_daemon().
|
static |
Definition at line 212 of file vm_swapout.c.
References vm_object::backing_object, vm_object::flags, vm_object::memq, OBJ_FICTITIOUS, OBJ_UNMANAGED, vm_object::paging_in_progress, pmap_resident_count, vm_object::shadow_count, VM_OBJECT_ASSERT_LOCKED, VM_OBJECT_RLOCK, VM_OBJECT_RUNLOCK, and vm_swapout_object_deactivate_page().
Referenced by vm_swapout_map_deactivate_pages().
|
static |
Definition at line 180 of file vm_swapout.c.
References pmap_is_referenced(), pmap_page_exists_quick(), vm_page_active(), vm_page_deactivate(), vm_page_try_remove_all(), vm_page_tryxbusy(), vm_page_wired(), and vm_page_xunbusy.
Referenced by vm_swapout_object_deactivate().
void vm_swapout_run | ( | void | ) |
Definition at line 336 of file vm_swapout.c.
void vm_swapout_run_idle | ( | void | ) |
Definition at line 348 of file vm_swapout.c.
|
static |
Definition at line 559 of file vm_swapout.c.
References KSTACK_MAX_PAGES, kstack_object, pmap_qenter(), vm_object_pip_add(), vm_object_pip_wakeup(), VM_OBJECT_WLOCK, VM_OBJECT_WUNLOCK, vm_page_all_valid(), vm_page_assert_xbusied, vm_pager_get_pages(), vm_pager_has_page(), VM_PAGER_OK, and vm_thread_stack_back().
Referenced by faultin().
|
static |
Definition at line 531 of file vm_swapout.c.
References kstack_object, pmap_qremove(), PQ_LAUNDRY, VM_OBJECT_WLOCK, VM_OBJECT_WUNLOCK, vm_page_dirty(), vm_page_lookup(), vm_page_unwire(), and vm_page_xunbusy_unchecked.
Referenced by swapout().
|
static |
Definition at line 169 of file vm_swapout.c.
Referenced by faultin(), and swapper_wkilled_only().
|
static |
Definition at line 142 of file vm_swapout.c.
Referenced by swapout_procs().
|
static |
Definition at line 151 of file vm_swapout.c.
Referenced by swapout_procs().
|
static |
Definition at line 168 of file vm_swapout.c.
Referenced by faultin(), and swapper_wkilled_only().
|
static |
Definition at line 167 of file vm_swapout.c.
Referenced by faultin(), swapout_procs(), and swapper_selector().
|
static |
Definition at line 163 of file vm_swapout.c.
Referenced by vm_daemon(), and vm_req_vmdaemon().
|
static |
Definition at line 162 of file vm_swapout.c.
Referenced by vm_daemon(), and vm_req_vmdaemon().
|
static |
Definition at line 156 of file vm_swapout.c.
Referenced by vm_daemon().
|
static |
Definition at line 122 of file vm_swapout.c.
|
static |
Definition at line 161 of file vm_swapout.c.
Referenced by vm_daemon(), and vm_req_vmdaemon().
|
static |
Definition at line 129 of file vm_swapout.c.
Referenced by vm_swapout_run().
|
static |
Definition at line 130 of file vm_swapout.c.
Referenced by vm_swapout_run_idle().
|
static |
Definition at line 120 of file vm_swapout.c.