diff options
author | dyson <dyson@FreeBSD.org> | 1997-12-04 19:00:56 +0000 |
---|---|---|
committer | dyson <dyson@FreeBSD.org> | 1997-12-04 19:00:56 +0000 |
commit | cd720ec73bac6dd6a1457d0d8de8726085c13bdb (patch) | |
tree | 40a2e960af8ac1b139c2f1d15f30959990547ca5 | |
parent | de0a036d8e076fec9007e8ad8962b66006c158e7 (diff) | |
download | FreeBSD-src-cd720ec73bac6dd6a1457d0d8de8726085c13bdb.zip FreeBSD-src-cd720ec73bac6dd6a1457d0d8de8726085c13bdb.tar.gz |
Support applications that need to resist or deny use of swap space.
sysctl -w vm.defer_swap_pageouts=1
Causes the system to resist the use of swap space. In low memory
conditions, performance will decrease.
sysctl -w vm.disable_swap_pageouts=1
Causes the system to mostly disable the use of swap space. In
low memory conditions, the system will likely start killing
processes.
-rw-r--r-- | sys/vm/vm_pageout.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c index 935b6a9..c55de98 100644 --- a/sys/vm/vm_pageout.c +++ b/sys/vm/vm_pageout.c @@ -65,7 +65,7 @@ * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * - * $Id: vm_pageout.c,v 1.99 1997/10/06 02:48:16 dyson Exp $ + * $Id: vm_pageout.c,v 1.100 1997/10/25 02:41:56 dyson Exp $ */ /* @@ -141,6 +141,8 @@ extern int vfs_update_wakeup; int vm_pageout_stats_max=0, vm_pageout_stats_interval = 0; int vm_pageout_full_stats_interval = 0; int vm_pageout_stats_free_max=0, vm_pageout_algorithm_lru=0; +int defer_swap_pageouts=0; +int disable_swap_pageouts=0; #if defined(NO_SWAPPING) int vm_swapping_enabled=0; #else @@ -170,6 +172,12 @@ SYSCTL_INT(_vm, VM_SWAPPING_ENABLED, swapping_enabled, CTLFLAG_RW, &vm_swapping_enabled, 0, ""); #endif +SYSCTL_INT(_vm, OID_AUTO, defer_swap_pageouts, + CTLFLAG_RW, &defer_swap_pageouts, 0, ""); + +SYSCTL_INT(_vm, OID_AUTO, disable_swap_pageouts, + CTLFLAG_RW, &disable_swap_pageouts, 0, ""); + #define MAXLAUNDER (cnt.v_page_count > 1800 ? 32 : 16) #define VM_PAGEOUT_PAGE_COUNT 16 @@ -716,6 +724,7 @@ rescan0: */ } else if (maxlaunder > 0) { int written; + int swap_pageouts_ok; struct vnode *vp = NULL; object = m->object; @@ -732,6 +741,22 @@ rescan0: continue; } + if ((object->type != OBJT_SWAP) && (object->type != OBJT_DEFAULT)) { + swap_pageouts_ok = 1; + } else { + swap_pageouts_ok = !(defer_swap_pageouts || disable_swap_pageouts); + swap_pageouts_ok |= (!disable_swap_pageouts && defer_swap_pageouts && + (cnt.v_free_count + cnt.v_cache_count) < cnt.v_free_min); + + } + if (!swap_pageouts_ok) { + s = splvm(); + TAILQ_REMOVE(&vm_page_queue_inactive, m, pageq); + TAILQ_INSERT_TAIL(&vm_page_queue_inactive, m, pageq); + splx(s); + continue; + } + if (object->type == OBJT_VNODE) { vp = object->handle; if (VOP_ISLOCKED(vp) || @@ -793,7 +818,6 @@ rescan0: * start the cleaning operation. */ written = vm_pageout_clean(m, 0); - if (vp) vput(vp); |