From: Ed Tomlinson <tomlins@cam.org>
To: linux-mm@kvack.org
Cc: Rik van Riel <riel@conectiva.com.br>
Subject: vmtime - a try at vm balancing
Date: Tue, 27 Mar 2001 06:52:08 -0500 [thread overview]
Message-ID: <01032706520800.02930@oscar> (raw)
Hi,
I have been having some fun. The following patch introduces the idea of
vmtime. vmtime is time as the vm percieves it. Its advanced by memory
pressure, which in the end, works out to be the page allocation & reclaim
rate. With this figure I attempt to solve two problems.
First I slow down the background page scanning to the rate we are allocating
pages. This means that an idle machine will not end up will all page ages
equal nearly as quickly. It should also help prevent cases where kswapd
eats too much cpu.
Second I add some slab cache pressure. Without the patch the icache and
dcache will get shrunk in under extreme cases. From comments on this
list (and personal experience) the slab cache can grow and end up causing
paging when it would make more sense to just shrink it. This also has
oom implications since the size of the slab cache and the possible space
we can free from it are not accounted for in the oom test. In any case
the patch should keep this storage under control. Are there any other
parts of the slab cache we should think about shrinking?
This has survived the night on my box with printk(s) in the if(s) to verify
its actually working.
Comments on style, bugs and reports on its effects very welcome.
---
--- /usr/src/linux/mm/vmscan.c.ac25 Tue Mar 27 06:28:34 2001
+++ /usr/src/linux/mm/vmscan.c Tue Mar 27 06:28:06 2001
@@ -985,22 +985,51 @@
for (;;) {
static int recalc = 0;
+ /* vmtime tracks time as the vm precieves it.
+ * It is advanced depending on the ammount of
+ * memory pressure.
+ */
+
+ static int vmtime = 0;
+ static int bgscan_required = 0;
+ static int slab_scan_required = 0;
+
/* If needed, try to free some memory. */
if (inactive_shortage() || free_shortage())
do_try_to_free_pages(GFP_KSWAPD, 0);
/*
* Do some (very minimal) background scanning. This
- * will scan all pages on the active list once
- * every minute. This clears old referenced bits
- * and moves unused pages to the inactive list.
+ * tries to scan all pages on the active list at the
+ * rate pages are allocated. This clears old referenced
+ * bits and moves unused pages to the inactive list.
+ */
+ if (vmtime > bgscan_required ) {
+ refill_inactive_scan(DEF_PRIORITY, 0);
+ bgscan_required = vmtime + (nr_active_pages >> INACTIVE_SHIFT);
+ }
+
+ /*
+ * Here we apply some pressure to the slab cache. We
+ * apply more pressure as it gets bigger. This would
+ * be cleaner if there was a nr_slab_pages...
*/
- refill_inactive_scan(DEF_PRIORITY, 0);
+ if (vmtime > slab_scan_required) {
+ shrink_dcache_memory(DEF_PRIORITY, GFP_KSWAPD);
+ shrink_icache_memory(DEF_PRIORITY, GFP_KSWAPD);
+ slab_scan_required = vmtime + num_physpages - nr_free_pages() - atomic_read(&page_cache_size) - atomic_read(&buffermem_pages);
+ }
- /* Once a second, recalculate some VM stats. */
+ /* Once a second, recalculate some VM stats and the vmtime. */
if (time_after(jiffies, recalc + HZ)) {
recalc = jiffies;
- recalculate_vm_stats();
+ recalculate_vm_stats();
+ vmtime += (memory_pressure >> INACTIVE_SHIFT);
+ if (vmtime > INT_MAX - num_physpages) {
+ vmtime = 0;
+ bgscan_required = 0;
+ slab_scan_required = 0;
+ }
}
run_task_queue(&tq_disk);
---
Ed Tomlinson <tomlins@cam.org>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
reply other threads:[~2001-03-27 11:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=01032706520800.02930@oscar \
--to=tomlins@cam.org \
--cc=linux-mm@kvack.org \
--cc=riel@conectiva.com.br \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox