DragonFly commits List (threaded) for 2010-02
git: kernel - SWAP CACHE part 8/many - Add the swap cache read intercept, rate ctl
Author: Matthew Dillon <firstname.lastname@example.org>
Date: Thu Feb 4 14:56:42 2010 -0800
kernel - SWAP CACHE part 8/many - Add the swap cache read intercept, rate ctl
* Add vn_cache_strategy() and adjust vn_strategy() to call it. This
implements the read intercept. If vn_cache_strategy() determines that
the entire request can be handled by the swap cache it issues an
appropriate swap_pager_strategy() call and returns 1, else it returns 0
and the normal vn_strategy() function is run.
vn_cache_strategy() only intercepts READ's which meet some fairly strict
requirements, including no bogus pages and page alignment (so certain
meta-data in UFS which uses a 6144 byte block size cannot be read via
the swap cache, sorry).
* Implement numerous sysctls.
vm.swapcache.accrate (default 1000000)
The average long-term write rate in bytes/second for writing
data to the swap cache. This is what ultimately controls the
wear rate of the SSD swap.
vm.swapcache.maxburst (default 1000000000)
vm.swapcache.curburst (default starts at 1000000000)
On machine boot curburst defaults to maxburst and will automatically
be trimmed to maxburst if you change maxburst. This allows a high
write-rate after boot.
During normal operation writes reduce curburst and accrate increases
curburst (up to maxburst), so periods of inactivity will allow another
burst of write activity later on.
vm.swapcache.read_enable (default 0 - disabled)
Enable the swap cache read intercept. When turned on vn_strategy()
calls will read from the swap cache if possible. When turned off
vn_strategy() calls read from the underlying vnode whether data
is available in the swap cache or not.
vm.swapcache.meta_enable (default 0 - disabled)
Enable swap caching of meta-data (The VM-backed block devices used
by filesystems). The swapcache code scans the VM page inactive
queue for suitable clean VCHR-backed VM pages and writes them to
the swap cache.
vm.swapcache.data_enable (default 0 - disabled)
Enable swap caching of data (Regular files). The swapcache code
scans the VM page inactive queue for suitable clean VREG-backed VM
pages and writes them to the swap cache.
vm.swapcache.maxlaunder (default 128 pages per 1/10 second)
Specifies the maximum number of pages in the inactive queue to
scan every 1/10 second. Set fairly low for the moment but
the default will ultimately be increased to something like 512
The total amount of data written by the swap cache to swap,
in bytes, since boot.
* Call swap_pager_unswapped() in a few more places that need it.
* NFS doesn't use bread/vn_strategy so it has been modified to call
vn_cache_strategy() directly for async IO. Currently we cannot
easily do it for synchronous IO. But async IO will get most of
* The swap cache will use up to 2/3 of available swap space to
cache clean vnode-backed data. Currently once this limit is
reached it will rely on vnode recycling to clean out space
and make room for more.
Vnode recycling is currently excessively limiting the amount of
data which can be cached, since when a vnode is recycled it's
backing VM object is also recycled and the swap cache assignments
are freed. Meta-data has other problems... it can choke the
Dealing with these issues is on the TODO.
Summary of changes:
sys/kern/vfs_bio.c | 115 ++++++++++++++++++++++++++++++++++++++++++++++--
sys/sys/vnode.h | 1 +
sys/vfs/nfs/nfs_bio.c | 27 +++++++++++
sys/vm/swap_pager.c | 2 -
sys/vm/swap_pager.h | 2 +
sys/vm/vm_pageout.c | 1 -
sys/vm/vm_swapcache.c | 64 ++++++++++++++++++++++++++-
7 files changed, 201 insertions(+), 11 deletions(-)
DragonFly BSD source repository