summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorAndrew Morton <akpm@digeo.com>2002-10-12 19:33:06 -0700
committerLinus Torvalds <torvalds@home.transmeta.com>2002-10-12 19:33:06 -0700
commit8f7a14042e1f5fc814fa60956e3a2dcf5744a0ed (patch)
treeab2c533aa9bfdd01e7b7a92c3f0376f1ab239cf5 /kernel
parent5bbac23e816b1927c5f78058454b3a51a0618153 (diff)
[PATCH] reduced and tunable swappiness
/proc/sys/vm/swappiness controls the VM's tendency to unmap pages and to swap things out. 100 -> basically current 2.5 behaviour 0 -> not very swappy at all The mechanism which is used to control swappiness is: to be reluctant to bring mapped pages onto the inactive list. Prefer to reclaim pagecache instead. The control for that mechanism is as follows: - If there is a large amount of mapped memory in the machine, we prefer to bring mapped pages onto the inactive list. - If page reclaim is under distress (more scanning is happening) then prefer to bring mapped pages onto the inactive list. This is basically the 2.4 algorithm, really. - If the /proc/sys/vm/swappiness control is high then prefer to bring mapped pages onto the inactive list. The implementation is simple: calculate the above three things as percentages and add them up. If that's over 100% then start reclaiming mapped pages. The `proportion of mapped memory' is downgraded so that we don't swap just because a lot of memory is mapped into pagetables - we still need some VM distress before starting to swap that memory out. For a while I was adding a little bias so that we prefer to unmap file-backed memory before swapping out anon memory. Because usually file backed memory can be evicted and reestablished with one I/O, not two. It was unmapping executable text too easily, so here I just treat them equally.
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sysctl.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 53d13c96fbf2..3b49efc1c523 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -311,6 +311,9 @@ static ctl_table vm_table[] = {
{ VM_NR_PDFLUSH_THREADS, "nr_pdflush_threads",
&nr_pdflush_threads, sizeof nr_pdflush_threads,
0444 /* read-only*/, NULL, &proc_dointvec},
+ {VM_SWAPPINESS, "swappiness", &vm_swappiness, sizeof(vm_swappiness),
+ 0644, NULL, &proc_dointvec_minmax, &sysctl_intvec, NULL, &zero,
+ &one_hundred },
#ifdef CONFIG_HUGETLB_PAGE
{VM_HUGETLB_PAGES, "nr_hugepages", &htlbpage_max, sizeof(int), 0644, NULL,
&proc_dointvec},