From: Michael Tokarev <mjt@tls.msk.ru>
To: Kenni Lund <kenni@kelu.dk>
Cc: kvm <kvm@vger.kernel.org>
Subject: Re: Best strategy for use of swap?
Date: Sun, 24 Jan 2010 13:42:12 +0300 [thread overview]
Message-ID: <4B5C2404.7020007@msgid.tls.msk.ru> (raw)
In-Reply-To: <3b1f68ef1001240221l42f41b3dw764b527ddc88a91d@mail.gmail.com>
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
prev parent reply other threads:[~2010-01-24 10:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-24 10:21 Best strategy for use of swap? Kenni Lund
2010-01-24 10:42 ` Michael Tokarev [this message]
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=4B5C2404.7020007@msgid.tls.msk.ru \
--to=mjt@tls.msk.ru \
--cc=kenni@kelu.dk \
--cc=kvm@vger.kernel.org \
/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