[Tmem-devel] [RFC] vswap: virtio based swap device
Nitin Gupta
ngupta at vflare.org
Sat Jan 2 16:24:04 PST 2010
virtio_vswap driver[1] creates /dev/vswap device which can
be used (only) as a swap disk. Pages swapped to this device
are send directly to host/hypervisor. The host, depending on
various policies, can fail this request in which case the driver
writes the page to guest controlled swap partition (backing_swap
module parameter provides this partition). The size of this
device is set equal to that of backing_swap.
This driver provides an alternate approach for "preswap"
introduced as part of "tmem" patches posted earlier:
http://lwn.net/Articles/338098/
These patches used Xen specific interfaces and made some
intrusive changes to swap code. However, I found the concept
interesting, so developed this virtio based driver which does
not require any kernel changes.
It uses virtio to create a virtual PCI device and also creates
a virtual block device (/dev/vswap) whose only job is to send
pages to host and if that fails, forward request to backing_swap.
It also requires changes to qemu-kvm[2] to expose this virtual
PCI device to guest and is enabled with '-vswap virtio' option.
In current state, it does everything except actually storing
incoming guest pages in host memory :) Also, it uses a single
virtqueue which sends each page to host synchronously. Its just
a proof of concept code to show how virtio framework can be used
to drive such a device. Perhaps a more interesting application would
be an FS-cache backend that sends pages to host as clean pagecache
usually occupies a vast majority of memory and ballooning is too slow
to deal quickly with such large caches when the host is running into
memory pressure.
[1] vswap kernel driver:
http://code.google.com/p/compcache/source/browse/sub-projects/vswap/
[2] qemu-kvm patch to expose vswap PCI device:
http://code.google.com/p/compcache/source/browse/sub-projects/vswap/qemu_kvm_vswap_support.patch
[3] Transcendent Memory (tmem) project page:
http://oss.oracle.com/projects/tmem/
(I intend to merge vswap with ramzswap driver which is already
in mainline, so I did not integrate it with kernel build system.
So, provided just the link to code instead of diff against /dev/null)
Thanks,
Nitin
More information about the Tmem-devel
mailing list