Re: Best strategy for use of swap?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Kenni Lund wrote:
> Hi
> 
> I was wondering; Does it make any sense to use swap inside guests?
> Wouldn't it give better performance to just skip swap entirely in the
> guest, assign it more memory and then increase the swap size on the
> host?

The Gold Rule: do not swap guests.
If a guest does not know it is swapped, and an interrupt comes which
requires memory which is swapped on host but guest thinks it's right
here, all bad things happens.  Guest is not ready to face a situation
when access to system RAM takes several _seconds_, usually it's in
range of nanoseconds.

For another thing, guest knows better what to swap.

Generally, swap serves as a safety measure in case we run into a
situation when the amount of RAM isn't sufficient.  Amount of memory
should be enough for "typical" workload of a system, and swap serves
for situation where it requires a bit more during peaks etc.  For that,
let the particular guest handle the (light) swap load, instead of
slowing down _all_ guests by swapping in host.

(And a side note to stop possible flame war here: there are different
views as of what swap is and is not.  Another "version" is that it
is used to free system memory from tasks which are not used right
now, and so on.  The main rule stands still: there should be very
few swapping.  And for light swapping it does not really matter if
we do swapping a bit faster in host than a bit slower in guest
(due to virtual i/o overhead): the difference isn't that high and
for _small_ amount of swapping it does not really matter speed-
wise.  But swapping in guest makes things more predictable and
smooth due to all the above).

/mjt
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux