From 8f7a14042e1f5fc814fa60956e3a2dcf5744a0ed Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sat, 12 Oct 2002 19:33:06 -0700 Subject: [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. --- include/linux/sysctl.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/linux/sysctl.h') diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 8139ec747979..f1a5aaa234ad 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -153,6 +153,7 @@ enum VM_OVERCOMMIT_RATIO=16, /* percent of RAM to allow overcommit in */ VM_PAGEBUF=17, /* struct: Control pagebuf parameters */ VM_HUGETLB_PAGES=18, /* int: Number of available Huge Pages */ + VM_SWAPPINESS=19, /* Tendency to steal mapped memory */ }; -- cgit v1.2.3 From bf175bc495d14b8776c001252177c8c8a0342727 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sat, 12 Oct 2002 19:33:16 -0700 Subject: [PATCH] rename /proc/sys/vm/dirty_async_ratio to dirty_ratio Since /proc/sys/vm/dirty_sync_ratio went away, the name "dirty_async_ratio" makes no sense. So rename it to just /proc/sys/vm/dirty_ratio. --- Documentation/filesystems/proc.txt | 2 +- Documentation/sysctl/vm.txt | 4 ++-- include/linux/sysctl.h | 2 +- include/linux/writeback.h | 2 +- kernel/sysctl.c | 4 ++-- mm/page-writeback.c | 18 +++++++++--------- 6 files changed, 16 insertions(+), 16 deletions(-) (limited to 'include/linux/sysctl.h') diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt index 3ad9c3fd7f08..e7f223b0b9df 100644 --- a/Documentation/filesystems/proc.txt +++ b/Documentation/filesystems/proc.txt @@ -966,7 +966,7 @@ dirty_background_ratio Contains, as a percentage of total system memory, the number of pages at which the pdflush background writeback daemon will start writing out dirty data. -dirty_async_ratio +dirty_ratio ----------------- Contains, as a percentage of total system memory, the number of pages at which diff --git a/Documentation/sysctl/vm.txt b/Documentation/sysctl/vm.txt index ed6ccff766f4..e6f8c613c879 100644 --- a/Documentation/sysctl/vm.txt +++ b/Documentation/sysctl/vm.txt @@ -18,14 +18,14 @@ files can be found in mm/swap.c. Currently, these files are in /proc/sys/vm: - overcommit_memory - page-cluster -- dirty_async_ratio +- dirty_ratio - dirty_background_ratio - dirty_expire_centisecs - dirty_writeback_centisecs ============================================================== -dirty_async_ratio, dirty_background_ratio, dirty_expire_centisecs, +dirty_ratio, dirty_background_ratio, dirty_expire_centisecs, dirty_writeback_centisecs: See Documentation/filesystems/proc.txt diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index f1a5aaa234ad..58055e1998cd 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -146,7 +146,7 @@ enum VM_UNUSED9=9, /* was: struct: Set page table cache parameters */ VM_PAGE_CLUSTER=10, /* int: set number of pages to swap together */ VM_DIRTY_BACKGROUND=11, /* dirty_background_ratio */ - VM_DIRTY_ASYNC=12, /* dirty_async_ratio */ + VM_DIRTY_RATIO=12, /* dirty_ratio */ VM_DIRTY_WB_CS=13, /* dirty_writeback_centisecs */ VM_DIRTY_EXPIRE_CS=14, /* dirty_expire_centisecs */ VM_NR_PDFLUSH_THREADS=15, /* nr_pdflush_threads */ diff --git a/include/linux/writeback.h b/include/linux/writeback.h index b71468f8f072..687091648a3a 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h @@ -67,7 +67,7 @@ int wakeup_bdflush(long nr_pages); /* These 5 are exported to sysctl. */ extern int dirty_background_ratio; -extern int dirty_async_ratio; +extern int vm_dirty_ratio; extern int dirty_writeback_centisecs; extern int dirty_expire_centisecs; diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 3b49efc1c523..0317dd749b2b 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -286,8 +286,8 @@ static ctl_table vm_table[] = { &dirty_background_ratio, sizeof(dirty_background_ratio), 0644, NULL, &proc_dointvec_minmax, &sysctl_intvec, NULL, &zero, &one_hundred }, - {VM_DIRTY_ASYNC, "dirty_async_ratio", &dirty_async_ratio, - sizeof(dirty_async_ratio), 0644, NULL, &proc_dointvec_minmax, + {VM_DIRTY_RATIO, "dirty_ratio", &vm_dirty_ratio, + sizeof(vm_dirty_ratio), 0644, NULL, &proc_dointvec_minmax, &sysctl_intvec, NULL, &zero, &one_hundred }, {VM_DIRTY_WB_CS, "dirty_writeback_centisecs", &dirty_writeback_centisecs, sizeof(dirty_writeback_centisecs), 0644, diff --git a/mm/page-writeback.c b/mm/page-writeback.c index e2dca9be22fe..f135ed5ab789 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -63,9 +63,9 @@ static inline long sync_writeback_pages(void) int dirty_background_ratio = 10; /* - * The generator of dirty data starts async writeback at this percentage + * The generator of dirty data starts writeback at this percentage */ -int dirty_async_ratio = 40; +int vm_dirty_ratio = 40; /* * The interval between `kupdate'-style writebacks, in centiseconds @@ -86,7 +86,7 @@ static void background_writeout(unsigned long _min_pages); /* * balance_dirty_pages() must be called by processes which are generating dirty * data. It looks at the number of dirty pages in the machine and will force - * the caller to perform writeback if the system is over `async_thresh'. + * the caller to perform writeback if the system is over `vm_dirty_ratio'. * If we're over `background_thresh' then pdflush is woken to perform some * writeout. */ @@ -94,15 +94,15 @@ void balance_dirty_pages(struct address_space *mapping) { struct page_state ps; long background_thresh; - long async_thresh; + long dirty_thresh; struct backing_dev_info *bdi = mapping->backing_dev_info; background_thresh = (dirty_background_ratio * total_pages) / 100; - async_thresh = (dirty_async_ratio * total_pages) / 100; + dirty_thresh = (vm_dirty_ratio * total_pages) / 100; get_page_state(&ps); - while (ps.nr_dirty + ps.nr_writeback > async_thresh) { + while (ps.nr_dirty + ps.nr_writeback > dirty_thresh) { struct writeback_control wbc = { .bdi = bdi, .sync_mode = WB_SYNC_NONE, @@ -116,7 +116,7 @@ void balance_dirty_pages(struct address_space *mapping) writeback_inodes(&wbc); get_page_state(&ps); - if (ps.nr_dirty + ps.nr_writeback <= async_thresh) + if (ps.nr_dirty + ps.nr_writeback <= dirty_thresh) break; blk_congestion_wait(WRITE, HZ/10); } @@ -338,8 +338,8 @@ static int __init page_writeback_init(void) if (correction < 100) { dirty_background_ratio *= correction; dirty_background_ratio /= 100; - dirty_async_ratio *= correction; - dirty_async_ratio /= 100; + vm_dirty_ratio *= correction; + vm_dirty_ratio /= 100; } init_timer(&wb_timer); -- cgit v1.2.3