Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/swap_pager.c
Show First 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | |||||
SYSCTL_PROC(_vm, OID_AUTO, swap_reserved, CTLTYPE_U64 | CTLFLAG_RD | CTLFLAG_MPSAFE, | SYSCTL_PROC(_vm, OID_AUTO, swap_reserved, CTLTYPE_U64 | CTLFLAG_RD | CTLFLAG_MPSAFE, | ||||
&swap_reserved, 0, sysctl_page_shift, "QU", | &swap_reserved, 0, sysctl_page_shift, "QU", | ||||
"Amount of swap storage needed to back all allocated anonymous memory."); | "Amount of swap storage needed to back all allocated anonymous memory."); | ||||
SYSCTL_PROC(_vm, OID_AUTO, swap_total, CTLTYPE_U64 | CTLFLAG_RD | CTLFLAG_MPSAFE, | SYSCTL_PROC(_vm, OID_AUTO, swap_total, CTLTYPE_U64 | CTLFLAG_RD | CTLFLAG_MPSAFE, | ||||
&swap_total, 0, sysctl_page_shift, "QU", | &swap_total, 0, sysctl_page_shift, "QU", | ||||
"Total amount of available swap storage."); | "Total amount of available swap storage."); | ||||
static int overcommit = 0; | int vm_overcommit = 0; | ||||
SYSCTL_INT(_vm, VM_OVERCOMMIT, overcommit, CTLFLAG_RW, &overcommit, 0, | SYSCTL_INT(_vm, VM_OVERCOMMIT, overcommit, CTLFLAG_RW, &vm_overcommit, 0, | ||||
mjg: this should be __read_mostly | |||||
"Configure virtual memory overcommit behavior. See tuning(7) " | "Configure virtual memory overcommit behavior. See tuning(7) " | ||||
"for details."); | "for details."); | ||||
static unsigned long swzone; | static unsigned long swzone; | ||||
SYSCTL_ULONG(_vm, OID_AUTO, swzone, CTLFLAG_RD, &swzone, 0, | SYSCTL_ULONG(_vm, OID_AUTO, swzone, CTLFLAG_RD, &swzone, 0, | ||||
"Actual size of swap metadata zone"); | "Actual size of swap metadata zone"); | ||||
static unsigned long swap_maxpages; | static unsigned long swap_maxpages; | ||||
SYSCTL_ULONG(_vm, OID_AUTO, swap_maxpages, CTLFLAG_RD, &swap_maxpages, 0, | SYSCTL_ULONG(_vm, OID_AUTO, swap_maxpages, CTLFLAG_RD, &swap_maxpages, 0, | ||||
"Maximum amount of swap supported"); | "Maximum amount of swap supported"); | ||||
static COUNTER_U64_DEFINE_EARLY(swap_free_deferred); | static COUNTER_U64_DEFINE_EARLY(swap_free_deferred); | ||||
SYSCTL_COUNTER_U64(_vm_stats_swap, OID_AUTO, free_deferred, | SYSCTL_COUNTER_U64(_vm_stats_swap, OID_AUTO, free_deferred, | ||||
CTLFLAG_RD, &swap_free_deferred, | CTLFLAG_RD, &swap_free_deferred, | ||||
"Number of pages that deferred freeing swap space"); | "Number of pages that deferred freeing swap space"); | ||||
static COUNTER_U64_DEFINE_EARLY(swap_free_completed); | static COUNTER_U64_DEFINE_EARLY(swap_free_completed); | ||||
SYSCTL_COUNTER_U64(_vm_stats_swap, OID_AUTO, free_completed, | SYSCTL_COUNTER_U64(_vm_stats_swap, OID_AUTO, free_completed, | ||||
CTLFLAG_RD, &swap_free_completed, | CTLFLAG_RD, &swap_free_completed, | ||||
"Number of deferred frees completed"); | "Number of deferred frees completed"); | ||||
/* bits from overcommit */ | |||||
#define SWAP_RESERVE_FORCE_ON (1 << 0) | |||||
#define SWAP_RESERVE_RLIMIT_ON (1 << 1) | |||||
#define SWAP_RESERVE_ALLOW_NONWIRED (1 << 2) | |||||
static int | static int | ||||
sysctl_page_shift(SYSCTL_HANDLER_ARGS) | sysctl_page_shift(SYSCTL_HANDLER_ARGS) | ||||
{ | { | ||||
uint64_t newval; | uint64_t newval; | ||||
u_long value = *(u_long *)arg1; | u_long value = *(u_long *)arg1; | ||||
newval = ((uint64_t)value) << PAGE_SHIFT; | newval = ((uint64_t)value) << PAGE_SHIFT; | ||||
return (sysctl_handle_64(oidp, &newval, 0, req)); | return (sysctl_handle_64(oidp, &newval, 0, req)); | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | #ifdef RACCT | ||||
int error; | int error; | ||||
#endif | #endif | ||||
int oc; | int oc; | ||||
static int curfail; | static int curfail; | ||||
static struct timeval lastfail; | static struct timeval lastfail; | ||||
KASSERT((incr & PAGE_MASK) == 0, ("%s: incr: %ju & PAGE_MASK", __func__, | KASSERT((incr & PAGE_MASK) == 0, ("%s: incr: %ju & PAGE_MASK", __func__, | ||||
(uintmax_t)incr)); | (uintmax_t)incr)); | ||||
Done Inline ActionsI'd prefer all this whitespace churn was in a separate commit. brooks: I'd prefer all this whitespace churn was in a separate commit. | |||||
Done Inline ActionsIt is, please see https://kib.kiev.ua/git/gitweb.cgi?p=deviant3.git;a=shortlog;h=refs/heads/at_vm for per-commit split kib: It is, please see https://kib.kiev.ua/git/gitweb.cgi?p=deviant3.git;a=shortlog… | |||||
#ifdef RACCT | #ifdef RACCT | ||||
if (RACCT_ENABLED()) { | if (RACCT_ENABLED()) { | ||||
PROC_LOCK(curproc); | PROC_LOCK(curproc); | ||||
error = racct_add(curproc, RACCT_SWAP, incr); | error = racct_add(curproc, RACCT_SWAP, incr); | ||||
PROC_UNLOCK(curproc); | PROC_UNLOCK(curproc); | ||||
if (error != 0) | if (error != 0) | ||||
return (false); | return (false); | ||||
} | } | ||||
#endif | #endif | ||||
pincr = atop(incr); | pincr = atop(incr); | ||||
prev = atomic_fetchadd_long(&swap_reserved, pincr); | prev = atomic_fetchadd_long(&swap_reserved, pincr); | ||||
r = prev + pincr; | r = prev + pincr; | ||||
s = swap_total; | s = swap_total; | ||||
oc = atomic_load_int(&overcommit); | oc = atomic_load_int(&vm_overcommit); | ||||
if (r > s && (oc & SWAP_RESERVE_ALLOW_NONWIRED) != 0) { | if (r > s && (oc & SWAP_RESERVE_ALLOW_NONWIRED) != 0) { | ||||
s += vm_cnt.v_page_count - vm_cnt.v_free_reserved - | s += vm_cnt.v_page_count - vm_cnt.v_free_reserved - | ||||
vm_wire_count(); | vm_wire_count(); | ||||
} | } | ||||
if ((oc & SWAP_RESERVE_FORCE_ON) != 0 && r > s && | if ((oc & SWAP_RESERVE_FORCE_ON) != 0 && r > s && | ||||
priv_check(curthread, PRIV_VM_SWAP_NOQUOTA) != 0) { | priv_check(curthread, PRIV_VM_SWAP_NOQUOTA) != 0) { | ||||
prev = atomic_fetchadd_long(&swap_reserved, -pincr); | prev = atomic_fetchadd_long(&swap_reserved, -pincr); | ||||
KASSERT(prev >= pincr, ("swap_reserved < incr on overcommit fail")); | KASSERT(prev >= pincr, ("swap_reserved < incr on overcommit fail")); | ||||
▲ Show 20 Lines • Show All 2,837 Lines • Show Last 20 Lines |
this should be __read_mostly