* [Qemu-devel] Swap disks virtualization
@ 2017-03-13 3:42 Christopher Pereira
2017-03-13 11:21 ` Kevin Wolf
0 siblings, 1 reply; 3+ messages in thread
From: Christopher Pereira @ 2017-03-13 3:42 UTC (permalink / raw)
To: qemu-devel
We are currently providing Linux swap disks with QEMU driver, virtio bus
and qcow2 type.
Do you know any alternatives that provide better performance?
Considering that swap disks contain less critical data, QEMU could avoid
disk IOs by using unassigned memory whenever possible. This could also
be handled by the underlying linux filesystem of course. Can we tell
QEMU to use the linux swap disk for creating a guest swap disk? What's
the state of the art regarding swap disks virtualization?
Best regards,
--
*J. Christopher Pereira*
IMATRONIX S.A.
www.imatronix.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] Swap disks virtualization
2017-03-13 3:42 [Qemu-devel] Swap disks virtualization Christopher Pereira
@ 2017-03-13 11:21 ` Kevin Wolf
2017-03-13 14:51 ` Christopher Pereira
0 siblings, 1 reply; 3+ messages in thread
From: Kevin Wolf @ 2017-03-13 11:21 UTC (permalink / raw)
To: Christopher Pereira; +Cc: qemu-devel
Am 13.03.2017 um 04:42 hat Christopher Pereira geschrieben:
> We are currently providing Linux swap disks with QEMU driver, virtio
> bus and qcow2 type.
>
> Do you know any alternatives that provide better performance?
>
> Considering that swap disks contain less critical data, QEMU could
> avoid disk IOs by using unassigned memory whenever possible. This
> could also be handled by the underlying linux filesystem of course.
> Can we tell QEMU to use the linux swap disk for creating a guest
> swap disk? What's the state of the art regarding swap disks
> virtualization?
I think the state of the art is to give the VMs enough memory rather
than making them use a swap disk. If the amount of memory required by
each VM changes dynamically, you can use memory ballooning or hotplug to
increase or decrease the memory size while the VM is running. If you
overcommit the memory, the VMs will automatically be part of the host's
swapping (with all performance implications of swapping, so I think
you'll still want to avoid it on the host, too).
But if you really, really want to use a swap disk in the VM for some
reason, there are three things that I would do:
1. Most importantly, set a good cache mode, cache=unsafe sounds
perfectly fine here because you're not interested in the state of the
image after a crash.
2. Consider putting the image on a tmpfs on the host. cache=unsafe will
already make sure that qemu never forces Linux to write out the data
in its cache with an fsync() call, but Linux will still do background
writeouts. With tmpfs, that won't happen. Of course, the downside is
that you're using actual host memory for it and rely on the host
kernel to swap out the tmpfs rather than data of host processes,
which may or may not work out. But I understand that this is more or
less what you're asking for.
3. You're unlikely to use any interesting features with this image, so
using raw instead of qcow2 could be possible. Don't expect too much
here, especially if your qcow2 image is preallocated, but if you can
use raw, it's always the best performing option.
Even with this, you still have the virtual disk I/O overhead for
accessing the VM's swap space, so it will never be as fast as just
giving the VM more memory.
Kevin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] Swap disks virtualization
2017-03-13 11:21 ` Kevin Wolf
@ 2017-03-13 14:51 ` Christopher Pereira
0 siblings, 0 replies; 3+ messages in thread
From: Christopher Pereira @ 2017-03-13 14:51 UTC (permalink / raw)
To: Kevin Wolf; +Cc: qemu-devel
On 13-Mar-17 08:21, Kevin Wolf wrote:
> I think the state of the art is to give the VMs enough memory rather
Thanks Kevin. This was the answer I expected, so here follows my second
question:
By increasing virtual RAM, I'm afraid that the guest OS may detect and
use more memory, causing the host to pay the price of overcommited
memory being swapped on the host.
If the guest OS (let's say Linux) detects less available memory, isn't
there a chance it will try to use less memory?
My guess is that the OS's should distinguish between physical (fast) and
swap memory (slow) for better memory management.
Any thoughts?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-03-13 14:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-13 3:42 [Qemu-devel] Swap disks virtualization Christopher Pereira
2017-03-13 11:21 ` Kevin Wolf
2017-03-13 14:51 ` Christopher Pereira
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).