Changeset View
Changeset View
Standalone View
Standalone View
vm_glue.c
Show First 20 Lines • Show All 836 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Swap_idle_threshold2 is the time that a process can be idle before | * Swap_idle_threshold2 is the time that a process can be idle before | ||||
* it will be swapped out, if idle swapping is enabled. | * it will be swapped out, if idle swapping is enabled. | ||||
*/ | */ | ||||
static int swap_idle_threshold2 = 10; | static int swap_idle_threshold2 = 10; | ||||
SYSCTL_INT(_vm, OID_AUTO, swap_idle_threshold2, CTLFLAG_RW, | SYSCTL_INT(_vm, OID_AUTO, swap_idle_threshold2, CTLFLAG_RW, | ||||
&swap_idle_threshold2, 0, "Time before a process will be swapped out"); | &swap_idle_threshold2, 0, "Time before a process will be swapped out"); | ||||
/* Long before Unix supported paging, it used process swapping. | |||||
* While this was ok with the PDP-11/20's 64kB address spaces, it does not work as well today | |||||
* when address spaces can easily be hundreds of GB.*/ | |||||
static u_long proc_swapout_max = 65536 ; | |||||
SYSCTL_LONG(_vm, OID_AUTO, proc_swapout_max, CTLFLAG_RW, &proc_swapout_max, 0, | |||||
"Allows to limit the swapout of whole processes which max resident size (in bytes) is equal or less than value"); | |||||
/* | /* | ||||
* First, if any processes have been sleeping or stopped for at least | * First, if any processes have been sleeping or stopped for at least | ||||
* "swap_idle_threshold1" seconds, they are swapped out. If, however, | * "swap_idle_threshold1" seconds, they are swapped out. If, however, | ||||
* no such processes exist, then the longest-sleeping or stopped | * no such processes exist, then the longest-sleeping or stopped | ||||
* process is swapped out. Finally, and only as a last resort, if | * process is swapped out. Finally, and only as a last resort, if | ||||
* there are no sleeping or stopped processes, the longest-resident | * there are no sleeping or stopped processes, the longest-resident | ||||
* process is swapped out. | * process is swapped out. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | case PRS_NORMAL: | ||||
if (minslptime > slptime) | if (minslptime > slptime) | ||||
minslptime = slptime; | minslptime = slptime; | ||||
thread_unlock(td); | thread_unlock(td); | ||||
} | } | ||||
/* | /* | ||||
* If the pageout daemon didn't free enough pages, | * If the pageout daemon didn't free enough pages, | ||||
* or if this process is idle and the system is | * or if this process is idle and the system is | ||||
* configured to swap proactively, swap it out. | * configured to swap proactively, and the process resident count | ||||
* is less than vm.proc_swapout_max swap it out. | |||||
rpokala: I think this would read slightly better like this:
"If the pageout daemon didn't free enough… | |||||
*/ | */ | ||||
if ((action & VM_SWAP_NORMAL) || | if (((vmspace_resident_count(p->p_vmspace) * PAGE_SIZE) | ||||
<= proc_swapout_max ) && | |||||
((action & VM_SWAP_NORMAL) || | |||||
((action & VM_SWAP_IDLE) && | ((action & VM_SWAP_IDLE) && | ||||
(minslptime > swap_idle_threshold2))) { | (minslptime > swap_idle_threshold2)))) { | ||||
_PRELE(p); | _PRELE(p); | ||||
if (swapout(p) == 0) | if (swapout(p) == 0) | ||||
didswap++; | didswap++; | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
vm_map_unlock(&vm->vm_map); | vm_map_unlock(&vm->vm_map); | ||||
vmspace_free(vm); | vmspace_free(vm); | ||||
goto retry; | goto retry; | ||||
} | } | ||||
Done Inline ActionsThis change in indentation seems gratuitous, and also incorrect. rpokala: This change in indentation seems gratuitous, and also incorrect. | |||||
} | } | ||||
nextproc: | nextproc: | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
vm_map_unlock(&vm->vm_map); | vm_map_unlock(&vm->vm_map); | ||||
nextproc1: | nextproc1: | ||||
vmspace_free(vm); | vmspace_free(vm); | ||||
nextproc2: | nextproc2: | ||||
sx_slock(&allproc_lock); | sx_slock(&allproc_lock); | ||||
Show All 32 Lines | #ifdef INVARIANTS | ||||
panic("not waking up swapper"); | panic("not waking up swapper"); | ||||
#endif | #endif | ||||
} | } | ||||
thread_unlock(td); | thread_unlock(td); | ||||
} | } | ||||
p->p_flag &= ~(P_SWAPPINGIN|P_SWAPPINGOUT); | p->p_flag &= ~(P_SWAPPINGIN|P_SWAPPINGOUT); | ||||
p->p_flag |= P_INMEM; | p->p_flag |= P_INMEM; | ||||
} | } | ||||
static int | static int | ||||
swapout(p) | swapout(p) | ||||
struct proc *p; | struct proc *p; | ||||
{ | { | ||||
struct thread *td; | struct thread *td; | ||||
PROC_LOCK_ASSERT(p, MA_OWNED); | PROC_LOCK_ASSERT(p, MA_OWNED); | ||||
▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines |
I think this would read slightly better like this:
"If the pageout daemon didn't free enough pages, or if this process is idle, the system is configured to swap proactively, and the process resident count is less than vm.proc_swapout_max, swap it out."