<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://linux-kvm.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=LuizCapitulino</id>
	<title>KVM - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://linux-kvm.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=LuizCapitulino"/>
	<link rel="alternate" type="text/html" href="https://linux-kvm.org/page/Special:Contributions/LuizCapitulino"/>
	<updated>2026-04-05T23:14:57Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.5</generator>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=5024</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=5024"/>
		<updated>2014-01-23T20:49:37Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The virtio balloon device allows KVM guests to reduce their memory size (thus relinquishing memory to the host) and to increase it back (thus taking memory from the host).&lt;br /&gt;
&lt;br /&gt;
This feature is mainly intended to support over-committing memory on KVM hosts. That is, hosts that are running VMs whose total memory size is greater than what the host has physically available. For example, a 2G host running two VMs each with 2G would be over-committed.&lt;br /&gt;
&lt;br /&gt;
The balloon device is important to support memory over-commitment because it allows for reducing a guest&#039;s memory size if needed. Suppose, in the previous example, that one of the guests is using 1G and its other 1G is free. We could use the balloon device to reduce this guest&#039;s size from 2G to 1G, this would free 1G in the host allowing the other VM to use it. Of course, if the reduced guest wants to run an application that consumes more than the 1G it currently has, it has to grow again.&lt;br /&gt;
&lt;br /&gt;
That&#039;s the problem with the current balloon device, it&#039;s entirely manual. Someone (or some tool) is supposed to be watching the pressure in the host and guest and then operate the balloon accordingly. This doesn&#039;t work well in practice (if doable at all).&lt;br /&gt;
&lt;br /&gt;
The balloon has to be automatic in order to be really useful. It could like this: when the host is under pressure, it asks guests to relinquish some megas if they can. When/if a guest gets into memory pressure, it gets some megas back from the host. That&#039;s what the automatic ballooning series is about.&lt;br /&gt;
&lt;br /&gt;
=== KVM Forum 2013 presentation slides ===&lt;br /&gt;
&lt;br /&gt;
They can be found [http://www.linux-kvm.org/wiki/images/f/f6/Automatic-ballooning-slides.pdf here], but note that much has changed since this talk.&lt;br /&gt;
&lt;br /&gt;
== Patches and Git trees ==&lt;br /&gt;
&lt;br /&gt;
=== Latest RFC version posted upstream ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039; [http://marc.info/?l=kvm&amp;amp;m=138988948715638&amp;amp;w=2 RFC PATCH 0/4 virtio_balloon: add pressure notification via a new virtqueue]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039; [http://marc.info/?l=kvm&amp;amp;m=138988966315690&amp;amp;w=2 RFC PATCH balloon: add automatic ballooning support]&lt;br /&gt;
&lt;br /&gt;
=== Git trees ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git git://repo.or.cz/linux-2.6/luiz-linux-2.6.git] virtio-balloon/pressure-notification/rfc/v1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[http://repo.or.cz/w/qemu/qmp-unstable.git git://repo.or.cz/qemu/qmp-unstable.git] balloon-automatic/handle-all-events/rfc/v1&lt;br /&gt;
&lt;br /&gt;
== TODO ==&lt;br /&gt;
&lt;br /&gt;
* More performance tests&lt;br /&gt;
* Make it dynamic to enable/disable automatic ballooning&lt;br /&gt;
* Do kernel work required in order to have non-cgroups code using in-kernel memory pressure notification&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
Setup:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10 or higher in your host. Make sure the kernel options CONFIG_CGROUPS and CONFIG_MEMCG are enabled&lt;br /&gt;
# Build QEMU from [[#Git trees| the Git trees section]]&lt;br /&gt;
# Build and install the guest kernel from [[#Git trees| the Git trees section]]&lt;br /&gt;
&lt;br /&gt;
Then start qemu with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;   # qemu [...] -device virtio-balloon,automatic=true&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To see automatic ballooning in action, do the following:&lt;br /&gt;
&lt;br /&gt;
# Generate pressure in your host (like running several VMs in parallel); or connect to QMP and issue the &#039;&#039;balloon-inject-host-pressure&#039;&#039; command&lt;br /&gt;
# You can monitor automatic ballooning activity by issuing &#039;&#039;info balloon&#039;&#039; in QEMU&#039;s monitor (also, I have debug code enabled that will dump a lot of info to stdout when &amp;quot;info balloon&amp;quot; is issued)&lt;br /&gt;
# After the guest has shrinked a bit, you can generate pressure in the guest to see it increasing its size again&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=5021</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=5021"/>
		<updated>2014-01-20T18:32:09Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The virtio balloon device allows KVM guests to reduce their memory size (thus relinquishing memory to the host) and to increase it back (thus taking memory from the host).&lt;br /&gt;
&lt;br /&gt;
This feature is mainly intended to support over-committing memory on KVM hosts. That is, hosts that are running VMs whose total memory size is greater than what the host has physically available. For example, a 2G host running two VMs each with 2G would be over-committed.&lt;br /&gt;
&lt;br /&gt;
The balloon device is important to support memory over-commitment because it allows for reducing a guest&#039;s memory size if needed. Suppose, in the previous example, that one of the guests is using 1G and its other 1G is free. We could use the balloon device to reduce this guest&#039;s size from 2G to 1G, this would free 1G in the host allowing the other VM to use it. Of course, if the reduced guest wants to run an application that consumes more than the 1G it currently has, it has to grow again.&lt;br /&gt;
&lt;br /&gt;
That&#039;s the problem with the current balloon device, it&#039;s entirely manual. Someone (or some tool) is supposed to be watching the pressure in the host and guest and then operate the balloon accordingly. This doesn&#039;t work well in practice (if doable at all).&lt;br /&gt;
&lt;br /&gt;
The balloon has to be automatic in order to be really useful. It could like this: when the host is under pressure, it asks guests to relinquish some megas if they can. When/if a guest gets into memory pressure, it gets some megas back from the host. That&#039;s what the automatic ballooning series is about.&lt;br /&gt;
&lt;br /&gt;
=== KVM Forum 2013 presentation slides ===&lt;br /&gt;
&lt;br /&gt;
They can be found [http://www.linux-kvm.org/wiki/images/f/f6/Automatic-ballooning-slides.pdf here], but note that much has changed since this talk.&lt;br /&gt;
&lt;br /&gt;
== Patches and Git trees ==&lt;br /&gt;
&lt;br /&gt;
=== Latest RFC version posted upstream ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039; [http://marc.info/?l=kvm&amp;amp;m=138988948715638&amp;amp;w=2 RFC PATCH 0/4 virtio_balloon: add pressure notification via a new virtqueue]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039; [http://marc.info/?l=kvm&amp;amp;m=138988966315690&amp;amp;w=2 RFC PATCH balloon: add automatic ballooning support]&lt;br /&gt;
&lt;br /&gt;
=== Git trees ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git git://repo.or.cz/linux-2.6/luiz-linux-2.6.git] virtio-balloon/pressure-notification/rfc.v1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[http://repo.or.cz/w/qemu/qmp-unstable.git git://repo.or.cz/qemu/qmp-unstable.git] balloon-automatic/handle-all-events/rfc.v1&lt;br /&gt;
&lt;br /&gt;
== TODO ==&lt;br /&gt;
&lt;br /&gt;
* More performance tests&lt;br /&gt;
* Make it dynamic to enable/disable automatic ballooning&lt;br /&gt;
* Do kernel work required in order to have non-cgroups code using in-kernel memory pressure notification&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
Setup:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10 or higher in your host. Make sure the kernel options CONFIG_CGROUPS and CONFIG_MEMCG are enabled&lt;br /&gt;
# Build QEMU from [[#Git trees| the Git trees section]]&lt;br /&gt;
# Build and install the guest kernel from [[#Git trees| the Git trees section]]&lt;br /&gt;
&lt;br /&gt;
Then start qemu with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;   # qemu [...] -device virtio-balloon,automatic=true&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To see automatic ballooning in action, do the following:&lt;br /&gt;
&lt;br /&gt;
# Generate pressure in your host (like running several VMs in parallel); or connect to QMP and issue the &#039;&#039;balloon-inject-host-pressure&#039;&#039; command&lt;br /&gt;
# You can monitor automatic ballooning activity by issuing &#039;&#039;info balloon&#039;&#039; in QEMU&#039;s monitor (also, I have debug code enabled that will dump a lot of info to stdout when &amp;quot;info balloon&amp;quot; is issued)&lt;br /&gt;
# After the guest has shrinked a bit, you can generate pressure in the guest to see it increasing its size again&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=5020</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=5020"/>
		<updated>2014-01-20T18:30:24Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The virtio balloon device allows KVM guests to reduce their memory size (thus relinquishing memory to the host) and to increase it back (thus taking memory from the host).&lt;br /&gt;
&lt;br /&gt;
This feature is mainly intended to support over-committing memory on KVM hosts. That is, hosts that are running VMs whose total memory size is greater than what the host has physically available. For example, a 2G host running two VMs each with 2G would be over-committed.&lt;br /&gt;
&lt;br /&gt;
The balloon device is important to support memory over-commitment because it allows for reducing a guest&#039;s memory size if needed. Suppose, in the previous example, that one of the guests is using 1G and its other 1G is free. We could use the balloon device to reduce this guest&#039;s size from 2G to 1G, this would free 1G in the host allowing the other VM to use it. Of course, if the reduced guest wants to run an application that consumes more than the 1G it currently has, it has to grow again.&lt;br /&gt;
&lt;br /&gt;
That&#039;s the problem with the current balloon device, it&#039;s entirely manual. Someone (or some tool) is supposed to be watching the pressure in the host and guest and then operate the balloon accordingly. This doesn&#039;t work well in practice (if doable at all).&lt;br /&gt;
&lt;br /&gt;
The balloon has to be automatic in order to be really useful. It could like this: when the host is under pressure, it asks guests to relinquish some megas if they can. When/if a guest gets into memory pressure, it gets some megas back from the host. That&#039;s what the automatic ballooning series is about.&lt;br /&gt;
&lt;br /&gt;
=== KVM Forum 2013 presentation slides ===&lt;br /&gt;
&lt;br /&gt;
They can be found [http://www.linux-kvm.org/wiki/images/f/f6/Automatic-ballooning-slides.pdf here], but note that much has changed since this talk.&lt;br /&gt;
&lt;br /&gt;
== Patches and Git trees ==&lt;br /&gt;
&lt;br /&gt;
=== Latest RFC version posted upstream ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039; [http://marc.info/?l=kvm&amp;amp;m=138988948715638&amp;amp;w=2 RFC PATCH 0/4 virtio_balloon: add pressure notification via a new virtqueue]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039; [http://marc.info/?l=kvm&amp;amp;m=138988966315690&amp;amp;w=2 RFC PATCH balloon: add automatic ballooning support]&lt;br /&gt;
&lt;br /&gt;
=== Git trees ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git git://repo.or.cz/linux-2.6/luiz-linux-2.6.git] virtio-balloon/pressure-notification/rfc.v1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[http://repo.or.cz/w/qemu/qmp-unstable.git git://repo.or.cz/qemu/qmp-unstable.git] balloon-automatic/handle-all-events/rfc.v1&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
Setup:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10 or higher in your host. Make sure the kernel options CONFIG_CGROUPS and CONFIG_MEMCG are enabled&lt;br /&gt;
# Build QEMU from [[#Git trees| the Git trees section]]&lt;br /&gt;
# Build and install the guest kernel from [[#Git trees| the Git trees section]]&lt;br /&gt;
&lt;br /&gt;
Then start qemu with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;   # qemu [...] -device virtio-balloon,automatic=true&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To see automatic ballooning in action, do the following:&lt;br /&gt;
&lt;br /&gt;
# Generate pressure in your host (like running several VMs in parallel); or connect to QMP and issue the &#039;&#039;balloon-inject-host-pressure&#039;&#039; command&lt;br /&gt;
# You can monitor automatic ballooning activity by issuing &#039;&#039;info balloon&#039;&#039; in QEMU&#039;s monitor (also, I have debug code enabled that will dump a lot of info to stdout when &amp;quot;info balloon&amp;quot; is issued)&lt;br /&gt;
# After the guest has shrinked a bit, you can generate pressure in the guest to see it increasing its size again&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=5018</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=5018"/>
		<updated>2014-01-16T20:44:24Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The balloon feature allows KVM guests to reduce their memory size (thus relinquishing memory to the host) and to increase back (thus taking memory from the host).&lt;br /&gt;
&lt;br /&gt;
This feature is mainly intended to support memory over-committed hosts. That is, hosts that are running VMs whose total memory size is greater than what the host has physically available. For example, a 2G host running two VMs each with 2G would be over-committed.&lt;br /&gt;
&lt;br /&gt;
The balloon feature is important to support memory over-commitment because it allows for reducing a guest&#039;s memory size if needed. Suppose, in the example above, that one of the guests is using 1G and its other 1G is free. We could use the balloon to reduce this guest&#039;s size from 2G to 1G, this would free 1G in the host allowing the other VM to use it. Of course, if the reduced guest wants to run an application that consumes more than the 1G it currently has, it has to grow again.&lt;br /&gt;
&lt;br /&gt;
That&#039;s the problem with the current balloon feature, it&#039;s entirely manual. Someone (or some tool) is supposed to be watching the pressure in the host and guest and then operate the balloon accordingly. This is just not doable in practice.&lt;br /&gt;
&lt;br /&gt;
The balloon has to be automatic in order to be really useful. It could like this: when the host is under pressure, VMs with spare memory automatically reduce their size by some megas. When a VM get into memory pressure (maybe because they relinquished memory to host) it increases its size by some megas. That&#039;s exactly what the automatic ballooning patch series does.&lt;br /&gt;
&lt;br /&gt;
=== KVM Forum 2013 presentation slides ===&lt;br /&gt;
&lt;br /&gt;
They can be found [http://www.linux-kvm.org/wiki/images/f/f6/Automatic-ballooning-slides.pdf here], but note that much has changed since this talk.&lt;br /&gt;
&lt;br /&gt;
== Patches and Git trees ==&lt;br /&gt;
&lt;br /&gt;
=== Latest RFC version posted upstream ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039; [http://marc.info/?l=kvm&amp;amp;m=138988948715638&amp;amp;w=2 RFC PATCH 0/4 virtio_balloon: add pressure notification via a new virtqueue]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039; [http://marc.info/?l=kvm&amp;amp;m=138988966315690&amp;amp;w=2 RFC PATCH balloon: add automatic ballooning support]&lt;br /&gt;
&lt;br /&gt;
=== Git trees ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git git://repo.or.cz/linux-2.6/luiz-linux-2.6.git] virtio-balloon/pressure-notification/rfc.v1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[http://repo.or.cz/w/qemu/qmp-unstable.git git://repo.or.cz/qemu/qmp-unstable.git] balloon-automatic/handle-all-events/rfc.v1&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
Setup:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10 or higher in your host. Make sure the kernel options CONFIG_CGROUPS and CONFIG_MEMCG are enabled&lt;br /&gt;
# Build QEMU from [[#Git trees| the Git trees section]]&lt;br /&gt;
# Build and install the guest kernel from [[#Git trees| the Git trees section]]&lt;br /&gt;
&lt;br /&gt;
Then start qemu with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;   # qemu [...] -device virtio-balloon,automatic=true&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To see automatic ballooning in action, do the following:&lt;br /&gt;
&lt;br /&gt;
# Generate pressure in your host (like running several VMs in parallel); or connect to QMP and issue the &#039;&#039;balloon-inject-host-pressure&#039;&#039; command&lt;br /&gt;
# You can monitor automatic ballooning activity by issuing &#039;&#039;info balloon&#039;&#039; in QEMU&#039;s monitor (also, I have debug code enabled that will dump a lot of info to stdout when &amp;quot;info balloon&amp;quot; is issued)&lt;br /&gt;
# After the guest has shrinked a bit, you can generate pressure in the guest to see it increasing its size again&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=5017</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=5017"/>
		<updated>2014-01-16T20:39:10Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The balloon feature allows KVM guests to reduce their memory size (thus relinquishing memory to the host) and to increase back (thus taking memory from the host).&lt;br /&gt;
&lt;br /&gt;
This feature is mainly intended to support memory over-committed hosts. That is, hosts that are running VMs whose total memory size is greater than what the host has physically available. For example, a 2G host running two VMs each with 2G would be over-committed.&lt;br /&gt;
&lt;br /&gt;
The balloon feature is important to support memory over-commitment because it allows for reducing a guest&#039;s memory size if needed. Suppose, in the example above, that one of the guests is using 1G and its other 1G is free. We could use the balloon to reduce this guest&#039;s size from 2G to 1G, this would free 1G in the host allowing the other VM to use it. Of course, if the reduced guest wants to run an application that consumes more than the 1G it currently has, it has to grow again.&lt;br /&gt;
&lt;br /&gt;
That&#039;s the problem with the current balloon feature, it&#039;s entirely manual. Someone (or some tool) is supposed to be watching the pressure in the host and guest and then operate the balloon accordingly. This is just not doable in practice.&lt;br /&gt;
&lt;br /&gt;
The balloon has to be automatic in order to be really useful. It could like this: when the host is under pressure, VMs with spare memory automatically reduce their size by some megas. When a VM get into memory pressure (maybe because they relinquished memory to host) it increases its size by some megas. That&#039;s exactly what the automatic ballooning patch series does.&lt;br /&gt;
&lt;br /&gt;
=== KVM Forum 2013 presentation slides ===&lt;br /&gt;
&lt;br /&gt;
They can be found [http://www.linux-kvm.org/wiki/images/f/f6/Automatic-ballooning-slides.pdf here]. But note that much has changed since this talk.&lt;br /&gt;
&lt;br /&gt;
== Patches and Git trees ==&lt;br /&gt;
&lt;br /&gt;
=== Latest RFC version posted upstream ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039; [http://marc.info/?l=kvm&amp;amp;m=138988948715638&amp;amp;w=2 RFC PATCH 0/4 virtio_balloon: add pressure notification via a new virtqueue]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039; [http://marc.info/?l=kvm&amp;amp;m=138988966315690&amp;amp;w=2 RFC PATCH balloon: add automatic ballooning support]&lt;br /&gt;
&lt;br /&gt;
=== Git trees ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git git://repo.or.cz/linux-2.6/luiz-linux-2.6.git] virtio-balloon/pressure-notification/rfc.v1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[http://repo.or.cz/w/qemu/qmp-unstable.git git://repo.or.cz/qemu/qmp-unstable.git] balloon-automatic/handle-all-events/rfc.v1&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
Setup:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10 or higher in your host. Make sure the kernel options CONFIG_CGROUPS and CONFIG_MEMCG are enabled&lt;br /&gt;
# Build QEMU from [[#Git trees| the Git trees section]]&lt;br /&gt;
# Build and install the guest kernel from [[#Git trees| the Git trees section]]&lt;br /&gt;
&lt;br /&gt;
Then start qemu with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;   # qemu [...] -device virtio-balloon,automatic=true&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To see automatic ballooning in action, do the following:&lt;br /&gt;
&lt;br /&gt;
# Generate pressure in your host (like running several VMs in parallel); or connect to QMP and issue the &#039;&#039;balloon-inject-host-pressure&#039;&#039; command&lt;br /&gt;
# You can monitor automatic ballooning activity by issuing &#039;&#039;info balloon&#039;&#039; in QEMU&#039;s monitor (also, I have debug code enabled that will dump a lot of info to stdout when &amp;quot;info balloon&amp;quot; is issued)&lt;br /&gt;
# After the guest has shrinked a bit, you can generate pressure in the guest to see it increasing its size again&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=5016</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=5016"/>
		<updated>2014-01-16T20:35:26Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The balloon feature allows KVM guests to reduce their memory size (thus relinquishing memory to the host) and to increase back (thus taking memory from the host).&lt;br /&gt;
&lt;br /&gt;
This feature is mainly intended to support memory over-committed hosts. That is, hosts that are running VMs whose total memory size is greater than what the host has physically available. For example, a 2G host running two VMs each with 2G would be over-committed.&lt;br /&gt;
&lt;br /&gt;
The balloon feature is important to support memory over-commitment because it allows for reducing a guest&#039;s memory size if needed. Suppose, in the example above, that one of the guests is using 1G and its other 1G is free. We could use the balloon to reduce this guest&#039;s size from 2G to 1G, this would free 1G in the host allowing the other VM to use it. Of course, if the reduced guest wants to run an application that consumes more than the 1G it currently has, it has to grow again.&lt;br /&gt;
&lt;br /&gt;
That&#039;s the problem with the current balloon feature, it&#039;s entirely manual. Someone (or some tool) is supposed to be watching the pressure in the host and guest and then operate the balloon accordingly. This is just not doable in practice.&lt;br /&gt;
&lt;br /&gt;
The balloon has to be automatic in order to be really useful. It could like this: when the host is under pressure, VMs with spare memory automatically reduce their size by some megas. When a VM get into memory pressure (maybe because they relinquished memory to host) it increases its size by some megas. That&#039;s exactly what the automatic ballooning patch series does.&lt;br /&gt;
&lt;br /&gt;
=== KVM Forum 2013 presentation slides ===&lt;br /&gt;
&lt;br /&gt;
They can be found [http://www.linux-kvm.org/wiki/images/f/f6/Automatic-ballooning-slides.pdf here]. But note that much has changed since this talk.&lt;br /&gt;
&lt;br /&gt;
== Patches and Git trees ==&lt;br /&gt;
&lt;br /&gt;
=== Latest RFC version posted upstream ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039; [http://marc.info/?l=kvm&amp;amp;m=138988948715638&amp;amp;w=2 RFC PATCH 0/4 virtio_balloon: add pressure notification via a new virtqueue]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039; [http://marc.info/?l=kvm&amp;amp;m=138988966315690&amp;amp;w=2 RFC PATCH balloon: add automatic ballooning support]&lt;br /&gt;
&lt;br /&gt;
=== Git trees ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/pressure-notification/rfc.v1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/qemu/qmp-unstable.git balloon-automatic/handle-all-events/rfc.v1&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
Setup:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10 or higher in your host. Make sure the kernel options CONFIG_CGROUPS and CONFIG_MEMCG are enabled&lt;br /&gt;
# Build QEMU from [[#Git trees| the Git trees section]]&lt;br /&gt;
# Build and install the guest kernel from [[#Git trees| the Git trees section]]&lt;br /&gt;
&lt;br /&gt;
Then start qemu with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;   # qemu [...] -device virtio-balloon,automatic=true&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To see automatic ballooning in action, do the following:&lt;br /&gt;
&lt;br /&gt;
# Generate pressure in your host (like running several VMs in parallel); or connect to QMP and issue the &#039;&#039;balloon-inject-host-pressure&#039;&#039; command&lt;br /&gt;
# You can monitor automatic ballooning activity by issuing &#039;&#039;info balloon&#039;&#039; in QEMU&#039;s monitor (also, I have debug code enabled that will dump a lot of info to stdout when &amp;quot;info balloon&amp;quot; is issued)&lt;br /&gt;
# After the guest has shrinked a bit, you can generate pressure in the guest to see it increasing its size again&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=5015</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=5015"/>
		<updated>2014-01-16T20:31:29Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The balloon feature allows KVM guests to reduce their memory size (thus relinquishing memory to the host) and to increase back (thus taking memory from the host).&lt;br /&gt;
&lt;br /&gt;
This feature is mainly intended to support memory over-committed hosts. That is, hosts that are running VMs whose total memory size is greater than what the host has physically available. For example, a 2G host running two VMs each with 2G would be over-committed.&lt;br /&gt;
&lt;br /&gt;
The balloon feature is important to support memory over-commitment because it allows for reducing a guest&#039;s memory size if needed. Suppose, in the example above, that one of the guests is using 1G and its other 1G is free. We could use the balloon to reduce this guest&#039;s size from 2G to 1G, this would free 1G in the host allowing the other VM to use it. Of course, if the reduced guest wants to run an application that consumes more than the 1G it currently has, it has to grow again.&lt;br /&gt;
&lt;br /&gt;
That&#039;s the problem with the current balloon feature, it&#039;s entirely manual. Someone (or some tool) is supposed to be watching the pressure in the host and guest and then operate the balloon accordingly. This is just not doable in practice.&lt;br /&gt;
&lt;br /&gt;
The balloon has to be automatic in order to be really useful. It could like this: when the host is under pressure, VMs with spare memory automatically reduce their size by some megas. When a VM get into memory pressure (maybe because they relinquished memory to host) it increases its size by some megas. That&#039;s exactly what the automatic ballooning patch series does.&lt;br /&gt;
&lt;br /&gt;
=== KVM Forum 2013 presentation slides ===&lt;br /&gt;
&lt;br /&gt;
They can be found [http://www.linux-kvm.org/wiki/images/f/f6/Automatic-ballooning-slides.pdf here]. But note that much has changed since this talk.&lt;br /&gt;
&lt;br /&gt;
== Patches and Git trees ==&lt;br /&gt;
&lt;br /&gt;
=== Latest RFC version posted upstream ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039; [http://marc.info/?l=kvm&amp;amp;m=138988948715638&amp;amp;w=2 [RFC PATCH 0/4] virtio_balloon: add pressure notification via a new virtqueue]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039; [http://marc.info/?l=kvm&amp;amp;m=138988966315690&amp;amp;w=2 RFC PATCH balloon: add automatic ballooning support]&lt;br /&gt;
&lt;br /&gt;
=== Git trees ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/pressure-notification/rfc.v1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/qemu/qmp-unstable.git balloon-automatic/handle-all-events/rfc.v1&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
Setup:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10 or higher in your host. Make sure the kernel options CONFIG_CGROUPS and CONFIG_MEMCG are enabled&lt;br /&gt;
# Build QEMU from [[#Git trees| the Git trees section]]&lt;br /&gt;
# Build and install the guest kernel from [[#Git trees| the Git trees section]]&lt;br /&gt;
&lt;br /&gt;
Then start qemu with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;   # qemu [...] -device virtio-balloon,automatic=true&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To see automatic ballooning in action, do the following:&lt;br /&gt;
&lt;br /&gt;
# Connect to QMP and issue the balloon-inject-host-pressure command. Or,&lt;br /&gt;
generate pressure in your host (like running several VMs in parallel)&lt;br /&gt;
# You can monitor automatic ballooning activity by issuing &amp;quot;info balloon&amp;quot; in QEMU&#039;s monitor (also, I have debug code enabled that will dump a lot of info to stdout when &amp;quot;info balloon&amp;quot; is issued)&lt;br /&gt;
# After guest has shrinked a bit, you can generate pressure in the guest to see it increasing its size again&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=5014</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=5014"/>
		<updated>2014-01-16T20:23:30Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The balloon feature allows KVM guests to reduce their memory size (thus relinquishing memory to the host) and to increase back (thus taking memory from the host).&lt;br /&gt;
&lt;br /&gt;
This feature is mainly intended to support memory over-committed hosts. That is, hosts that are running VMs whose total memory size is greater than what the host has physically available. For example, a 2G host running two VMs each with 2G would be over-committed.&lt;br /&gt;
&lt;br /&gt;
The balloon feature is important to support memory over-commitment because it allows for reducing a guest&#039;s memory size if needed. Suppose, in the example above, that one of the guests is using 1G and its other 1G is free. We could use the balloon to reduce this guest&#039;s size from 2G to 1G, this would free 1G in the host allowing the other VM to use it. Of course, if the reduced guest wants to run an application that consumes more than the 1G it currently has, it has to grow again.&lt;br /&gt;
&lt;br /&gt;
That&#039;s the problem with the current balloon feature, it&#039;s entirely manual. Someone (or some tool) is supposed to be watching the pressure in the host and guest and then operate the balloon accordingly. This is just not doable in practice.&lt;br /&gt;
&lt;br /&gt;
The balloon has to be automatic in order to be really useful. It could like this: when the host is under pressure, VMs with spare memory automatically reduce their size by some megas. When a VM get into memory pressure (maybe because they relinquished memory to host) it increases its size by some megas. That&#039;s exactly what the automatic ballooning patch series does.&lt;br /&gt;
&lt;br /&gt;
=== KVM Forum 2013 presentation slides ===&lt;br /&gt;
&lt;br /&gt;
They can be found [http://www.linux-kvm.org/wiki/images/f/f6/Automatic-ballooning-slides.pdf here]. But note that much has changed since this talk.&lt;br /&gt;
&lt;br /&gt;
== Patches and Git trees ==&lt;br /&gt;
&lt;br /&gt;
=== Latest RFC version posted upstream ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039; [http://marc.info/?l=kvm&amp;amp;m=138988948715638&amp;amp;w=2 [RFC PATCH 0/4] virtio_balloon: add pressure notification via a new virtqueue]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039; [http://marc.info/?l=kvm&amp;amp;m=138988966315690&amp;amp;w=2 RFC PATCH balloon: add automatic ballooning support]&lt;br /&gt;
&lt;br /&gt;
=== Git trees ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/pressure-notification/rfc.v1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/qemu/qmp-unstable.git balloon-automatic/handle-all-events/rfc.v1&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
You have to setup the following before experimenting with auto-ballooning:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10 or higher in your host. Make sure the kernel options CONFIG_CGROUPS and CONFIG_MEMCG are enabled&lt;br /&gt;
# Build and install QEMU from [[#Git trees| the Git trees section]] (suggest the RFC one)&lt;br /&gt;
# Build and install the guest kernel from [[#Git trees| the Git trees section]] (suggest the RFC one)&lt;br /&gt;
&lt;br /&gt;
After setting up the above, do the following to experiment with automatic deflate:&lt;br /&gt;
&lt;br /&gt;
# Pass &#039;&#039;-balloon virtio,auto-balloon=true&#039;&#039; when starting QEMU&lt;br /&gt;
# Wait for the guest to boot, then generate some memory pressure in the guest (say a kernel build with lots of jobs)&lt;br /&gt;
# Switch to QEMU&#039;s monitor and shrink the guest (say from 1G to 200MB)&lt;br /&gt;
# Watch the guest increase its memory by running &amp;quot;free&amp;quot; within the guest (or &amp;quot;info balloon&amp;quot; in QEMU)&lt;br /&gt;
&lt;br /&gt;
There are two ways to play with automatic inflate:&lt;br /&gt;
&lt;br /&gt;
# The simplest thing is to create a memory constrained cgroup, but this will require code changes in QEMU because it&#039;s hardcoded to use the root cgroup (yes, we need a command-line option for that)&lt;br /&gt;
# If you don&#039;t want to play with cgroups, you can overcommit your host by running several VMs in parallel. The VMs have to run a heavy memory workload&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=5013</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=5013"/>
		<updated>2014-01-16T20:07:55Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The balloon feature allows KVM guests to reduce their memory size (thus relinquishing memory to the host) and to increase back (thus taking memory from the host).&lt;br /&gt;
&lt;br /&gt;
This feature is mainly intended to support memory over-committed hosts. That is, hosts that are running VMs whose total memory size is greater than what the host has physically available. For example, a 2G host running two VMs each with 2G would be over-committed.&lt;br /&gt;
&lt;br /&gt;
The balloon feature is important to support memory over-commitment because it allows for reducing a guest&#039;s memory size if needed. Suppose, in the example above, that one of the guests is using 1G and its other 1G is free. We could use the balloon to reduce this guest&#039;s size to 1G, this would free 1G in the host allowing the other VM to use it. Of course, if the reduced guest wants to run an application that consumes more than the 1G it currently has, it has to grow again.&lt;br /&gt;
&lt;br /&gt;
That&#039;s the problem with the current balloon feature, it&#039;s entirely manual. Someone (or some tool) is supposed to be watching the pressure in the host and guest and then operate the balloon accordingly. This is just not doable in practice.&lt;br /&gt;
&lt;br /&gt;
The balloon has to be automatic in order to be really useful. It could like this: when the host is under pressure, VMs with spare memory automatically reduce their size by some megas. When a VM get into pressure (maybe because they relinquished memory to host) it increases its size by some megas. That&#039;s exactly what the automatic ballooning feature does.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
KVM guests have a driver called the balloon driver. This driver allows guests to shrink and grow their memory. The balloon driver supports two operations:&lt;br /&gt;
&lt;br /&gt;
* Inflate: memory is taken from the guest and given to the host (guest shrinks)&lt;br /&gt;
* Deflate: memory is returned from the host to the guest (guest grows)&lt;br /&gt;
&lt;br /&gt;
Today, both operations are manual. The automatic ballooning project is about making them completely automatic, based on host and guest needs.&lt;br /&gt;
&lt;br /&gt;
=== KVM Forum 2013 presentation slides ===&lt;br /&gt;
&lt;br /&gt;
They can be found [http://www.linux-kvm.org/wiki/images/f/f6/Automatic-ballooning-slides.pdf here]&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is performed by QEMU (ie. the KVM host). QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events so that it&#039;s notified when the host is under memory pressure.&lt;br /&gt;
&lt;br /&gt;
Current patches have pre-defined values to be used by QEMU when it receives a memory pressure notification from the host kernel. Those values are:&lt;br /&gt;
&lt;br /&gt;
* 1MB on LOW pressure&lt;br /&gt;
* 2MB on MEDIUM pressure&lt;br /&gt;
* 4MB on CRITICAL pressure&lt;br /&gt;
&lt;br /&gt;
For example, suppose the host is facing MEDIUM pressure and notifies QEMU. When QEMU receives the event, it asks the guest to inflate its balloon by 2MB. The guest in turn will shrink itself by 2MB and give that memory to the host.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the guest or, more specifically, by the balloon driver.&lt;br /&gt;
&lt;br /&gt;
The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure, and the number of pages to be returned to the kernel is passed to the callback. The balloon driver shrink callback deflates the guest&#039;s balloon.&lt;br /&gt;
&lt;br /&gt;
For example, suppose the guest shrunk itself because of pressure in the host. But after some time, the guest is running more applications which causes memory pressure in the guest due its reduced size. The guest kernel then starts reclaiming memory and calls all shrink callbacks. That&#039;s when the balloon driver&#039;s shrink callback runs, and deflates the balloon by the number of pages specified. This causes the guest to grow again.&lt;br /&gt;
&lt;br /&gt;
== Git trees ==&lt;br /&gt;
&lt;br /&gt;
=== Latest RFC version posted upstream ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/rfc.v2 (or grab the patch [http://repo.or.cz/w/qemu/qmp-unstable.git/commit/59fec94e6396d6c32cdce47777440c3a988be63d here])&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/rfc (or grab the first two patches from the [http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git/shortlog/refs/heads/virtio-balloon/auto-deflate/rfc web interface])&lt;br /&gt;
&lt;br /&gt;
=== Development branches ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/current&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/current&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
You have to setup the following before experimenting with auto-ballooning:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10 or higher in your host. Make sure the kernel options CONFIG_CGROUPS and CONFIG_MEMCG are enabled&lt;br /&gt;
# Build and install QEMU from [[#Git trees| the Git trees section]] (suggest the RFC one)&lt;br /&gt;
# Build and install the guest kernel from [[#Git trees| the Git trees section]] (suggest the RFC one)&lt;br /&gt;
&lt;br /&gt;
After setting up the above, do the following to experiment with automatic deflate:&lt;br /&gt;
&lt;br /&gt;
# Pass &#039;&#039;-balloon virtio,auto-balloon=true&#039;&#039; when starting QEMU&lt;br /&gt;
# Wait for the guest to boot, then generate some memory pressure in the guest (say a kernel build with lots of jobs)&lt;br /&gt;
# Switch to QEMU&#039;s monitor and shrink the guest (say from 1G to 200MB)&lt;br /&gt;
# Watch the guest increase its memory by running &amp;quot;free&amp;quot; within the guest (or &amp;quot;info balloon&amp;quot; in QEMU)&lt;br /&gt;
&lt;br /&gt;
There are two ways to play with automatic inflate:&lt;br /&gt;
&lt;br /&gt;
# The simplest thing is to create a memory constrained cgroup, but this will require code changes in QEMU because it&#039;s hardcoded to use the root cgroup (yes, we need a command-line option for that)&lt;br /&gt;
# If you don&#039;t want to play with cgroups, you can overcommit your host by running several VMs in parallel. The VMs have to run a heavy memory workload&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=5012</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=5012"/>
		<updated>2014-01-16T20:00:02Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The balloon feature allows KVM guests to reduce their memory size (thus relinquishing memory to the host) and to increase back (thus taking memory from the host).&lt;br /&gt;
&lt;br /&gt;
This feature is mainly intended to support memory over-committed hosts. That is, hosts that are running VMs whose the total memory is greater than what the host has physically available. For example, a host with 2G free of memory is running two VMs each with 2G would be over-committed.&lt;br /&gt;
&lt;br /&gt;
The balloon feature is important to support memory over-commitment because it allows for reducing a guest&#039;s memory size if needed. Suppose, in the example above, one of the guests is using 1G and its other 1G free. We could use the balloon to reduce this guest&#039;s size to 1G, this would free 1G in the host allowing the other VM to use it. Of course, if the reduced guest wants to run an application that consumes more than 1G it currently has, it has to grow again.&lt;br /&gt;
&lt;br /&gt;
That&#039;s the problem with the current balloon feature, it&#039;s entirely manual. Someone (or some tool) is supposed to be watching the pressure in the host and guest and then operate the balloon accordingly. This is just not doable in real life.&lt;br /&gt;
&lt;br /&gt;
In order to solve this problem we have to make the balloon automatic. It could like this: when the host is under pressure, VMs with spare memory automatically reduce their size by some megas. When a VM get into pressure (maybe because they relinquished memory to host) it increases its size by some megas. That&#039;s exactly what the automatic ballooning feature does.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
KVM guests have a driver called the balloon driver. This driver allows guests to shrink and grow their memory. The balloon driver supports two operations:&lt;br /&gt;
&lt;br /&gt;
* Inflate: memory is taken from the guest and given to the host (guest shrinks)&lt;br /&gt;
* Deflate: memory is returned from the host to the guest (guest grows)&lt;br /&gt;
&lt;br /&gt;
Today, both operations are manual. The automatic ballooning project is about making them completely automatic, based on host and guest needs.&lt;br /&gt;
&lt;br /&gt;
=== KVM Forum 2013 presentation slides ===&lt;br /&gt;
&lt;br /&gt;
They can be found [http://www.linux-kvm.org/wiki/images/f/f6/Automatic-ballooning-slides.pdf here]&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is performed by QEMU (ie. the KVM host). QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events so that it&#039;s notified when the host is under memory pressure.&lt;br /&gt;
&lt;br /&gt;
Current patches have pre-defined values to be used by QEMU when it receives a memory pressure notification from the host kernel. Those values are:&lt;br /&gt;
&lt;br /&gt;
* 1MB on LOW pressure&lt;br /&gt;
* 2MB on MEDIUM pressure&lt;br /&gt;
* 4MB on CRITICAL pressure&lt;br /&gt;
&lt;br /&gt;
For example, suppose the host is facing MEDIUM pressure and notifies QEMU. When QEMU receives the event, it asks the guest to inflate its balloon by 2MB. The guest in turn will shrink itself by 2MB and give that memory to the host.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the guest or, more specifically, by the balloon driver.&lt;br /&gt;
&lt;br /&gt;
The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure, and the number of pages to be returned to the kernel is passed to the callback. The balloon driver shrink callback deflates the guest&#039;s balloon.&lt;br /&gt;
&lt;br /&gt;
For example, suppose the guest shrunk itself because of pressure in the host. But after some time, the guest is running more applications which causes memory pressure in the guest due its reduced size. The guest kernel then starts reclaiming memory and calls all shrink callbacks. That&#039;s when the balloon driver&#039;s shrink callback runs, and deflates the balloon by the number of pages specified. This causes the guest to grow again.&lt;br /&gt;
&lt;br /&gt;
== Git trees ==&lt;br /&gt;
&lt;br /&gt;
=== Latest RFC version posted upstream ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/rfc.v2 (or grab the patch [http://repo.or.cz/w/qemu/qmp-unstable.git/commit/59fec94e6396d6c32cdce47777440c3a988be63d here])&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/rfc (or grab the first two patches from the [http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git/shortlog/refs/heads/virtio-balloon/auto-deflate/rfc web interface])&lt;br /&gt;
&lt;br /&gt;
=== Development branches ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/current&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/current&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
You have to setup the following before experimenting with auto-ballooning:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10 or higher in your host. Make sure the kernel options CONFIG_CGROUPS and CONFIG_MEMCG are enabled&lt;br /&gt;
# Build and install QEMU from [[#Git trees| the Git trees section]] (suggest the RFC one)&lt;br /&gt;
# Build and install the guest kernel from [[#Git trees| the Git trees section]] (suggest the RFC one)&lt;br /&gt;
&lt;br /&gt;
After setting up the above, do the following to experiment with automatic deflate:&lt;br /&gt;
&lt;br /&gt;
# Pass &#039;&#039;-balloon virtio,auto-balloon=true&#039;&#039; when starting QEMU&lt;br /&gt;
# Wait for the guest to boot, then generate some memory pressure in the guest (say a kernel build with lots of jobs)&lt;br /&gt;
# Switch to QEMU&#039;s monitor and shrink the guest (say from 1G to 200MB)&lt;br /&gt;
# Watch the guest increase its memory by running &amp;quot;free&amp;quot; within the guest (or &amp;quot;info balloon&amp;quot; in QEMU)&lt;br /&gt;
&lt;br /&gt;
There are two ways to play with automatic inflate:&lt;br /&gt;
&lt;br /&gt;
# The simplest thing is to create a memory constrained cgroup, but this will require code changes in QEMU because it&#039;s hardcoded to use the root cgroup (yes, we need a command-line option for that)&lt;br /&gt;
# If you don&#039;t want to play with cgroups, you can overcommit your host by running several VMs in parallel. The VMs have to run a heavy memory workload&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4982</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4982"/>
		<updated>2013-11-11T14:20:32Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to KVM guests performace (eg. swapping) or even extreme to the point where the kernel may kill a VM or an important virt stack component.&lt;br /&gt;
&lt;br /&gt;
To help avoiding this scenario, a KVM guest could automatically give memory to the host when the host is facing memory pressure. By doing so the guest may also get into memory pressure so we need a way to allow the guest to automatically get memory back.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
KVM guests have a driver called the balloon driver. This driver allows guests to shrink and grow their memory. The balloon driver supports two operations:&lt;br /&gt;
&lt;br /&gt;
* Inflate: memory is taken from the guest and given to the host (guest shrinks)&lt;br /&gt;
* Deflate: memory is returned from the host to the guest (guest grows)&lt;br /&gt;
&lt;br /&gt;
Today, both operations are manual. The automatic ballooning project is about making them completely automatic, based on host and guest needs.&lt;br /&gt;
&lt;br /&gt;
=== KVM Forum 2013 presentation slides ===&lt;br /&gt;
&lt;br /&gt;
They can be found [http://www.linux-kvm.org/wiki/images/f/f6/Automatic-ballooning-slides.pdf here]&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is performed by QEMU (ie. the KVM host). QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events so that it&#039;s notified when the host is under memory pressure.&lt;br /&gt;
&lt;br /&gt;
Current patches have pre-defined values to be used by QEMU when it receives a memory pressure notification from the host kernel. Those values are:&lt;br /&gt;
&lt;br /&gt;
* 1MB on LOW pressure&lt;br /&gt;
* 2MB on MEDIUM pressure&lt;br /&gt;
* 4MB on CRITICAL pressure&lt;br /&gt;
&lt;br /&gt;
For example, suppose the host is facing MEDIUM pressure and notifies QEMU. When QEMU receives the event, it asks the guest to inflate its balloon by 2MB. The guest in turn will shrink itself by 2MB and give that memory to the host.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the guest or, more specifically, by the balloon driver.&lt;br /&gt;
&lt;br /&gt;
The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure, and the number of pages to be returned to the kernel is passed to the callback. The balloon driver shrink callback deflates the guest&#039;s balloon.&lt;br /&gt;
&lt;br /&gt;
For example, suppose the guest shrunk itself because of pressure in the host. But after some time, the guest is running more applications which causes memory pressure in the guest due its reduced size. The guest kernel then starts reclaiming memory and calls all shrink callbacks. That&#039;s when the balloon driver&#039;s shrink callback runs, and deflates the balloon by the number of pages specified. This causes the guest to grow again.&lt;br /&gt;
&lt;br /&gt;
== Git trees ==&lt;br /&gt;
&lt;br /&gt;
=== Latest RFC version posted upstream ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/rfc.v2 (or grab the patch [http://repo.or.cz/w/qemu/qmp-unstable.git/commit/59fec94e6396d6c32cdce47777440c3a988be63d here])&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/rfc (or grab the first two patches from the [http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git/shortlog/refs/heads/virtio-balloon/auto-deflate/rfc web interface])&lt;br /&gt;
&lt;br /&gt;
=== Development branches ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/current&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/current&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
You have to setup the following before experimenting with auto-ballooning:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10 or higher in your host. Make sure the kernel options CONFIG_CGROUPS and CONFIG_MEMCG are enabled&lt;br /&gt;
# Build and install QEMU from [[#Git trees| the Git trees section]] (suggest the RFC one)&lt;br /&gt;
# Build and install the guest kernel from [[#Git trees| the Git trees section]] (suggest the RFC one)&lt;br /&gt;
&lt;br /&gt;
After setting up the above, do the following to experiment with automatic deflate:&lt;br /&gt;
&lt;br /&gt;
# Pass &#039;&#039;-balloon virtio,auto-balloon=true&#039;&#039; when starting QEMU&lt;br /&gt;
# Wait for the guest to boot, then generate some memory pressure in the guest (say a kernel build with lots of jobs)&lt;br /&gt;
# Switch to QEMU&#039;s monitor and shrink the guest (say from 1G to 200MB)&lt;br /&gt;
# Watch the guest increase its memory by running &amp;quot;free&amp;quot; within the guest (or &amp;quot;info balloon&amp;quot; in QEMU)&lt;br /&gt;
&lt;br /&gt;
There are two ways to play with automatic inflate:&lt;br /&gt;
&lt;br /&gt;
# The simplest thing is to create a memory constrained cgroup, but this will require code changes in QEMU because it&#039;s hardcoded to use the root cgroup (yes, we need a command-line option for that)&lt;br /&gt;
# If you don&#039;t want to play with cgroups, you can overcommit your host by running several VMs in parallel. The VMs have to run a heavy memory workload&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=File:Automatic-ballooning-slides.pdf&amp;diff=4981</id>
		<title>File:Automatic-ballooning-slides.pdf</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=File:Automatic-ballooning-slides.pdf&amp;diff=4981"/>
		<updated>2013-11-11T14:17:01Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: Automatic Ballooning talk slides&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Automatic Ballooning talk slides&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4889</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4889"/>
		<updated>2013-10-10T14:08:57Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to KVM guests performace (eg. swapping) or even extreme to the point where the kernel may kill a VM or an important virt stack component.&lt;br /&gt;
&lt;br /&gt;
To help avoiding this scenario, a KVM guest could automatically give memory to the host when the host is facing memory pressure. By doing so the guest may also get into memory pressure so we need a way to allow the guest to automatically get memory back.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
KVM guests have a driver called the balloon driver. This driver allows guests to shrink and grow their memory. The balloon driver supports two operations:&lt;br /&gt;
&lt;br /&gt;
* Inflate: memory is taken from the guest and given to the host (guest shrinks)&lt;br /&gt;
* Deflate: memory is returned from the host to the guest (guest grows)&lt;br /&gt;
&lt;br /&gt;
Today, both operations are manual. The automatic ballooning project is about making them completely automatic, based on host and guest needs.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is performed by QEMU (ie. the KVM host). QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events so that it&#039;s notified when the host is under memory pressure.&lt;br /&gt;
&lt;br /&gt;
Current patches have pre-defined values to be used by QEMU when it receives a memory pressure notification from the host kernel. Those values are:&lt;br /&gt;
&lt;br /&gt;
* 1MB on LOW pressure&lt;br /&gt;
* 2MB on MEDIUM pressure&lt;br /&gt;
* 4MB on CRITICAL pressure&lt;br /&gt;
&lt;br /&gt;
For example, suppose the host is facing MEDIUM pressure and notifies QEMU. When QEMU receives the event, it asks the guest to inflate its balloon by 2MB. The guest in turn will shrink itself by 2MB and give that memory to the host.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the guest or, more specifically, by the balloon driver.&lt;br /&gt;
&lt;br /&gt;
The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure, and the number of pages to be returned to the kernel is passed to the callback. The balloon driver shrink callback deflates the guest&#039;s balloon.&lt;br /&gt;
&lt;br /&gt;
For example, suppose the guest shrunk itself because of pressure in the host. But after some time, the guest is running more applications which causes memory pressure in the guest due its reduced size. The guest kernel then starts reclaiming memory and calls all shrink callbacks. That&#039;s when the balloon driver&#039;s shrink callback runs, and deflates the balloon by the number of pages specified. This causes the guest to grow again.&lt;br /&gt;
&lt;br /&gt;
== Git trees ==&lt;br /&gt;
&lt;br /&gt;
=== Latest RFC version posted upstream ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/rfc.v2 (or grab the patch [http://repo.or.cz/w/qemu/qmp-unstable.git/commit/59fec94e6396d6c32cdce47777440c3a988be63d here])&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/rfc (or grab the first two patches from the [http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git/shortlog/refs/heads/virtio-balloon/auto-deflate/rfc web interface])&lt;br /&gt;
&lt;br /&gt;
=== Development branches ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/current&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/current&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
You have to setup the following before experimenting with auto-ballooning:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10 or higher in your host. Make sure the kernel options CONFIG_CGROUPS and CONFIG_MEMCG are enabled&lt;br /&gt;
# Build and install QEMU from [[#Git trees| the Git trees section]] (suggest the RFC one)&lt;br /&gt;
# Build and install the guest kernel from [[#Git trees| the Git trees section]] (suggest the RFC one)&lt;br /&gt;
&lt;br /&gt;
After setting up the above, do the following to experiment with automatic deflate:&lt;br /&gt;
&lt;br /&gt;
# Pass &#039;&#039;-balloon virtio,auto-balloon=true&#039;&#039; when starting QEMU&lt;br /&gt;
# Wait for the guest to boot, then generate some memory pressure in the guest (say a kernel build with lots of jobs)&lt;br /&gt;
# Switch to QEMU&#039;s monitor and shrink the guest (say from 1G to 200MB)&lt;br /&gt;
# Watch the guest increase its memory by running &amp;quot;free&amp;quot; within the guest (or &amp;quot;info balloon&amp;quot; in QEMU)&lt;br /&gt;
&lt;br /&gt;
There are two ways to play with automatic inflate:&lt;br /&gt;
&lt;br /&gt;
# The simplest thing is to create a memory constrained cgroup, but this will require code changes in QEMU because it&#039;s hardcoded to use the root cgroup (yes, we need a command-line option for that)&lt;br /&gt;
# If you don&#039;t want to play with cgroups, you can overcommit your host by running several VMs in parallel. The VMs have to run a heavy memory workload&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4888</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4888"/>
		<updated>2013-10-10T14:07:20Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to KVM guests performace (eg. swapping) or even extreme to the point where the kernel may kill a VM or an important virt stack component.&lt;br /&gt;
&lt;br /&gt;
To help avoiding this scenario, a KVM guest could automatically give memory to the host when the host is facing memory pressure. By doing so the guest may also get into memory pressure so we need a way to allow the guest to automatically get memory back.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
KVM guests have a driver called the balloon driver. This driver allows guests to shrink and grow their memory. The balloon driver supports two operations:&lt;br /&gt;
&lt;br /&gt;
* Inflate: memory is taken from the guest and given to the host (guest shrinks)&lt;br /&gt;
* Deflate: memory is returned from the host to the guest (guest grows)&lt;br /&gt;
&lt;br /&gt;
Today, both operations are manual. The automatic ballooning project is about making them completely automatic, based on host and guest needs.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is performed by QEMU (ie. the KVM host). QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events so that it&#039;s notified when the host is under memory pressure.&lt;br /&gt;
&lt;br /&gt;
Current patches have pre-defined values to be used by QEMU when it receives a memory pressure notification from the host kernel. Those values are:&lt;br /&gt;
&lt;br /&gt;
* 1MB on LOW pressure&lt;br /&gt;
* 2MB on MEDIUM pressure&lt;br /&gt;
* 4MB on CRITICAL pressure&lt;br /&gt;
&lt;br /&gt;
For example, suppose the host is facing MEDIUM pressure and notifies QEMU. When QEMU receives the event, it asks the guest to inflate its balloon by 2MB. The guest in turn will shrink itself by 2MB and give that memory to the host.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the guest or, more specifically, by the balloon driver.&lt;br /&gt;
&lt;br /&gt;
The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure, and the number of pages to be returned to the kernel is passed to the callback. The balloon driver shrink callback deflates the guest&#039;s balloon.&lt;br /&gt;
&lt;br /&gt;
For example, suppose the guest shrunk itself because of pressure in the host. But after some time, the guest is running more applications which causes memory pressure in the guest due its reduced size. The guest kernel then starts reclaiming memory and calls all shrink callbacks. That&#039;s when the balloon driver&#039;s shrink callback runs, and deflates the balloon by the number of pages specified. This causes the guest to grow again.&lt;br /&gt;
&lt;br /&gt;
== Git trees ==&lt;br /&gt;
&lt;br /&gt;
=== Latest RFC version posted upstream ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/rfc.v2 (or grab the patch [http://repo.or.cz/w/qemu/qmp-unstable.git/commit/59fec94e6396d6c32cdce47777440c3a988be63d here])&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/rfc (or grab the first two patches from the [http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git/shortlog/refs/heads/virtio-balloon/auto-deflate/rfc web interface])&lt;br /&gt;
&lt;br /&gt;
=== Development branches ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/current&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/current&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
You have to setup the following before experimenting with auto-ballooning:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10 or higher in your host. Make sure the kernel options CONFIG_CGROUPS and CONFIG_MEMCG are enabled&lt;br /&gt;
# Build and install QEMU from [[#Git trees]] (suggest the RFC one)&lt;br /&gt;
# Build and install the guest kernel from &#039;&#039;git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/rfc&#039;&#039; (or grab the first two patches from the [http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git/shortlog/refs/heads/virtio-balloon/auto-deflate/rfc web interface])&lt;br /&gt;
&lt;br /&gt;
After setting up the above, do the following to experiment with automatic deflate:&lt;br /&gt;
&lt;br /&gt;
# Pass &#039;&#039;-balloon virtio,auto-balloon=true&#039;&#039; when starting QEMU&lt;br /&gt;
# Wait for the guest to boot, then generate some memory pressure in the guest (say a kernel build with lots of jobs)&lt;br /&gt;
# Switch to QEMU&#039;s monitor and shrink the guest (say from 1G to 200MB)&lt;br /&gt;
# Watch the guest increase its memory by running &amp;quot;free&amp;quot; within the guest (or &amp;quot;info balloon&amp;quot; in QEMU)&lt;br /&gt;
&lt;br /&gt;
There are two ways to play with automatic inflate:&lt;br /&gt;
&lt;br /&gt;
# The simplest thing is to create a memory constrained cgroup, but this will require code changes in QEMU because it&#039;s hardcoded to use the root cgroup (yes, we need a command-line option for that)&lt;br /&gt;
# If you don&#039;t want to play with cgroups, you can overcommit your host by running several VMs in parallel. The VMs have to run a heavy memory workload&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4887</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4887"/>
		<updated>2013-10-10T13:59:20Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to KVM guests performace (eg. swapping) or even extreme to the point where the kernel may kill a VM or an important virt stack component.&lt;br /&gt;
&lt;br /&gt;
To help avoiding this scenario, a KVM guest could automatically give memory to the host when the host is facing memory pressure. By doing so the guest may also get into memory pressure so we need a way to allow the guest to automatically get memory back.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
KVM guests have a driver called the balloon driver. This driver allows guests to shrink and grow their memory. The balloon driver supports two operations:&lt;br /&gt;
&lt;br /&gt;
* Inflate: memory is taken from the guest and given to the host (guest shrinks)&lt;br /&gt;
* Deflate: memory is returned from the host to the guest (guest grows)&lt;br /&gt;
&lt;br /&gt;
Today, both operations are manual. The automatic ballooning project is about making them completely automatic, based on host and guest needs.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is performed by QEMU (ie. the KVM host). QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events so that it&#039;s notified when the host is under memory pressure.&lt;br /&gt;
&lt;br /&gt;
Current patches have pre-defined values to be used by QEMU when it receives a memory pressure notification from the host kernel. Those values are:&lt;br /&gt;
&lt;br /&gt;
* 1MB on LOW pressure&lt;br /&gt;
* 2MB on MEDIUM pressure&lt;br /&gt;
* 4MB on CRITICAL pressure&lt;br /&gt;
&lt;br /&gt;
For example, suppose the host is facing MEDIUM pressure and notifies QEMU. When QEMU receives the event, it asks the guest to inflate its balloon by 2MB. The guest in turn will shrink itself by 2MB and give that memory to the host.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the guest or, more specifically, by the balloon driver.&lt;br /&gt;
&lt;br /&gt;
The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure, and the number of pages to be returned to the kernel is passed to the callback. The balloon driver shrink callback deflates the guest&#039;s balloon.&lt;br /&gt;
&lt;br /&gt;
For example, suppose the guest shrunk itself because of pressure in the host. But after some time, the guest is running more applications which causes memory pressure in the guest due its reduced size. The guest kernel then starts reclaiming memory and calls all shrink callbacks. That&#039;s when the balloon driver&#039;s shrink callback runs, and deflates the balloon by the number of pages specified. This causes the guest to grow again.&lt;br /&gt;
&lt;br /&gt;
== GIT trees ==&lt;br /&gt;
&lt;br /&gt;
=== Latest RFC version posted upstream ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/rfc.v2 (or grab the patch [http://repo.or.cz/w/qemu/qmp-unstable.git/commit/59fec94e6396d6c32cdce47777440c3a988be63d here])&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/rfc (or grab the first two patches from the [http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git/shortlog/refs/heads/virtio-balloon/auto-deflate/rfc web interface])&lt;br /&gt;
&lt;br /&gt;
=== Development branches ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/current&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/current&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
You have to setup the following before experimenting with auto-ballooning:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10 or higher in your host. Make sure the kernel options CONFIG_CGROUPS and CONFIG_MEMCG are enabled&lt;br /&gt;
# Build and install QEMU from &#039;&#039;git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/rfc.v2&#039;&#039; (or grab the patch [http://repo.or.cz/w/qemu/qmp-unstable.git/commit/59fec94e6396d6c32cdce47777440c3a988be63d here])&lt;br /&gt;
# Build and install the guest kernel from &#039;&#039;git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/rfc&#039;&#039; (or grab the first two patches from the [http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git/shortlog/refs/heads/virtio-balloon/auto-deflate/rfc web interface])&lt;br /&gt;
&lt;br /&gt;
After setting up the above, do the following to experiment with automatic deflate:&lt;br /&gt;
&lt;br /&gt;
# Pass &#039;&#039;-balloon virtio,auto-balloon=true&#039;&#039; when starting QEMU&lt;br /&gt;
# Wait for the guest to boot, then generate some memory pressure in the guest (say a kernel build with lots of jobs)&lt;br /&gt;
# Switch to QEMU&#039;s monitor and shrink the guest (say from 1G to 200MB)&lt;br /&gt;
# Watch the guest increase its memory by running &amp;quot;free&amp;quot; within the guest (or &amp;quot;info balloon&amp;quot; in QEMU)&lt;br /&gt;
&lt;br /&gt;
There are two ways to play with automatic inflate:&lt;br /&gt;
&lt;br /&gt;
# The simplest thing is to create a memory constrained cgroup, but this will require code changes in QEMU because it&#039;s hardcoded to use the root cgroup (yes, we need a command-line option for that)&lt;br /&gt;
# If you don&#039;t want to play with cgroups, you can overcommit your host by running several VMs in parallel. The VMs have to run a heavy memory workload&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4886</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4886"/>
		<updated>2013-10-10T13:50:02Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to KVM guests performace (eg. swapping) or even extreme to the point where the kernel may kill a VM or an important virt stack component.&lt;br /&gt;
&lt;br /&gt;
To help avoiding this scenario, a KVM guest could automatically give memory to the host when the host is facing memory pressure. By doing so the guest may also get into memory pressure so we need a way to allow the guest to automatically get memory back.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
KVM guests have a driver called the balloon driver. This driver allows guests to shrink and grow their memory. The balloon driver supports two operations:&lt;br /&gt;
&lt;br /&gt;
* Inflate: memory is taken from the guest and given to the host (guest shrinks)&lt;br /&gt;
* Deflate: memory is returned from the host to the guest (guest grows)&lt;br /&gt;
&lt;br /&gt;
Today, both operations are manual. The automatic ballooning project is about making them completely automatic, based on host and guest needs.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is performed by QEMU (ie. the KVM host). QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events so that it&#039;s notified when the host is under memory pressure.&lt;br /&gt;
&lt;br /&gt;
Current patches have pre-defined values to be used by QEMU when it receives a memory pressure notification from the host kernel. Those values are:&lt;br /&gt;
&lt;br /&gt;
* 1MB on LOW pressure&lt;br /&gt;
* 2MB on MEDIUM pressure&lt;br /&gt;
* 4MB on CRITICAL pressure&lt;br /&gt;
&lt;br /&gt;
For example, suppose the host is facing MEDIUM pressure and notifies QEMU. When QEMU receives the event, it asks the guest to inflate its balloon by 2MB. The guest in turn will shrink itself by 2MB and give that memory to the host.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the guest or, more specifically, by the balloon driver.&lt;br /&gt;
&lt;br /&gt;
The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure, and the number of pages to be returned to the kernel is passed to the callback. The balloon driver shrink callback deflates the guest&#039;s balloon.&lt;br /&gt;
&lt;br /&gt;
For example, suppose the guest shrunk itself because of pressure in the host. But after some time, the guest is running more applications which causes memory pressure in the guest due its reduced size. The guest kernel then starts reclaiming memory and calls all shrink callbacks. That&#039;s when the balloon driver&#039;s shrink callback runs, and deflates the balloon by the number of pages specified. This causes the guest to grow again.&lt;br /&gt;
&lt;br /&gt;
== GIT trees ==&lt;br /&gt;
&lt;br /&gt;
=== Latest RFC version posted upstream ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/rfc.v2 (or grab the patch [http://repo.or.cz/w/qemu/qmp-unstable.git/commit/59fec94e6396d6c32cdce47777440c3a988be63d here])&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/rfc (or grab the first two patches from the [http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git/shortlog/refs/heads/virtio-balloon/auto-deflate/rfc web interface])&lt;br /&gt;
&lt;br /&gt;
=== Development branches ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;QEMU:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/current&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Guest kernel:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/current&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
You have to do three things to play with automatic-ballooning:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10 or higher in the host. Make sure to enable CONFIG_CGROUPS and CONFIG_MEMCG&lt;br /&gt;
# Clone QEMU from &#039;&#039;git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/rfc.v2&#039;&#039; (or grab the patch [http://repo.or.cz/w/qemu/qmp-unstable.git/commit/59fec94e6396d6c32cdce47777440c3a988be63d here])&lt;br /&gt;
# Install the following kernel on your guest &#039;&#039;git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/rfc&#039;&#039; (or grab the first two patches from the [http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git/shortlog/refs/heads/virtio-balloon/auto-deflate/rfc web interface])&lt;br /&gt;
&lt;br /&gt;
After setting up the above, do the following to experiment with automatic deflate (which is easy to reproduce):&lt;br /&gt;
&lt;br /&gt;
# Pass &#039;&#039;-balloon virtio,auto-balloon=true&#039;&#039; when starting QEMU&lt;br /&gt;
# Wait for the guest to boot, then generate some memory pressure in the guest (say a kernel build with lots of jobs)&lt;br /&gt;
# Switch to QEMU&#039;s monitor and shrink guest memory (say from 1G to 200MB)&lt;br /&gt;
# Watch the guest increase its memory by running &amp;quot;info balloon&amp;quot; on QEMU&#039;s monitor&lt;br /&gt;
&lt;br /&gt;
To see automatic inflate and automatic deflate in action, you can run several VMs in parallel doing some heavy memory workload. Make sure to over commit host memory. Say your host has 4GB, run 6 VMs with 1GB each.&lt;br /&gt;
&lt;br /&gt;
Another idea is to run one or more VMs in a memory constrained cgroup, although this will require some hacking on the current patches as they register for the root memory cgroup.&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4885</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4885"/>
		<updated>2013-10-10T13:46:02Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to KVM guests performace (eg. swapping) or even extreme to the point where the kernel may kill a VM or an important virt stack component.&lt;br /&gt;
&lt;br /&gt;
To help avoiding this scenario, a KVM guest could automatically give memory to the host when the host is facing memory pressure. By doing so the guest may also get into memory pressure so we need a way to allow the guest to automatically get memory back.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
KVM guests have a driver called the balloon driver. This driver allows guests to shrink and grow their memory. The balloon driver supports two operations:&lt;br /&gt;
&lt;br /&gt;
* Inflate: memory is taken from the guest and given to the host (guest shrinks)&lt;br /&gt;
* Deflate: memory is returned from the host to the guest (guest grows)&lt;br /&gt;
&lt;br /&gt;
Today, both operations are manual. The automatic ballooning project is about making them completely automatic, based on host and guest needs.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is performed by QEMU (ie. the KVM host). QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events so that it&#039;s notified when the host is under memory pressure.&lt;br /&gt;
&lt;br /&gt;
Current patches have pre-defined values to be used by QEMU when it receives a memory pressure notification from the host kernel. Those values are:&lt;br /&gt;
&lt;br /&gt;
* 1MB on LOW pressure&lt;br /&gt;
* 2MB on MEDIUM pressure&lt;br /&gt;
* 4MB on CRITICAL pressure&lt;br /&gt;
&lt;br /&gt;
For example, suppose the host is facing MEDIUM pressure and notifies QEMU. When QEMU receives the event, it asks the guest to inflate its balloon by 2MB. The guest in turn will shrink itself by 2MB and give that memory to the host.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the guest or, more specifically, by the balloon driver.&lt;br /&gt;
&lt;br /&gt;
The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure, and the number of pages to be returned to the kernel is passed to the callback. The balloon driver shrink callback deflates the guest&#039;s balloon.&lt;br /&gt;
&lt;br /&gt;
For example, suppose the guest shrunk itself because of pressure in the host. But after some time, the guest is running more applications which causes memory pressure in the guest due its reduced size. The guest kernel then starts reclaiming memory and calls all shrink callbacks. That&#039;s when the balloon driver&#039;s shrink callback runs, and deflates the balloon by the number of pages specified. This causes the guest to grow again.&lt;br /&gt;
&lt;br /&gt;
== GIT trees ==&lt;br /&gt;
&lt;br /&gt;
Latest RFC version posted upstream:&lt;br /&gt;
&lt;br /&gt;
* QEMU: git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/rfc.v2 (or grab the patch [http://repo.or.cz/w/qemu/qmp-unstable.git/commit/59fec94e6396d6c32cdce47777440c3a988be63d here])&lt;br /&gt;
* Guest kernel: git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/rfc (or grab the first two patches from the [http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git/shortlog/refs/heads/virtio-balloon/auto-deflate/rfc web interface])&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
You have to do three things to play with automatic-ballooning:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10 or higher in the host. Make sure to enable CONFIG_CGROUPS and CONFIG_MEMCG&lt;br /&gt;
# Clone QEMU from &#039;&#039;git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/rfc.v2&#039;&#039; (or grab the patch [http://repo.or.cz/w/qemu/qmp-unstable.git/commit/59fec94e6396d6c32cdce47777440c3a988be63d here])&lt;br /&gt;
# Install the following kernel on your guest &#039;&#039;git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/rfc&#039;&#039; (or grab the first two patches from the [http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git/shortlog/refs/heads/virtio-balloon/auto-deflate/rfc web interface])&lt;br /&gt;
&lt;br /&gt;
After setting up the above, do the following to experiment with automatic deflate (which is easy to reproduce):&lt;br /&gt;
&lt;br /&gt;
# Pass &#039;&#039;-balloon virtio,auto-balloon=true&#039;&#039; when starting QEMU&lt;br /&gt;
# Wait for the guest to boot, then generate some memory pressure in the guest (say a kernel build with lots of jobs)&lt;br /&gt;
# Switch to QEMU&#039;s monitor and shrink guest memory (say from 1G to 200MB)&lt;br /&gt;
# Watch the guest increase its memory by running &amp;quot;info balloon&amp;quot; on QEMU&#039;s monitor&lt;br /&gt;
&lt;br /&gt;
To see automatic inflate and automatic deflate in action, you can run several VMs in parallel doing some heavy memory workload. Make sure to over commit host memory. Say your host has 4GB, run 6 VMs with 1GB each.&lt;br /&gt;
&lt;br /&gt;
Another idea is to run one or more VMs in a memory constrained cgroup, although this will require some hacking on the current patches as they register for the root memory cgroup.&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4884</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4884"/>
		<updated>2013-10-10T13:38:49Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to KVM guests performace (eg. swapping) or even extreme to the point where the kernel may kill a VM or an important virt stack component.&lt;br /&gt;
&lt;br /&gt;
To help avoiding this scenario, a KVM guest could automatically give memory to the host when the host is facing memory pressure. By doing so the guest may also get into memory pressure so we need a way to allow the guest to automatically get memory back.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
KVM guests have a driver called the balloon driver. This driver allows guests to shrink and grow their memory. The balloon driver supports two operations:&lt;br /&gt;
&lt;br /&gt;
* Inflate: memory is taken from the guest and given to the host (guest shrinks)&lt;br /&gt;
* Deflate: memory is returned from the host to the guest (guest grows)&lt;br /&gt;
&lt;br /&gt;
Today, both operations are manual. The automatic ballooning project is about making them completely automatic, based on host and guest needs.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is performed by QEMU (ie. the KVM host). QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events so that it&#039;s notified when the host is under memory pressure.&lt;br /&gt;
&lt;br /&gt;
Current patches have pre-defined values to be used by QEMU when it receives a memory pressure notification from the host kernel. Those values are:&lt;br /&gt;
&lt;br /&gt;
* 1MB on LOW pressure&lt;br /&gt;
* 2MB on MEDIUM pressure&lt;br /&gt;
* 4MB on CRITICAL pressure&lt;br /&gt;
&lt;br /&gt;
For example, suppose the host is facing MEDIUM pressure and notifies QEMU. When QEMU receives the event, it asks the guest to inflate its balloon by 2MB. The guest in turn will shrink itself by 2MB and give that memory to the host.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the guest or, more specifically, by the balloon driver.&lt;br /&gt;
&lt;br /&gt;
The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure, and the number of pages to be returned to the kernel is passed to the callback. The balloon driver shrink callback deflates the guest&#039;s balloon.&lt;br /&gt;
&lt;br /&gt;
For example, suppose the guest shrunk itself because of pressure in the host. But after some time, the guest is running more applications which causes memory pressure in the guest due its reduced size. The guest kernel then starts reclaiming memory and calls all shrink callbacks. That&#039;s when the balloon driver&#039;s shrink callback runs, and deflates the balloon by the number of pages specified. This causes the guest to grow again.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
You have to do three things to play with automatic-ballooning:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10 or higher in the host. Make sure to enable CONFIG_CGROUPS and CONFIG_MEMCG&lt;br /&gt;
# Clone QEMU from &#039;&#039;git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/rfc.v2&#039;&#039; (or grab the patch [http://repo.or.cz/w/qemu/qmp-unstable.git/commit/59fec94e6396d6c32cdce47777440c3a988be63d here])&lt;br /&gt;
# Install the following kernel on your guest &#039;&#039;git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/rfc&#039;&#039; (or grab the first two patches from the [http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git/shortlog/refs/heads/virtio-balloon/auto-deflate/rfc web interface])&lt;br /&gt;
&lt;br /&gt;
After setting up the above, do the following to experiment with automatic deflate (which is easy to reproduce):&lt;br /&gt;
&lt;br /&gt;
# Pass &#039;&#039;-balloon virtio,auto-balloon=true&#039;&#039; when starting QEMU&lt;br /&gt;
# Wait for the guest to boot, then generate some memory pressure in the guest (say a kernel build with lots of jobs)&lt;br /&gt;
# Switch to QEMU&#039;s monitor and shrink guest memory (say from 1G to 200MB)&lt;br /&gt;
# Watch the guest increase its memory by running &amp;quot;info balloon&amp;quot; on QEMU&#039;s monitor&lt;br /&gt;
&lt;br /&gt;
To see automatic inflate and automatic deflate in action, you can run several VMs in parallel doing some heavy memory workload. Make sure to over commit host memory. Say your host has 4GB, run 6 VMs with 1GB each.&lt;br /&gt;
&lt;br /&gt;
Another idea is to run one or more VMs in a memory constrained cgroup, although this will require some hacking on the current patches as they register for the root memory cgroup.&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4883</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4883"/>
		<updated>2013-10-10T13:30:51Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to KVM guests performace (eg. swapping) or even extreme to the point where the kernel may kill a VM or an important virt stack component.&lt;br /&gt;
&lt;br /&gt;
To help avoiding this scenario, a KVM guest could automatically give memory to the host when the host is facing memory pressure. By doing so the guest may also get into memory pressure so we need a way to allow the guest to automatically get memory back.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
KVM guests have a driver called the balloon driver. This driver allows guests to shrink and grow their memory. The balloon driver supports two operations:&lt;br /&gt;
&lt;br /&gt;
* Inflate: memory is taken from the guest and given to the host (guest shrinks)&lt;br /&gt;
* Deflate: memory is returned from the host to the guest (guest grows)&lt;br /&gt;
&lt;br /&gt;
Today, both operations are manual. The automatic ballooning project is about making them completely automatic, based on host and guest needs.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is performed by QEMU (ie. the KVM host). QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events so that it&#039;s notified when the host is under memory pressure.&lt;br /&gt;
&lt;br /&gt;
Current patches have pre-defined values to be used by QEMU when it receives a memory pressure notification from the host kernel. Those values are:&lt;br /&gt;
&lt;br /&gt;
* 1MB on LOW pressure&lt;br /&gt;
* 2MB on MEDIUM pressure&lt;br /&gt;
* 4MB on CRITICAL pressure&lt;br /&gt;
&lt;br /&gt;
For example, suppose the host is facing MEDIUM pressure and notifies QEMU. When QEMU receives the event, it asks the guest to inflate its balloon by 2MB. The guest in turn will shrink itself by 2MB and give that memory to the host.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the guest or, more specifically, by the balloon driver.&lt;br /&gt;
&lt;br /&gt;
The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure. The number of pages to be returned to the kernel is passed to the callback. The balloon driver shrink callback performs deflate by the number of pages specified by the kernel.&lt;br /&gt;
&lt;br /&gt;
For example, suppose the guest shrunk itself because of pressure in the host. But after some time, the guest is running more applications which causes memory pressure in the guest due its current size. The guest kernel then starts reclaiming memory and calls all shrink callbacks. That&#039;s when the balloon driver&#039;s shrink callback runs, and deflates the balloon. This causes the guest to grow by taking memory back from the host.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
You have to do three things to play with automatic-ballooning:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10 or higher in the host. Make sure to enable CONFIG_CGROUPS and CONFIG_MEMCG&lt;br /&gt;
# Clone QEMU from &#039;&#039;git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/rfc.v2&#039;&#039; (or grab the patch [http://repo.or.cz/w/qemu/qmp-unstable.git/commit/59fec94e6396d6c32cdce47777440c3a988be63d here])&lt;br /&gt;
# Install the following kernel on your guest &#039;&#039;git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/rfc&#039;&#039; (or grab the first two patches from the [http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git/shortlog/refs/heads/virtio-balloon/auto-deflate/rfc web interface])&lt;br /&gt;
&lt;br /&gt;
After setting up the above, do the following to experiment with automatic deflate (which is easy to reproduce):&lt;br /&gt;
&lt;br /&gt;
# Pass &#039;&#039;-balloon virtio,auto-balloon=true&#039;&#039; when starting QEMU&lt;br /&gt;
# Wait for the guest to boot, then generate some memory pressure in the guest (say a kernel build with lots of jobs)&lt;br /&gt;
# Switch to QEMU&#039;s monitor and shrink guest memory (say from 1G to 200MB)&lt;br /&gt;
# Watch the guest increase its memory by running &amp;quot;info balloon&amp;quot; on QEMU&#039;s monitor&lt;br /&gt;
&lt;br /&gt;
To see automatic inflate and automatic deflate in action, you can run several VMs in parallel doing some heavy memory workload. Make sure to over commit host memory. Say your host has 4GB, run 6 VMs with 1GB each.&lt;br /&gt;
&lt;br /&gt;
Another idea is to run one or more VMs in a memory constrained cgroup, although this will require some hacking on the current patches as they register for the root memory cgroup.&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4882</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4882"/>
		<updated>2013-10-10T13:23:37Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to KVM guests performace (eg. swapping) or even extreme to the point where the kernel may kill a VM or an important virt stack component.&lt;br /&gt;
&lt;br /&gt;
To help avoiding this scenario, a KVM guest could automatically give memory to the host when the host is facing memory pressure. By doing so the guest may also get into memory pressure so we need a way to allow the guest to automatically get memory back.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
KVM guests have a driver called the balloon driver. This driver allows guests to shrink and grow their memory. The balloon driver supports two operations:&lt;br /&gt;
&lt;br /&gt;
* Inflate: memory is taken from the guest and given to the host (guest shrinks)&lt;br /&gt;
* Deflate: memory is returned from the host to the guest (guest grows)&lt;br /&gt;
&lt;br /&gt;
Today, both operations are manual. The automatic ballooning project is about making them completely automatic, based on host and guest needs.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is performed by QEMU (ie. the KVM host). QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events so that it&#039;s notified when the host is under memory pressure.&lt;br /&gt;
&lt;br /&gt;
Current patches have pre-defined values to be used by QEMU when it receives a memory pressure notification from the host kernel. Those values are:&lt;br /&gt;
&lt;br /&gt;
* 1MB on LOW pressure&lt;br /&gt;
* 2MB on MEDIUM pressure&lt;br /&gt;
* 4MB on CRITICAL pressure&lt;br /&gt;
&lt;br /&gt;
For example, suppose the host is facing MEDIUM pressure and notifies QEMU. When QEMU receives the event, it asks the guest to inflate its balloon by 2MB. The guest in turn will shrink itself by 2MB and give that memory to the host.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the virtio-balloon driver within the guest. There&#039;s also two ways of implementing this:&lt;br /&gt;
&lt;br /&gt;
# The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure. The number of pages to be returned to the kernel is passed to the callback, so that the callback can deflate the balloon by that amount. This is what the current patchset does&lt;br /&gt;
# The virtio-balloon driver registers for an in-kernel memory pressure event (not upstream yet) and deflates the balloon by some fixed amount (maybe the same amount used in automatic inflate)&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
You have to do three things to play with automatic-ballooning:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10 or higher in the host. Make sure to enable CONFIG_CGROUPS and CONFIG_MEMCG&lt;br /&gt;
# Clone QEMU from &#039;&#039;git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/rfc.v2&#039;&#039; (or grab the patch [http://repo.or.cz/w/qemu/qmp-unstable.git/commit/59fec94e6396d6c32cdce47777440c3a988be63d here])&lt;br /&gt;
# Install the following kernel on your guest &#039;&#039;git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/rfc&#039;&#039; (or grab the first two patches from the [http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git/shortlog/refs/heads/virtio-balloon/auto-deflate/rfc web interface])&lt;br /&gt;
&lt;br /&gt;
After setting up the above, do the following to experiment with automatic deflate (which is easy to reproduce):&lt;br /&gt;
&lt;br /&gt;
# Pass &#039;&#039;-balloon virtio,auto-balloon=true&#039;&#039; when starting QEMU&lt;br /&gt;
# Wait for the guest to boot, then generate some memory pressure in the guest (say a kernel build with lots of jobs)&lt;br /&gt;
# Switch to QEMU&#039;s monitor and shrink guest memory (say from 1G to 200MB)&lt;br /&gt;
# Watch the guest increase its memory by running &amp;quot;info balloon&amp;quot; on QEMU&#039;s monitor&lt;br /&gt;
&lt;br /&gt;
To see automatic inflate and automatic deflate in action, you can run several VMs in parallel doing some heavy memory workload. Make sure to over commit host memory. Say your host has 4GB, run 6 VMs with 1GB each.&lt;br /&gt;
&lt;br /&gt;
Another idea is to run one or more VMs in a memory constrained cgroup, although this will require some hacking on the current patches as they register for the root memory cgroup.&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4881</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4881"/>
		<updated>2013-10-10T13:08:21Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to KVM guests performace (eg. swapping) or even extreme to the point where the kernel may kill a VM or an important virt stack component.&lt;br /&gt;
&lt;br /&gt;
To help avoiding this scenario, a KVM guest could automatically give memory to the host when the host is facing memory pressure. By doing so the guest may also get into memory pressure so we need a way to allow the guest to automatically get memory back.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
KVM guests have a driver called the balloon driver. This driver allows guests to shrink and grow their memory. The balloon driver supports two operations:&lt;br /&gt;
&lt;br /&gt;
* Inflate: memory is taken from the guest and given to the host (guest shrinks)&lt;br /&gt;
* Deflate: memory is returned from the host to the guest (guest grows)&lt;br /&gt;
&lt;br /&gt;
Today, both operations are manual. The automatic ballooning project is about making them completely automatic, based on host and guest needs.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is performed by QEMU, that is, the KVM host. There are two ways I&#039;m playing with automatic inflate, in both of them QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events so that it&#039;s notified when the host is under memory pressure:&lt;br /&gt;
&lt;br /&gt;
# QEMU registers for the VMPRESSURE_MEDIUM event and inflates the balloon by an user specified value when the event is received. That value value could default to 16MB or 32MB. This is what the current patchset does&lt;br /&gt;
# QEMU registers for the three memory pressure events and inflates the balloon accordingly. Say, it could inflate the balloon by 1MB on VMPRESSURE_LOW; 16MB on VMPRESSURE_MEDIUM and 128MB on VMPRESSURE_CRITICAL&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the virtio-balloon driver within the guest. There&#039;s also two ways of implementing this:&lt;br /&gt;
&lt;br /&gt;
# The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure. The number of pages to be returned to the kernel is passed to the callback, so that the callback can deflate the balloon by that amount. This is what the current patchset does&lt;br /&gt;
# The virtio-balloon driver registers for an in-kernel memory pressure event (not upstream yet) and deflates the balloon by some fixed amount (maybe the same amount used in automatic inflate)&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
You have to do three things to play with automatic-ballooning:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10 or higher in the host. Make sure to enable CONFIG_CGROUPS and CONFIG_MEMCG&lt;br /&gt;
# Clone QEMU from &#039;&#039;git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/rfc.v2&#039;&#039; (or grab the patch [http://repo.or.cz/w/qemu/qmp-unstable.git/commit/59fec94e6396d6c32cdce47777440c3a988be63d here])&lt;br /&gt;
# Install the following kernel on your guest &#039;&#039;git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/rfc&#039;&#039; (or grab the first two patches from the [http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git/shortlog/refs/heads/virtio-balloon/auto-deflate/rfc web interface])&lt;br /&gt;
&lt;br /&gt;
After setting up the above, do the following to experiment with automatic deflate (which is easy to reproduce):&lt;br /&gt;
&lt;br /&gt;
# Pass &#039;&#039;-balloon virtio,auto-balloon=true&#039;&#039; when starting QEMU&lt;br /&gt;
# Wait for the guest to boot, then generate some memory pressure in the guest (say a kernel build with lots of jobs)&lt;br /&gt;
# Switch to QEMU&#039;s monitor and shrink guest memory (say from 1G to 200MB)&lt;br /&gt;
# Watch the guest increase its memory by running &amp;quot;info balloon&amp;quot; on QEMU&#039;s monitor&lt;br /&gt;
&lt;br /&gt;
To see automatic inflate and automatic deflate in action, you can run several VMs in parallel doing some heavy memory workload. Make sure to over commit host memory. Say your host has 4GB, run 6 VMs with 1GB each.&lt;br /&gt;
&lt;br /&gt;
Another idea is to run one or more VMs in a memory constrained cgroup, although this will require some hacking on the current patches as they register for the root memory cgroup.&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4842</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4842"/>
		<updated>2013-07-16T17:53:55Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to KVM guests performace (eg. swapping) or even extreme to the point where the kernel may kill a VM or an important virt stack component.&lt;br /&gt;
&lt;br /&gt;
To help avoiding this scenario, a KVM guest could automatically return memory to the host when the host is facing memory pressure. By doing so the guest may also get into memory pressure so we also need a way to allow the guest to automatically get memory back.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
KVM guests have a driver called the balloon driver. This driver allows guests to shrink and increase their memory. The balloon driver supports two operations:&lt;br /&gt;
&lt;br /&gt;
* Inflate: guest memory shrinks and memory is returned to the host&lt;br /&gt;
* Deflate: guest memory increases and memory is taken from the host&lt;br /&gt;
&lt;br /&gt;
Today, both operations are manual. The automatic ballooning project is about making them completely automatic, based on host and guest needs.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is performed by QEMU, that is, the KVM host. There are two ways I&#039;m playing with automatic inflate, in both of them QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events so that it&#039;s notified when the host is under memory pressure:&lt;br /&gt;
&lt;br /&gt;
# QEMU registers for the VMPRESSURE_MEDIUM event and inflates the balloon by an user specified value when the event is received. That value value could default to 16MB or 32MB. This is what the current patchset does&lt;br /&gt;
# QEMU registers for the three memory pressure events and inflates the balloon accordingly. Say, it could inflate the balloon by 1MB on VMPRESSURE_LOW; 16MB on VMPRESSURE_MEDIUM and 128MB on VMPRESSURE_CRITICAL&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the virtio-balloon driver within the guest. There&#039;s also two ways of implementing this:&lt;br /&gt;
&lt;br /&gt;
# The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure. The number of pages to be returned to the kernel is passed to the callback, so that the callback can deflate the balloon by that amount. This is what the current patchset does&lt;br /&gt;
# The virtio-balloon driver registers for an in-kernel memory pressure event (not upstream yet) and deflates the balloon by some fixed amount (maybe the same amount used in automatic inflate)&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
You have to do three things to play with automatic-ballooning:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10 or higher in the host. Make sure to enable CONFIG_CGROUPS and CONFIG_MEMCG&lt;br /&gt;
# Clone QEMU from &#039;&#039;git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/rfc.v2&#039;&#039; (or grab the patch [http://repo.or.cz/w/qemu/qmp-unstable.git/commit/59fec94e6396d6c32cdce47777440c3a988be63d here])&lt;br /&gt;
# Install the following kernel on your guest &#039;&#039;git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/rfc&#039;&#039; (or grab the first two patches from the [http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git/shortlog/refs/heads/virtio-balloon/auto-deflate/rfc web interface])&lt;br /&gt;
&lt;br /&gt;
After setting up the above, do the following to experiment with automatic deflate (which is easy to reproduce):&lt;br /&gt;
&lt;br /&gt;
# Pass &#039;&#039;-balloon virtio,auto-balloon=true&#039;&#039; when starting QEMU&lt;br /&gt;
# Wait for the guest to boot, then generate some memory pressure in the guest (say a kernel build with lots of jobs)&lt;br /&gt;
# Switch to QEMU&#039;s monitor and shrink guest memory (say from 1G to 200MB)&lt;br /&gt;
# Watch the guest increase its memory by running &amp;quot;info balloon&amp;quot; on QEMU&#039;s monitor&lt;br /&gt;
&lt;br /&gt;
To see automatic inflate and automatic deflate in action, you can run several VMs in parallel doing some heavy memory workload. Make sure to over commit host memory. Say your host has 4GB, run 6 VMs with 1GB each.&lt;br /&gt;
&lt;br /&gt;
Another idea is to run one or more VMs in a memory constrained cgroup, although this will require some hacking on the current patches as they register for the root memory cgroup.&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4841</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4841"/>
		<updated>2013-07-16T17:45:46Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to KVM guests performace (eg. swapping) or even extreme to the point where the kernel may kill a VM or an important virt stack component.&lt;br /&gt;
&lt;br /&gt;
To help avoiding this scenario, a KVM guest could automatically return memory to the host when the host is facing memory pressure. By doing so the guest may also get into memory pressure so we also need a way to allow the guest to automatically get memory back.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
KVM guests have a driver called the balloon driver. This driver allows guests to shrink and increase their memory. The balloon driver supports two operations:&lt;br /&gt;
&lt;br /&gt;
* Inflate: guest memory shrinks and memory is returned to the host&lt;br /&gt;
* Deflate: guest memory increases and memory is taken from the host&lt;br /&gt;
&lt;br /&gt;
Today, both operations are manual. The automatic ballooning project is about making them completely automatic, based on host and guest needs.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is performed by QEMU, that is, the KVM host. There are two ways I&#039;m playing with automatic inflate, in both of them QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events so that it&#039;s notified when the host is under memory pressure:&lt;br /&gt;
&lt;br /&gt;
# QEMU registers for the VMPRESSURE_MEDIUM event and inflates the balloon by an user specified value when the event is received. That value value could default to 16MB or 32MB. This is what the current patchset does&lt;br /&gt;
# QEMU registers for the three memory pressure events and inflates the balloon accordingly. Say, it could inflate the balloon by 1MB on VMPRESSURE_LOW; 16MB on VMPRESSURE_MEDIUM and 128MB on VMPRESSURE_CRITICAL&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the virtio-balloon driver within the guest. There&#039;s also two ways of implementing this:&lt;br /&gt;
&lt;br /&gt;
# The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure. The number of pages to be returned to the kernel is passed to the callback, so that the callback can deflate the balloon by that amount. This is what the current patchset does&lt;br /&gt;
# The virtio-balloon driver registers for an in-kernel memory pressure event (not upstream yet) and deflates the balloon by some fixed amount (maybe the same amount used in automatic inflate)&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
You have to do three things to play with automatic-ballooning:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10-rc1 or higher in the host. Make sure to enable CONFIG_CGROUPS and CONFIG_MEMCG&lt;br /&gt;
# Clone QEMU from &#039;&#039;git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/rfc.v2&#039;&#039; (or grab the patch [http://repo.or.cz/w/qemu/qmp-unstable.git/commit/59fec94e6396d6c32cdce47777440c3a988be63d here])&lt;br /&gt;
# Install the following kernel on your guest &#039;&#039;git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/rfc&#039;&#039; (or grab the patches from the [http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git/shortlog/refs/heads/virtio-balloon/auto-deflate/rfc web interface])&lt;br /&gt;
&lt;br /&gt;
After setting up the above, do the following to experiment with automatic deflate (which is easy to reproduce):&lt;br /&gt;
&lt;br /&gt;
# Pass &#039;&#039;-balloon virtio,auto-balloon=true&#039;&#039; when starting QEMU&lt;br /&gt;
# Wait for the guest to boot, then generate some memory pressure in the guest (say a kernel build with lots of jobs)&lt;br /&gt;
# Switch to QEMU&#039;s monitor and decrease guest memory (say from 1G to 200MB)&lt;br /&gt;
# Watch the guest increase its memory by repeatedly running &amp;quot;info balloon&amp;quot; on QEMU&#039;s monitor&lt;br /&gt;
&lt;br /&gt;
To see automatic inflate and automatic deflate in action, you can run several VMs in parallel doing some heavy memory workload. Make sure to over commit host memory. Say your host has 4GB, run 6 VMs with 1GB each.&lt;br /&gt;
&lt;br /&gt;
Another idea is to run one VM, but generate pressure in the host some way like a big kernel build or an application that allocates lots of memory.&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4840</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4840"/>
		<updated>2013-07-16T17:34:31Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to KVM guests performace (eg. swapping) or even extreme to the point where the kernel may kill a VM or an important virt stack component.&lt;br /&gt;
&lt;br /&gt;
To help avoiding this scenario, a KVM guest could automatically return memory to the host when the host is facing memory pressure. By doing so the guest may also get into memory pressure so we also need a way to allow the guest to automatically get memory back.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
KVM guests have a driver called the balloon driver. This driver allows guests to shrink and increase their memory. The balloon driver supports two operations:&lt;br /&gt;
&lt;br /&gt;
* Inflate: guest memory shrinks and memory is returned to the host&lt;br /&gt;
* Deflate: guest memory increases and memory is taken from the host&lt;br /&gt;
&lt;br /&gt;
Today, both operations are manual. The automatic ballooning project is about making them completely automatic, based on host and guest needs.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is performed by QEMU, that is, the KVM host. There are two ways I&#039;m playing with automatic inflate, in both of them QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events to learn when the host is under memory pressure:&lt;br /&gt;
&lt;br /&gt;
# QEMU registers for the VMPRESSURE_MEDIUM event and inflates the balloon by an user specified value when the event is received. That value value could default to 16MB or 32MB. This is what the current patchset does&lt;br /&gt;
# QEMU registers for the three memory pressure events and inflates the balloon accordingly. Say, it could inflate the balloon by 1MB on VMPRESSURE_LOW; 16MB on VMPRESSURE_MEDIUM and 128MB on VMPRESSURE_CRITICAL. This is not done yet because there&#039;s a small limitation in the memory pressure code which doesn&#039;t allow this. I&#039;ll fix it&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the virtio-balloon driver within the guest. There&#039;s also two ways of implementing this:&lt;br /&gt;
&lt;br /&gt;
# The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure. The number of pages to be returned to the kernel is passed to the callback, so that the callback can deflate the balloon by that amount. This is what the current patchset does&lt;br /&gt;
# The virtio-balloon driver registers for an in-kernel memory pressure event (not upstream yet) and deflates the balloon by some fixed amount (maybe the same amount used in automatic inflate)&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
You have to do three things to play with automatic-ballooning:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10-rc1 or higher in the host. Make sure to enable CONFIG_CGROUPS and CONFIG_MEMCG&lt;br /&gt;
# Clone QEMU from &#039;&#039;git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/rfc.v2&#039;&#039; (or grab the patch [http://repo.or.cz/w/qemu/qmp-unstable.git/commit/59fec94e6396d6c32cdce47777440c3a988be63d here])&lt;br /&gt;
# Install the following kernel on your guest &#039;&#039;git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/rfc&#039;&#039; (or grab the patches from the [http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git/shortlog/refs/heads/virtio-balloon/auto-deflate/rfc web interface])&lt;br /&gt;
&lt;br /&gt;
After setting up the above, do the following to experiment with automatic deflate (which is easy to reproduce):&lt;br /&gt;
&lt;br /&gt;
# Pass &#039;&#039;-balloon virtio,auto-balloon=true&#039;&#039; when starting QEMU&lt;br /&gt;
# Wait for the guest to boot, then generate some memory pressure in the guest (say a kernel build with lots of jobs)&lt;br /&gt;
# Switch to QEMU&#039;s monitor and decrease guest memory (say from 1G to 200MB)&lt;br /&gt;
# Watch the guest increase its memory by repeatedly running &amp;quot;info balloon&amp;quot; on QEMU&#039;s monitor&lt;br /&gt;
&lt;br /&gt;
To see automatic inflate and automatic deflate in action, you can run several VMs in parallel doing some heavy memory workload. Make sure to over commit host memory. Say your host has 4GB, run 6 VMs with 1GB each.&lt;br /&gt;
&lt;br /&gt;
Another idea is to run one VM, but generate pressure in the host some way like a big kernel build or an application that allocates lots of memory.&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4839</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4839"/>
		<updated>2013-07-16T17:30:36Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to KVM guests performace (eg. swapping) or even extreme to the point where the kernel may kill a VM or an important virt stack component.&lt;br /&gt;
&lt;br /&gt;
To help avoiding this scenario, a KVM guest could automatically return memory to the host when the host is facing memory pressure. By doing so the guest may also get into memory pressure so we also need a way to allow the guest to automatically get memory back.&lt;br /&gt;
&lt;br /&gt;
That&#039;s what the automatic ballooning project is about.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
KVM guests have a driver called the balloon driver. This driver allows guests to shrink and increase their memory. The balloon driver supports two operations:&lt;br /&gt;
&lt;br /&gt;
* Inflate: guest memory shrinks and guest memory is returned to the host&lt;br /&gt;
* Deflate: guest memory increases and memory is taken from the host&lt;br /&gt;
&lt;br /&gt;
Today, both operations are manual. The automatic ballooning project is about making them completely automatic, based on host and guest needs.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is performed by QEMU, that is, the KVM host. There are two ways I&#039;m playing with automatic inflate, in both of them QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events to learn when the host is under memory pressure:&lt;br /&gt;
&lt;br /&gt;
# QEMU registers for the VMPRESSURE_MEDIUM event and inflates the balloon by an user specified value when the event is received. That value value could default to 16MB or 32MB. This is what the current patchset does&lt;br /&gt;
# QEMU registers for the three memory pressure events and inflates the balloon accordingly. Say, it could inflate the balloon by 1MB on VMPRESSURE_LOW; 16MB on VMPRESSURE_MEDIUM and 128MB on VMPRESSURE_CRITICAL. This is not done yet because there&#039;s a small limitation in the memory pressure code which doesn&#039;t allow this. I&#039;ll fix it&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the virtio-balloon driver within the guest. There&#039;s also two ways of implementing this:&lt;br /&gt;
&lt;br /&gt;
# The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure. The number of pages to be returned to the kernel is passed to the callback, so that the callback can deflate the balloon by that amount. This is what the current patchset does&lt;br /&gt;
# The virtio-balloon driver registers for an in-kernel memory pressure event (not upstream yet) and deflates the balloon by some fixed amount (maybe the same amount used in automatic inflate)&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
You have to do three things to play with automatic-ballooning:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10-rc1 or higher in the host. Make sure to enable CONFIG_CGROUPS and CONFIG_MEMCG&lt;br /&gt;
# Clone QEMU from &#039;&#039;git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/rfc.v2&#039;&#039; (or grab the patch [http://repo.or.cz/w/qemu/qmp-unstable.git/commit/59fec94e6396d6c32cdce47777440c3a988be63d here])&lt;br /&gt;
# Install the following kernel on your guest &#039;&#039;git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/rfc&#039;&#039; (or grab the patches from the [http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git/shortlog/refs/heads/virtio-balloon/auto-deflate/rfc web interface])&lt;br /&gt;
&lt;br /&gt;
After setting up the above, do the following to experiment with automatic deflate (which is easy to reproduce):&lt;br /&gt;
&lt;br /&gt;
# Pass &#039;&#039;-balloon virtio,auto-balloon=true&#039;&#039; when starting QEMU&lt;br /&gt;
# Wait for the guest to boot, then generate some memory pressure in the guest (say a kernel build with lots of jobs)&lt;br /&gt;
# Switch to QEMU&#039;s monitor and decrease guest memory (say from 1G to 200MB)&lt;br /&gt;
# Watch the guest increase its memory by repeatedly running &amp;quot;info balloon&amp;quot; on QEMU&#039;s monitor&lt;br /&gt;
&lt;br /&gt;
To see automatic inflate and automatic deflate in action, you can run several VMs in parallel doing some heavy memory workload. Make sure to over commit host memory. Say your host has 4GB, run 6 VMs with 1GB each.&lt;br /&gt;
&lt;br /&gt;
Another idea is to run one VM, but generate pressure in the host some way like a big kernel build or an application that allocates lots of memory.&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4826</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4826"/>
		<updated>2013-06-17T21:09:58Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to KVM guests performace (eg. swapping) or even extreme to the point where the kernel may kill a VM or an important virt stack component.&lt;br /&gt;
&lt;br /&gt;
To help avoiding this situation, a KVM guest could automatically return memory to the host when the host is facing memory pressure. By doing so the guest may also get into memory pressure so we also need a way to allow the guest to automatically get memory back.&lt;br /&gt;
&lt;br /&gt;
That&#039;s what the automatic ballooning project is about. The next section will dive into ways of implementing it. The following section will provide instructions on how to try current patches.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is performed by QEMU, that is, the KVM host. There are two ways I&#039;m playing with automatic inflate, in both of them QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events to learn when the host is under memory pressure:&lt;br /&gt;
&lt;br /&gt;
# QEMU registers for the VMPRESSURE_MEDIUM event and inflates the balloon by an user specified value when the event is received. That value value could default to 16MB or 32MB. This is what the current patchset does&lt;br /&gt;
# QEMU registers for the three memory pressure events and inflates the balloon accordingly. Say, it could inflate the balloon by 1MB on VMPRESSURE_LOW; 16MB on VMPRESSURE_MEDIUM and 128MB on VMPRESSURE_CRITICAL. This is not done yet because there&#039;s a small limitation in the memory pressure code which doesn&#039;t allow this. I&#039;ll fix it&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the virtio-balloon driver within the guest. There&#039;s also two ways of implementing this:&lt;br /&gt;
&lt;br /&gt;
# The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure. The number of pages to be returned to the kernel is passed to the callback, so that the callback can deflate the balloon by that amount. This is what the current patchset does&lt;br /&gt;
# The virtio-balloon driver registers for an in-kernel memory pressure event (not upstream yet) and deflates the balloon by some fixed amount (maybe the same amount used in automatic inflate)&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
You have to do three things to play with automatic-ballooning:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10-rc1 or higher in the host. Make sure to enable CONFIG_CGROUPS and CONFIG_MEMCG&lt;br /&gt;
# Clone QEMU from &#039;&#039;git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/rfc.v2&#039;&#039; (or grab the patch [http://repo.or.cz/w/qemu/qmp-unstable.git/commit/59fec94e6396d6c32cdce47777440c3a988be63d here])&lt;br /&gt;
# Install the following kernel on your guest &#039;&#039;git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/rfc&#039;&#039; (or grab the patches from the [http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git/shortlog/refs/heads/virtio-balloon/auto-deflate/rfc web interface])&lt;br /&gt;
&lt;br /&gt;
After setting up the above, do the following to experiment with automatic deflate (which is easy to reproduce):&lt;br /&gt;
&lt;br /&gt;
# Pass &#039;&#039;-balloon virtio,auto-balloon=true&#039;&#039; when starting QEMU&lt;br /&gt;
# Wait for the guest to boot, then generate some memory pressure in the guest (say a kernel build with lots of jobs)&lt;br /&gt;
# Switch to QEMU&#039;s monitor and decrease guest memory (say from 1G to 200MB)&lt;br /&gt;
# Watch the guest increase its memory by repeatedly running &amp;quot;info balloon&amp;quot; on QEMU&#039;s monitor&lt;br /&gt;
&lt;br /&gt;
To see automatic inflate and automatic deflate in action, you can run several VMs in parallel doing some heavy memory workload. Make sure to over commit host memory. Say your host has 4GB, run 6 VMs with 1GB each.&lt;br /&gt;
&lt;br /&gt;
Another idea is to run one VM, but generate pressure in the host some way like a big kernel build or an application that allocates lots of memory.&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4825</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4825"/>
		<updated>2013-06-17T20:51:41Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to KVM guests performace (eg. swapping) or even extreme to the point where the kernel may kill a VM or an important virt stack component.&lt;br /&gt;
&lt;br /&gt;
To help avoiding this situation, a KVM guest could automatically return memory to the host when the host is facing memory pressure (automatic inflate). By doing so the guest may also get into memory pressure so we also need a way to allow the guest to automatically get memory back (automatic deflate).&lt;br /&gt;
&lt;br /&gt;
That&#039;s what the automatic ballooning project is about. The next section will dive into ways of implementing it. The following section will provide instructions on how to try current patches.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is performed by QEMU, that is, the KVM host. There are two ways I&#039;m playing with automatic inflate, in both of them QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events to learn when the host is under memory pressure:&lt;br /&gt;
&lt;br /&gt;
# QEMU registers for the VMPRESSURE_MEDIUM event and inflates the balloon by an user specified value when the event is received. That value value could default to 16MB or 32MB. This is what the current patchset does&lt;br /&gt;
# QEMU registers for the three memory pressure events and inflates the balloon accordingly. Say, it could inflate the balloon by 1MB on VMPRESSURE_LOW; 16MB on VMPRESSURE_MEDIUM and 128MB on VMPRESSURE_CRITICAL. This is not done yet because there&#039;s a small limitation in the memory pressure code which doesn&#039;t allow this. I&#039;ll fix it&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the virtio-balloon driver within the guest. There&#039;s also two ways of implementing this:&lt;br /&gt;
&lt;br /&gt;
# The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure. The number of pages to be returned to the kernel is passed to the callback, so that the callback can deflate the balloon by that amount. This is what the current patchset does&lt;br /&gt;
# The virtio-balloon driver registers for an in-kernel memory pressure event (not upstream yet) and deflates the balloon by some fixed amount (maybe the same amount used in automatic inflate)&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
You have to do three things to play with automatic-ballooning:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10-rc1 or higher in the host. Make sure to enable CONFIG_CGROUPS and CONFIG_MEMCG&lt;br /&gt;
# Clone QEMU from &#039;&#039;git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/rfc.v2&#039;&#039; (or grab the patch [http://repo.or.cz/w/qemu/qmp-unstable.git/commit/59fec94e6396d6c32cdce47777440c3a988be63d here])&lt;br /&gt;
# Install the following kernel on your guest &#039;&#039;git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/rfc&#039;&#039; (or grab the patches from the [http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git/shortlog/refs/heads/virtio-balloon/auto-deflate/rfc web interface])&lt;br /&gt;
&lt;br /&gt;
After setting up the above, do the following to experiment with automatic deflate (which is easy to reproduce):&lt;br /&gt;
&lt;br /&gt;
# Pass &#039;&#039;-balloon virtio,auto-balloon=true&#039;&#039; when starting QEMU&lt;br /&gt;
# Wait for the guest to boot, then generate some memory pressure in the guest (say a kernel build with lots of jobs)&lt;br /&gt;
# Switch to QEMU&#039;s monitor and decrease guest memory (say from 1G to 200MB)&lt;br /&gt;
# Watch the guest increase its memory by repeatedly running &amp;quot;info balloon&amp;quot; on QEMU&#039;s monitor&lt;br /&gt;
&lt;br /&gt;
To see automatic inflate and automatic deflate in action, you can run several VMs in parallel doing some heavy memory workload. Make sure to over commit host memory. Say your host has 4GB, run 6 VMs with 1GB each.&lt;br /&gt;
&lt;br /&gt;
Another idea is to run one VM, but generate pressure in the host some way like a big kernel build or an application that allocates lots of memory.&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4824</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4824"/>
		<updated>2013-06-17T20:49:54Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to KVM guests performace (eg. swapping) or even extreme to the point where the kernel may kill a VM or an important virt stack component.&lt;br /&gt;
&lt;br /&gt;
To help avoiding this situation, a KVM guest could automatically return memory to the host when the host is facing memory pressure (automatic inflate). By doing so the guest may also get into memory pressure so we also need a way to allow the guest to automatically get memory back (automatic deflate).&lt;br /&gt;
&lt;br /&gt;
That&#039;s what the automatic ballooning project is about. The next section will dive into ways of implementing it. The following section will provide instructions on how to try current patches.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is performed by QEMU, that is, the KVM host. There are two ways I&#039;m playing with automatic inflate, in both of them QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events to learn when the host is under memory pressure:&lt;br /&gt;
&lt;br /&gt;
# QEMU registers for the VMPRESSURE_MEDIUM event and inflates the balloon by an user specified value when the event is received. That value value could default to 16MB or 32MB. This is what the current patchset does&lt;br /&gt;
# QEMU registers for the three memory pressure events and inflates the balloon accordingly. Say, it could inflate the balloon by 1MB on VMPRESSURE_LOW; 16MB on VMPRESSURE_MEDIUM and 128MB on VMPRESSURE_CRITICAL. This is not done yet because there&#039;s a small limitation in the memory pressure code which doesn&#039;t allow this. I&#039;ll fix it&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the virtio-balloon driver within the guest. There&#039;s also two ways of implementing this:&lt;br /&gt;
&lt;br /&gt;
# The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure. The number of pages to be returned to the kernel is passed to the callback, so that the callback can deflate the balloon by that amount. This is what the current patchset does&lt;br /&gt;
# The virtio-balloon driver registers for an in-kernel memory pressure event (not upstream yet) and deflates the balloon by some fixed amount (maybe the same amount used in automatic inflate)&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
You have to do three things to play with automatic-ballooning:&lt;br /&gt;
&lt;br /&gt;
# Install kernel 3.10-rc1 or higher in the host. Make sure to enable CONFIG_CGROUPS and CONFIG_MEMCG&lt;br /&gt;
# Clone QEMU from git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/rfc.v2 (or grab the patch [http://repo.or.cz/w/qemu/qmp-unstable.git/commit/59fec94e6396d6c32cdce47777440c3a988be63d here])&lt;br /&gt;
# Install the following kernel on your guest git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/rfc (or grab the patches from the [http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git/shortlog/refs/heads/virtio-balloon/auto-deflate/rfc web interface])&lt;br /&gt;
&lt;br /&gt;
After setting up the above, do the following to experiment with automatic deflate (which is easy to reproduce):&lt;br /&gt;
&lt;br /&gt;
# Pass -balloon virtio,auto-balloon=true when starting QEMU&lt;br /&gt;
# Wait for the guest to boot, then generate some memory pressure in the guest (say a kernel build with lots of jobs)&lt;br /&gt;
# Switch to QEMU&#039;s monitor and decrease guest memory (say from 1G to 200MB)&lt;br /&gt;
# Watch the guest increase its memory by repeatedly running &amp;quot;info balloon&amp;quot; on QEMU&#039;s monitor&lt;br /&gt;
&lt;br /&gt;
To see automatic inflate and automatic deflate in action, you can run several VMs in parallel doing some heavy memory workload. Make sure to over commit host memory. Say your host has 4GB, run 6 VMs with 1GB each.&lt;br /&gt;
&lt;br /&gt;
Another idea is to run one VM, but generate pressure in the host some way like a big kernel build or an application that allocates lots of memory.&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4823</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4823"/>
		<updated>2013-06-17T20:40:45Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to KVM guests performace (eg. swapping) or even extreme to the point where the kernel may kill a VM or an important virt stack component.&lt;br /&gt;
&lt;br /&gt;
To help avoiding this situation, a KVM guest could automatically return memory to the host when the host is facing memory pressure (automatic inflate). By doing so the guest may also get into memory pressure so we also need a way to allow the guest to automatically get memory back (automatic deflate).&lt;br /&gt;
&lt;br /&gt;
That&#039;s what the automatic ballooning project is about. The next section will dive into ways of implementing it. The following section will provide instructions on how to try current patches.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is performed by QEMU, that is, the KVM host. There are two ways I&#039;m playing with automatic inflate, in both of them QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events to learn when the host is under memory pressure:&lt;br /&gt;
&lt;br /&gt;
# QEMU registers for the VMPRESSURE_MEDIUM event and inflates the balloon by an user specified value when the event is received. That value value could default to 16MB or 32MB. This is what the current patchset does&lt;br /&gt;
# QEMU registers for the three memory pressure events and inflates the balloon accordingly. Say, it could inflate the balloon by 1MB on VMPRESSURE_LOW; 16MB on VMPRESSURE_MEDIUM and 128MB on VMPRESSURE_CRITICAL. This is not done yet because there&#039;s a small limitation in the memory pressure code which doesn&#039;t allow this. I&#039;ll fix it&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the virtio-balloon driver within the guest. There&#039;s also two ways of implementing this:&lt;br /&gt;
&lt;br /&gt;
# The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure. The number of pages to be returned to the kernel is passed to the callback, so that the callback can deflate the balloon by that amount. This is what the current patchset does&lt;br /&gt;
# The virtio-balloon driver registers for an in-kernel memory pressure event (not upstream yet) and deflates the balloon by some fixed amount (maybe the same amount used in automatic inflate)&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
You have to do three things to play with automatic-ballooning:&lt;br /&gt;
&lt;br /&gt;
# Build &amp;amp; install kernel 3.10-rc1 or higher in the host. Make sure to enable CONFIG_CGROUPS and CONFIG_MEMCG&lt;br /&gt;
# Clone QEMU from git://repo.or.cz/qemu/qmp-unstable.git balloon/auto-ballooning/rfc.v2 (or grab the patch [http://repo.or.cz/w/qemu/qmp-unstable.git/commit/59fec94e6396d6c32cdce47777440c3a988be63d here])&lt;br /&gt;
# Build &amp;amp; install the following kernel on your guest git://repo.or.cz/linux-2.6/luiz-linux-2.6.git virtio-balloon/auto-deflate/rfc (or grab the patches from the [http://repo.or.cz/w/linux-2.6/luiz-linux-2.6.git/shortlog/refs/heads/virtio-balloon/auto-deflate/rfc web interface])&lt;br /&gt;
&lt;br /&gt;
After setting up the above, do the following to actually try automatic ballooning:&lt;br /&gt;
&lt;br /&gt;
# Pass -balloon virtio,auto-balloon=true when starting QEMU&lt;br /&gt;
# Wait for the guest to boot, then generate some memory pressure in the guest (say a kernel build with lots of jobs)&lt;br /&gt;
# Switch to QEMU&#039;s monitor and decrease guest memory (say from 1G to 200MB)&lt;br /&gt;
# Watch the guest to increase its memory by repeatedly running &amp;quot;info balloon&amp;quot; on QEMU&#039;s monitor&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4822</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4822"/>
		<updated>2013-06-17T20:01:05Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to KVM guests performace (eg. swapping) or even extreme to the point where the kernel may kill a VM or an important virt stack component.&lt;br /&gt;
&lt;br /&gt;
To help avoiding this situation, a KVM guest could automatically return memory to the host when the host is facing memory pressure (automatic inflate). By doing so the guest may also get into memory pressure so we also need a way to allow the guest to automatically get memory back (automatic deflate).&lt;br /&gt;
&lt;br /&gt;
That&#039;s what the automatic ballooning project is about. The next section will dive into ways of implementing it. The following section will provide instructions on how to try current patches.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is performed by QEMU, that is, the KVM host. There are two ways I&#039;m playing with automatic inflate, in both of them QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events to learn when the host is under memory pressure:&lt;br /&gt;
&lt;br /&gt;
# QEMU registers for the VMPRESSURE_MEDIUM event and inflates the balloon by an user specified value when the event is received. That value value could default to 16MB or 32MB. This is what the current patchset does&lt;br /&gt;
# QEMU registers for the three memory pressure events and inflates the balloon accordingly. Say, it could inflate the balloon by 1MB on VMPRESSURE_LOW; 16MB on VMPRESSURE_MEDIUM and 128MB on VMPRESSURE_CRITICAL. This is not done yet because there&#039;s a small limitation in the memory pressure code which doesn&#039;t allow this. I&#039;ll fix it&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the virtio-balloon driver within the guest. There&#039;s also two ways of implementing this:&lt;br /&gt;
&lt;br /&gt;
# The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure. The number of pages to be returned to the kernel is passed to the callback, so that the callback can deflate the balloon by that amount. This is what the current patchset does&lt;br /&gt;
# The virtio-balloon driver registers for an in-kernel memory pressure event (not upstream yet) and deflates the balloon by some fixed amount (maybe the same amount used in automatic inflate)&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4810</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4810"/>
		<updated>2013-06-13T21:11:26Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to KVM guests performace (eg. swapping) or even extreme to the point where the kernel may kill a VM or an important virt stack component.&lt;br /&gt;
&lt;br /&gt;
To help avoiding this situation, a KVM guest could automatically return memory to the host when the host is facing memory pressure (automatic inflate). By doing so the guest may also get into memory pressure so we also need a way to allow the guest to automatically get memory back (automatic deflate).&lt;br /&gt;
&lt;br /&gt;
That&#039;s what the automatic ballooning project is about. The next section will dive into ways of implementing it. The following section will provide instructions on how to try current patches.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is performed by QEMU, that is, the KVM host. There are two ways I&#039;m playing with automatic inflate, in both of them QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events to learn when the host is under memory pressure:&lt;br /&gt;
&lt;br /&gt;
# QEMU registers for the VMPRESSURE_MEDIUM event and inflates the balloon by an user specified value when the event is received. That value value could default to 16MB or 32MB. This is what the current patchset does&lt;br /&gt;
# QEMU registers for the three memory pressure events and inflates the balloon accordingly. Say, it could inflate the balloon by 1MB on VMPRESSURE_LOW; 16MB on VMPRESSURE_MEDIUM and 128MB on VMPRESSURE_CRITICAL. This is not done yet because there&#039;s a small limitation in the memory pressure code which doesn&#039;t allow this. I&#039;ll fix it&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the virtio-balloon driver in the guest. There&#039;s also two ways of implementing this:&lt;br /&gt;
&lt;br /&gt;
# The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure. The number of pages to be returned to the kernel is passed to the callback, so that the callback can deflate the balloon by that amount. This is what the current patchset does&lt;br /&gt;
# The virtio-balloon driver registers for an in-kernel memory pressure event (not upstream yet) and deflates the balloon by some fixed amount (maybe the same amount used in automatic inflate)&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4809</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4809"/>
		<updated>2013-06-13T21:05:48Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to KVM guests performace (eg. swapping) or even extreme to the point where the kernel may kill a VM or an important virt stack component.&lt;br /&gt;
&lt;br /&gt;
To help avoiding this situation, a KVM guest could automatically return memory to the host when the host is facing memory pressure (automatic inflate). By doing so the guest may also get into memory pressure so we also need a way to allow the guest to automatically get memory back (automatic deflate).&lt;br /&gt;
&lt;br /&gt;
That&#039;s what the automatic ballooning project is about. The next section will dive into ways of implementing it. The following section will provide instructions on how to try current patches.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is performed by QEMU, that is, the KVM host. There are two ways I&#039;m playing with automatic inflate, in both of them QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events to learn when the host is under memory pressure:&lt;br /&gt;
&lt;br /&gt;
# QEMU registers for VMPRESSURE_MEDIUM event and inflates the balloon by an user specified value when that event is received. That value value could default to 16MB or 32MB. This is what the current patchset does&lt;br /&gt;
# QEMU registers for the three memory pressure events and inflates the balloon accordingly. Say, it inflates the balloon by 1MB on VMPRESSURE_LOW; 16MB on VMPRESSURE_MEDIUM and 128MB on VMPRESSURE_CRITICAL. This is not done yet because there&#039;s a small limitation in the memory pressure code which doesn&#039;t allow this. I&#039;ll fix it&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the virtio-balloon driver in the guest. There&#039;s also two ways of implementing this:&lt;br /&gt;
&lt;br /&gt;
# The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure. The number of pages to be returned to the kernel is passed to the callback, so that the callback can deflate the balloon by that amount. This is what the current patchset does&lt;br /&gt;
# The virtio-balloon driver registers for an in-kernel memory pressure event (not upstream yet) and deflates the balloon by some fixed amount (maybe the same used in automatic inflate)&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4808</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4808"/>
		<updated>2013-06-13T21:05:21Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to KVM guests performace (eg. swapping) or even extreme to the point where the kernel may kill a VM or an important virt stack component.&lt;br /&gt;
&lt;br /&gt;
To help avoiding this situation, a KVM guest could automatically return memory to the host when the host is facing memory pressure (automatic inflate). By doing so the guest may also get into memory pressure so we also need a way to allow the guest to automatically get memory back (automatic deflate).&lt;br /&gt;
&lt;br /&gt;
That&#039;s what the automatic ballooning project is about. The next section will dive into ways of implementing it. The following section will provide instructions on how to try current patches.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is performed by QEMU, that is, the KVM host. There are two ways I&#039;m playing with automatic inflate, in both of them QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events to learn when the host is under memory pressure:&lt;br /&gt;
&lt;br /&gt;
# QEMU registers for VMPRESSURE_MEDIUM event and inflates the balloon by an user specified value when that event is received. That value value could default to 16MB or 32MB. This is what the current patchset does&lt;br /&gt;
&lt;br /&gt;
# QEMU registers for the three memory pressure events and inflates the balloon accordingly. Say, it inflates the balloon by 1MB on VMPRESSURE_LOW; 16MB on VMPRESSURE_MEDIUM and 128MB on VMPRESSURE_CRITICAL. This is not done yet because there&#039;s a small limitation in the memory pressure code which doesn&#039;t allow this. I&#039;ll fix it&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the virtio-balloon driver in the guest. There&#039;s also two ways of implementing this:&lt;br /&gt;
&lt;br /&gt;
# The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure. The number of pages to be returned to the kernel is passed to the callback, so that the callback can deflate the balloon by that amount. This is what the current patchset does&lt;br /&gt;
&lt;br /&gt;
# The virtio-balloon driver registers for an in-kernel memory pressure event (not upstream yet) and deflates the balloon by some fixed amount (maybe the same used in automatic inflate)&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4807</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4807"/>
		<updated>2013-06-13T20:56:56Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to kvm guests performace (eg. swapping) or even extreme to the point where the kernel may kill a VM or an important virt stack component.&lt;br /&gt;
&lt;br /&gt;
To help avoiding this situation, a kvm guest could automatically return memory to the host when the host is facing memory pressure. By doing so the guest may also get into memory pressure so we also need a way to allow the guest to automatically get memory back.&lt;br /&gt;
&lt;br /&gt;
That&#039;s what the automatic ballooning project is about. The next section will dive into ways of implementing it. The following section will provide instructions on how to try current patches.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is done by QEMU, that is the KVM host. There are two ways I&#039;m playing with automatic inflate, in both of them QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events to learn when the host is under memory pressure:&lt;br /&gt;
&lt;br /&gt;
* QEMU registers for VMPRESSURE_MEDIUM and inflates the balloon by an user specified amount, which could default to 16MB or 32MB. This is what the current patchset does&lt;br /&gt;
&lt;br /&gt;
* QEMU registers for the three memory pressure events and inflates the balloon accordingly, say it inflates the balloon by 1MB on VMPRESSURE_LOW; 16MB on VMPRESSURE_MEDIUM and 128MB on VMPRESSURE_CRITICAL. This is not done yet because there&#039;s a small limitation on the vmpressure code which doesn&#039;t allow this. I&#039;ll fix it&lt;br /&gt;
&lt;br /&gt;
=== Automatic Deflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic deflate is performed by the virtio-balloon driver in the guest. There&#039;s also two ways of implementing this:&lt;br /&gt;
&lt;br /&gt;
* The virtio-balloon driver registers a callback with the shrinker API. That callback is called when the guest kernel is facing memory pressure. The number of pages to be returned to the kernel is passed to the callback, so that the callback can deflate the balloon by that amount. This is what the current code does&lt;br /&gt;
&lt;br /&gt;
* The virtio-balloon driver registers for an in-kernel vmpressure event (not upstream yet) and deflates the balloon by some fixed amount (maybe the same used in automatic inflate)&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4806</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4806"/>
		<updated>2013-06-13T20:49:34Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to kvm guests performace (eg. swapping) or even extreme to the point where the kernel may kill a VM or an important virt stack component.&lt;br /&gt;
&lt;br /&gt;
To help avoiding this situation, a kvm guest could automatically return memory to the host when the host is facing memory pressure. By doing so the guest may also get into memory pressure so we also need a way to allow the guest to automatically get memory back.&lt;br /&gt;
&lt;br /&gt;
That&#039;s what the automatic ballooning project is about. The next section will dive into ways of implementing it. The following section will provide instructions on how to try current patches.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Automatic Inflate ===&lt;br /&gt;
&lt;br /&gt;
Automatic inflate is done by QEMU, that is the KVM host. There are two ways I&#039;m playing with automatic inflate, in both of them QEMU registers for [http://lwn.net/Articles/544652/ memory pressure] events to learn when the host is under memory pressure:&lt;br /&gt;
&lt;br /&gt;
* QEMU registers for VMPRESSURE_MEDIUM and inflates the balloon by an user specified amount, which could default to 16MB or 32MB. This is what the current patchset does&lt;br /&gt;
&lt;br /&gt;
* QEMU registers for the three memory pressure events and inflates the balloon accordingly, say it inflates the balloon by 1MB on VMPRESSURE_LOW; 16MB on VMPRESSURE_MEDIUM and 128MB on VMPRESSURE_CRITICAL. This is not done yet because there&#039;s a small limitation on the vmpressure code which doesn&#039;t allow this. I&#039;ll fix it&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4805</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4805"/>
		<updated>2013-06-13T20:20:18Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Automatic Ballooning =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to kvm guests performace (eg. swapping) or even extreme to the point where the kernel kills user-space processes (which could be a kvm guest itself or a virt stack component).&lt;br /&gt;
&lt;br /&gt;
To help avoiding this situation, a kvm guest could automatically inflate its balloon (thus returning memory to the host) when the host is facing memory pressure. Likewise, a kvm guest could automatically deflate its balloon when the guest itself is facing memory pressure (maybe due to automatic inflate).&lt;br /&gt;
&lt;br /&gt;
=== status ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FIXME&#039;&#039;&#039;: add tree.&lt;br /&gt;
&lt;br /&gt;
=== testing ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FIXME&#039;&#039;&#039;: describe.&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4614</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4614"/>
		<updated>2012-12-12T14:05:56Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Auto-ballooning =&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to kvm guests performace (eg. swapping) or even extreme to the point where the kernel kills user-space processes (which could be a kvm guest itself or a virt stack component).&lt;br /&gt;
&lt;br /&gt;
To help avoiding this situation, a kvm guest could automatically inflate its balloon (thus returning memory to the host) when the host is facing memory pressure. Likewise, a kvm guest could automatically deflate its balloon when the guest itself is facing memory pressure (maybe due to automatic inflate).&lt;br /&gt;
&lt;br /&gt;
The goal of this page is to collect ideas on how to implement auto-ballooning.&lt;br /&gt;
Currently, there is only one proposal, which is the &amp;quot;automatic balance&amp;quot; idea,&lt;br /&gt;
mostly designed by Rik van Riel.&lt;br /&gt;
&lt;br /&gt;
== Automatic balance ==&lt;br /&gt;
&lt;br /&gt;
In automatic balance, the hypervisor (eg. QEMU) must have a way to detect that the host is under memory pressure. When this happens, QEMU could automatically inflate the guest&#039;s balloon to some value (say 10MB). When it&#039;s the guest that&#039;s facing memory pressure, its balloon driver could automatically deflate the memory balloon.&lt;br /&gt;
&lt;br /&gt;
It&#039;s expected that inflate and deflate will balance each other over time.&lt;br /&gt;
&lt;br /&gt;
Next sections describe the implementation details of this idea.&lt;br /&gt;
&lt;br /&gt;
=== auto-inflate ===&lt;br /&gt;
&lt;br /&gt;
There are two components needed to make auto-inflate work.&lt;br /&gt;
&lt;br /&gt;
* A (host) kernel API to let user-space processes know when the kernel is facing memory pressure&lt;br /&gt;
&lt;br /&gt;
* QEMU changes to use the host kernel API, and to inflate the guest&#039;s balloon when the host kernel is facing memory pressure&lt;br /&gt;
&lt;br /&gt;
=== auto-deflate ===&lt;br /&gt;
&lt;br /&gt;
Only one component is needed for auto-deflate&lt;br /&gt;
&lt;br /&gt;
* The guest virtio-balloon driver must be changed to automatically deflate the balloon when the guest is facing memory pressure&lt;br /&gt;
&lt;br /&gt;
=== status ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FIXME&#039;&#039;&#039;: add tree.&lt;br /&gt;
&lt;br /&gt;
=== testing ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FIXME&#039;&#039;&#039;: describe.&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4613</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4613"/>
		<updated>2012-12-12T14:03:27Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Auto-ballooning =&lt;br /&gt;
&lt;br /&gt;
When a Linux host is running out of memory, the kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to kvm guests performace (eg. swapping) or even extreme to the point where the kernel kills user-space processes (which could be a kvm guest itself or a virt stack component).&lt;br /&gt;
&lt;br /&gt;
To help avoiding this situation, a kvm guest could automatically inflate its balloon (thus returning memory to the host) when the host is facing memory pressure. Likewise, a kvm guest could automatically deflate its balloon when the guest itself is facing memory pressure (maybe due to automatic inflate).&lt;br /&gt;
&lt;br /&gt;
The goal of this page is to collect ideas on how to implement auto-ballooning.&lt;br /&gt;
Currently, there is only one proposal, which is the &amp;quot;automatic balance&amp;quot; idea,&lt;br /&gt;
mostly designed by Rik van Riel.&lt;br /&gt;
&lt;br /&gt;
== Automatic balance ==&lt;br /&gt;
&lt;br /&gt;
In automatic balance, the hypervisor (eg. QEMU) must have a way to detect that the host is under memory pressure. When this happens, QEMU could automatically inflate the guest&#039;s balloon to some value (say 10MB). When it&#039;s the guest that&#039;s facing memory pressure, its balloon driver could automatically deflate the memory balloon.&lt;br /&gt;
&lt;br /&gt;
It&#039;s expected that inflate and deflate will balance each other over time.&lt;br /&gt;
&lt;br /&gt;
Next sections describe the implementation details of this idea.&lt;br /&gt;
&lt;br /&gt;
=== auto-inflate ===&lt;br /&gt;
&lt;br /&gt;
There are three components needed to make auto-inflate work.&lt;br /&gt;
&lt;br /&gt;
* A host kernel API to let user-space processes know when the kernel is facing memory pressure (&#039;&#039;&#039;TODO&#039;&#039;&#039;: point to mempressure API)&lt;br /&gt;
&lt;br /&gt;
* QEMU changes to use the host kernel API, and to inflate the guest&#039;s balloon when the host kernel is facing memory pressure&lt;br /&gt;
&lt;br /&gt;
=== auto-deflate ===&lt;br /&gt;
&lt;br /&gt;
Only one component is needed for auto-deflate:&lt;br /&gt;
&lt;br /&gt;
* The guest virtio-balloon driver must be changed to automatically deflate the balloon when the guest is facing memory pressure&lt;br /&gt;
&lt;br /&gt;
=== status ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FIXME&#039;&#039;&#039;: add tree.&lt;br /&gt;
&lt;br /&gt;
=== testing ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FIXME&#039;&#039;&#039;: describe.&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4612</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4612"/>
		<updated>2012-12-12T01:45:04Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Auto-ballooning =&lt;br /&gt;
&lt;br /&gt;
When a kvm host is running out of memory, the host kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to kvm guests performace (eg. swapping) or even extreme to the point where the kernel kills user-space processes (which could be a kvm guest itself or a virt stack component).&lt;br /&gt;
&lt;br /&gt;
To help avoiding those scenarios, the hypervisor (eg. QEMU) could automatically inflate the guest&#039;s balloon (thus returning memory to the host). This will also require a method for automatically deflating the guest&#039;s memory, so that fairness is ensured and the guest kernel doesn&#039;t run itself into trouble.&lt;br /&gt;
&lt;br /&gt;
The goal of this page is to collect ideas on how to implement auto-ballooning.&lt;br /&gt;
Currently, there is only one proposal, which is the &amp;quot;automatic balance&amp;quot; idea,&lt;br /&gt;
mostly designed by Rik van Riel.&lt;br /&gt;
&lt;br /&gt;
== Automatic balance ==&lt;br /&gt;
&lt;br /&gt;
In automatic balance, the hypervisor (eg. QEMU) automatically inflates the guest balloon when the host kernel is under memory pressure. On the other hand, when the guest kernel is under memory pressure, it will automatically try to deflate its balloon (which possibly may have been inflated by the hypervisor).&lt;br /&gt;
&lt;br /&gt;
It&#039;s expected that inflate and deflate will automatically balance each other over time.&lt;br /&gt;
&lt;br /&gt;
Next sections describe the implementation details of this idea.&lt;br /&gt;
&lt;br /&gt;
=== auto-inflate ===&lt;br /&gt;
&lt;br /&gt;
There are three components needed to make auto-inflate work.&lt;br /&gt;
&lt;br /&gt;
* A host kernel API to let user-space processes know when the kernel is facing memory pressure (&#039;&#039;&#039;TODO&#039;&#039;&#039;: point to mempressure API)&lt;br /&gt;
&lt;br /&gt;
* QEMU changes to use the host kernel API, and to inflate the guest&#039;s balloon when the host kernel is facing memory pressure&lt;br /&gt;
&lt;br /&gt;
=== auto-deflate ===&lt;br /&gt;
&lt;br /&gt;
Only one component is needed for auto-deflate:&lt;br /&gt;
&lt;br /&gt;
* The guest virtio-balloon driver must be changed to automatically deflate the balloon when the guest is facing memory pressure&lt;br /&gt;
&lt;br /&gt;
=== status ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FIXME&#039;&#039;&#039;: add tree.&lt;br /&gt;
&lt;br /&gt;
=== testing ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FIXME&#039;&#039;&#039;: describe.&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4611</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4611"/>
		<updated>2012-12-12T01:43:38Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Auto-ballooning =&lt;br /&gt;
&lt;br /&gt;
When a kvm host is running out of memory, the host kernel will take action to &#039;&#039;reclaim&#039;&#039; memory. This action may be detrimental to kvm guests performace (eg. swapping) or even extreme to the point where the kernel kills user-space processes (which could be a kvm guest itself or a virt stack component).&lt;br /&gt;
&lt;br /&gt;
To help avoiding those scenarios, the hypervisor (eg. QEMU) could automatically inflate the guest&#039;s balloon (thus returning memory to the host). This will also require a method for automatically deflating the guest&#039;s memory, so that fairness is ensured and the guest kernel doesn&#039;t run itself into trouble.&lt;br /&gt;
&lt;br /&gt;
The goal of this page is to collect ideas on how to implement auto-ballooning.&lt;br /&gt;
Currently, there is only one proposal, which is the &amp;quot;automatic balance&amp;quot; idea,&lt;br /&gt;
mostly designed by Rik van Riel.&lt;br /&gt;
&lt;br /&gt;
== Automatic balance ==&lt;br /&gt;
&lt;br /&gt;
In automatic balance, the hypervisor (eg. QEMU) automatically inflates the guest balloon when the host kernel is under memory pressure. On the other hand, when the guest kernel is under memory pressure, it will automatically try to deflate its balloon (which possibly may have been inflated by the hypervisor).&lt;br /&gt;
&lt;br /&gt;
It&#039;s expected that inflate and deflate will automatically balance each other over time.&lt;br /&gt;
&lt;br /&gt;
Next sections describe the implementation details of this idea.&lt;br /&gt;
&lt;br /&gt;
=== auto-inflate ===&lt;br /&gt;
&lt;br /&gt;
There are three components needed to make auto-inflate work.&lt;br /&gt;
&lt;br /&gt;
* A host kernel API to let user-space processes know when the kernel is facing memory pressure (&#039;&#039;&#039;TODO&#039;&#039;&#039;: point to mempressure API)&lt;br /&gt;
&lt;br /&gt;
* QEMU changes to use the host kernel API, and to inflate the guest&#039;s balloon when the host kernel is facing memory pressure&lt;br /&gt;
&lt;br /&gt;
=== auto-deflate ===&lt;br /&gt;
&lt;br /&gt;
Only one component is needed for auto-deflate:&lt;br /&gt;
&lt;br /&gt;
* The guest virtio-balloon driver must be changed to automatically deflate the balloon when the guest is facing memory pressure&lt;br /&gt;
&lt;br /&gt;
=== status ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FIXME&#039;&#039;&#039;: add tree.&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;FIXME&#039;&#039;&#039;: add tree.&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4610</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4610"/>
		<updated>2012-12-12T01:42:01Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Auto-ballooning =&lt;br /&gt;
&lt;br /&gt;
When a kvm host is running out of memory, the host kernel will take action to reclaim memory. This action may be detrimental to kvm guests performace (eg. swapping) or even extreme to the point where the kernel kills user-space processes (which could be a kvm guest itself or a virt stack component).&lt;br /&gt;
&lt;br /&gt;
To help avoiding those scenarios, the hypervisor (eg. QEMU) could automatically inflate the guest&#039;s balloon (thus returning memory to the host). This will also require a method for automatically deflating the guest&#039;s memory, so that fairness is ensured and the guest kernel doesn&#039;t run itself into trouble.&lt;br /&gt;
&lt;br /&gt;
The goal of this page is to collect ideas on how to implement auto-ballooning.&lt;br /&gt;
Currently, there is only one proposal, which is the &amp;quot;automatic balance&amp;quot; idea,&lt;br /&gt;
mostly designed by Rik van Riel.&lt;br /&gt;
&lt;br /&gt;
== Automatic balance ==&lt;br /&gt;
&lt;br /&gt;
In automatic balance, the hypervisor (eg. QEMU) automatically inflates the guest balloon when the host kernel is under memory pressure. On the other hand, when the guest kernel is under memory pressure, it will automatically try to deflate its balloon (which possibly may have been inflated by the hypervisor).&lt;br /&gt;
&lt;br /&gt;
It&#039;s expected that inflate and deflate will automatically balance each other over time.&lt;br /&gt;
&lt;br /&gt;
Next sections describe the implementation details of this idea.&lt;br /&gt;
&lt;br /&gt;
=== auto-inflate ===&lt;br /&gt;
&lt;br /&gt;
There are three components needed to make auto-inflate work.&lt;br /&gt;
&lt;br /&gt;
* A host kernel API to let user-space processes know when the kernel is facing memory pressure (TODO: point to mempressure API)&lt;br /&gt;
&lt;br /&gt;
* QEMU changes to use the host kernel API, and to inflate the guest&#039;s balloon when the host kernel is facing memory pressure&lt;br /&gt;
&lt;br /&gt;
=== auto-deflate ===&lt;br /&gt;
&lt;br /&gt;
Only one component is needed for auto-deflate:&lt;br /&gt;
&lt;br /&gt;
* The guest virtio-balloon driver must be changed to automatically deflate the balloon when the guest is facing memory pressure&lt;br /&gt;
&lt;br /&gt;
=== Status ===&lt;br /&gt;
&lt;br /&gt;
FIXME: add luiz tree.&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
	<entry>
		<id>https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4609</id>
		<title>Projects/auto-ballooning</title>
		<link rel="alternate" type="text/html" href="https://linux-kvm.org/index.php?title=Projects/auto-ballooning&amp;diff=4609"/>
		<updated>2012-12-12T01:37:44Z</updated>

		<summary type="html">&lt;p&gt;LuizCapitulino: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Auto-ballooning =&lt;br /&gt;
&lt;br /&gt;
When a kvm host is running out of memory, the host kernel will take action to reclaim memory. This action may be detrimental to kvm guests performace (eg. swapping) or even extreme to the point where the kernel kills user-space processes (which could be a kvm guest itself or a virt stack component).&lt;br /&gt;
&lt;br /&gt;
To help avoiding those scenarios, the hypervisor (eg. QEMU) could automatically inflate the guest&#039;s balloon (thus returning memory to the host). This will also require a method for automatically deflating the guest&#039;s memory, so that fairness is ensured and the guest kernel doesn&#039;t run itself into trouble.&lt;br /&gt;
&lt;br /&gt;
The object of this page is to collect ideas on how to implement auto-ballooning.&lt;br /&gt;
Currently, there is only one proposal, which is the &amp;quot;automatic balance&amp;quot; idea,&lt;br /&gt;
mostly designed by Rik van Riel.&lt;br /&gt;
&lt;br /&gt;
== Automatic balance ==&lt;br /&gt;
&lt;br /&gt;
In automatic balance, the hypervisor (eg. QEMU) automatically inflates the guest balloon when the host kernel is under memory pressure. On the other hand, when the guest kernel is under memory pressure, it will automatically try to deflate its balloon (which possibly may have been inflated by the hypervisor).&lt;br /&gt;
&lt;br /&gt;
It&#039;s expected that automatic inflate and deflate can balance each other.&lt;br /&gt;
&lt;br /&gt;
Next sections describe the implementation details of this idea.&lt;br /&gt;
&lt;br /&gt;
=== auto-inflate ===&lt;br /&gt;
&lt;br /&gt;
There are three components needed to make auto-inflate work.&lt;br /&gt;
&lt;br /&gt;
1. A host kernel API to let user-space processes know when the kernel is facing memory pressure&lt;br /&gt;
&lt;br /&gt;
2. QEMU changes to use the host kernel API, and to inflate the guest&#039;s balloon when the host kernel is facing memory pressure&lt;br /&gt;
&lt;br /&gt;
=== auto-deflate ===&lt;br /&gt;
&lt;br /&gt;
Only one component is needed for auto-deflate:&lt;br /&gt;
&lt;br /&gt;
1. The guest virtio-balloon driver must be changed to automatically deflate the balloon when the guest is facing memory pressure&lt;br /&gt;
&lt;br /&gt;
=== Status ===&lt;/div&gt;</summary>
		<author><name>LuizCapitulino</name></author>
	</entry>
</feed>