<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/drivers/virtio, branch v3.3</title>
<subtitle>Linux kernel source tree</subtitle>
<id>https://git.amat.us/linux/atom/drivers/virtio?h=v3.3</id>
<link rel='self' href='https://git.amat.us/linux/atom/drivers/virtio?h=v3.3'/>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/'/>
<updated>2012-02-29T22:58:41Z</updated>
<entry>
<title>virtio: balloon: leak / fill balloon across S4</title>
<updated>2012-02-29T22:58:41Z</updated>
<author>
<name>Amit Shah</name>
<email>amit.shah@redhat.com</email>
</author>
<published>2012-02-29T12:12:51Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=4eb05d562ea1ea34ff607aa877aefbf05b21c140'/>
<id>urn:sha1:4eb05d562ea1ea34ff607aa877aefbf05b21c140</id>
<content type='text'>
commit e562966dbaf49e7804097cd991e5d3a8934fc148 added support for S4 to
the balloon driver.  The freeze function did nothing to free the pages,
since reclaiming the pages from the host to immediately give them back
(if S4 was successful) seemed wasteful.  Also, if S4 wasn't successful,
the guest would have to re-fill the balloon.  On restore, the pages were
supposed to be marked freed and the free page counters were incremented
to reflect the balloon was totally deflated.

However, this wasn't done right.  The pages that were earlier taken away
from the guest during a balloon inflation operation were just shown as
used pages after a successful restore from S4.  Just a fancy way of
leaking lots of memory.

Instead of trying that, just leak the balloon on freeze and fill it on
restore/thaw paths.  This works properly now.  The optimisation to not
leak can be added later on after a bit of refactoring of the code.

Signed-off-by: Amit Shah &lt;amit.shah@redhat.com&gt;
Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
</content>
</entry>
<entry>
<title>virtio: correct the memory barrier in virtqueue_kick_prepare()</title>
<updated>2012-01-27T21:40:23Z</updated>
<author>
<name>Jason Wang</name>
<email>jasowang@redhat.com</email>
</author>
<published>2012-01-20T08:17:08Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=a72caae21803b74e04e2afda5e035f149d4ea118'/>
<id>urn:sha1:a72caae21803b74e04e2afda5e035f149d4ea118</id>
<content type='text'>
Use virtio_mb() to make sure the available index to be exposed before
checking the the avail event. Otherwise we may get stale value of
avail event in guest and never kick the host after.

Note: this fixes a bug introduced by ee7cd8981e15bcb365fc762afe3fc47b8242f630.

Signed-off-by: Jason Wang &lt;jasowang@redhat.com&gt;
Acked-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
Cc: stable@kernel.org
</content>
</entry>
<entry>
<title>virtio: fix typos of memory barriers</title>
<updated>2012-01-27T21:40:22Z</updated>
<author>
<name>Jason Wang</name>
<email>jasowang@redhat.com</email>
</author>
<published>2012-01-20T08:16:59Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=4dbc5d9f4f791df8a5879f4a655f517adc7f56d1'/>
<id>urn:sha1:4dbc5d9f4f791df8a5879f4a655f517adc7f56d1</id>
<content type='text'>
Note: this fixes a bug introduced recently in
7b21e34fd1c272e3a8c3846168f2f6287a4cd72b.

Signed-off-by: Jason Wang &lt;jasowang@redhat.com&gt;
Acked-by: Michael S. Tsirkin &lt;mst@redhat.com&gt;
Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
</content>
</entry>
<entry>
<title>virtio: balloon: Add freeze, restore handlers to support S4</title>
<updated>2012-01-12T05:14:47Z</updated>
<author>
<name>Amit Shah</name>
<email>amit.shah@redhat.com</email>
</author>
<published>2011-12-22T11:28:35Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=e562966dbaf49e7804097cd991e5d3a8934fc148'/>
<id>urn:sha1:e562966dbaf49e7804097cd991e5d3a8934fc148</id>
<content type='text'>
Handling balloon hibernate / restore is tricky.  If the balloon was
inflated before going into the hibernation state, upon resume, the host
will not have any memory of that.  Any pages that were passed on to the
host earlier would most likely be invalid, and the host will have to
re-balloon to the previous value to get in the pre-hibernate state.

So the only sane thing for the guest to do here is to discard all the
pages that were put in the balloon.  When to discard the pages is the
next question.

One solution is to deflate the balloon just before writing the image to
the disk (in the freeze() PM callback).  However, asking for pages from
the host just to discard them immediately after seems wasteful of
resources.  Hence, it makes sense to do this by just fudging our
counters soon after wakeup.  This means we don't deflate the balloon
before sleep, and also don't put unnecessary pressure on the host.

This also helps in the thaw case: if the freeze fails for whatever
reason, the balloon should continue to remain in the inflated state.
This was tested by issuing 'swapoff -a' and trying to go into the S4
state.  That fails, and the balloon stays inflated, as expected.  Both
the host and the guest are happy.

Finally, in the restore() callback, we empty the list of pages that were
previously given off to the host, add the appropriate number of pages to
the totalram_pages counter, reset the num_pages counter to 0, and
all is fine.

As a last step, delete the vqs on the freeze callback to prepare for
hibernation, and re-create them in the restore and thaw callbacks to
resume normal operation.

The kthread doesn't race with any operations here, since it's frozen
before the freeze() call and is thawed after the thaw() and restore()
callbacks, so we're safe with that.

Signed-off-by: Amit Shah &lt;amit.shah@redhat.com&gt;
Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
</content>
</entry>
<entry>
<title>virtio: balloon: Move vq initialization into separate function</title>
<updated>2012-01-12T05:14:46Z</updated>
<author>
<name>Amit Shah</name>
<email>amit.shah@redhat.com</email>
</author>
<published>2011-12-22T11:28:34Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=be91c33dd15eff6b0dffc60cee4c8042e75493d2'/>
<id>urn:sha1:be91c33dd15eff6b0dffc60cee4c8042e75493d2</id>
<content type='text'>
The probe and PM restore functions will share this code.

Signed-off-by: Amit Shah &lt;amit.shah@redhat.com&gt;
Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
</content>
</entry>
<entry>
<title>virtio: pci: add PM notification handlers for restore, freeze, thaw, poweroff</title>
<updated>2012-01-12T05:14:44Z</updated>
<author>
<name>Amit Shah</name>
<email>amit.shah@redhat.com</email>
</author>
<published>2011-12-22T11:28:26Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=f0fe6f11503fa9880867554350ac5d3092c47251'/>
<id>urn:sha1:f0fe6f11503fa9880867554350ac5d3092c47251</id>
<content type='text'>
Handle thaw, restore and freeze notifications from the PM core.  Expose
these to individual virtio drivers that can quiesce and resume vq
operations.  For drivers not implementing the thaw() method, use the
restore method instead.

These functions also save device-specific data so that the device can be
put in pre-suspend state after resume, and disable and enable the PCI
device in the freeze and resume functions, respectively.

Signed-off-by: Amit Shah &lt;amit.shah@redhat.com&gt;
Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
</content>
</entry>
<entry>
<title>virtio: pci: switch to new PM API</title>
<updated>2012-01-12T05:14:44Z</updated>
<author>
<name>Amit Shah</name>
<email>amit.shah@redhat.com</email>
</author>
<published>2011-12-22T11:28:25Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=d077536386595309060dda57e7b7474c501a589b'/>
<id>urn:sha1:d077536386595309060dda57e7b7474c501a589b</id>
<content type='text'>
The older PM API doesn't have a way to get notifications on hibernate
events.  Switch to the newer one that gives us those notifications.

Signed-off-by: Amit Shah &lt;amit.shah@redhat.com&gt;
Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
</content>
</entry>
<entry>
<title>virtio: add debugging if driver doesn't kick.</title>
<updated>2012-01-12T05:14:43Z</updated>
<author>
<name>Rusty Russell</name>
<email>rusty@rustcorp.com.au</email>
</author>
<published>2012-01-12T05:14:43Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=e93300b1afc7cd4fe1e741ceaf06714d060e88b8'/>
<id>urn:sha1:e93300b1afc7cd4fe1e741ceaf06714d060e88b8</id>
<content type='text'>
Under the existing #ifdef DEBUG, check that they don't have more than
1/10 of a second between an add_buf() and a
virtqueue_notify()/virtqueue_kick_prepare() call.

We could get false positives on a really busy system, but good for
development.

Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
</content>
</entry>
<entry>
<title>virtio: expose added descriptors immediately.</title>
<updated>2012-01-12T05:14:43Z</updated>
<author>
<name>Rusty Russell</name>
<email>rusty@rustcorp.com.au</email>
</author>
<published>2012-01-12T05:14:43Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=ee7cd8981e15bcb365fc762afe3fc47b8242f630'/>
<id>urn:sha1:ee7cd8981e15bcb365fc762afe3fc47b8242f630</id>
<content type='text'>
A virtio driver does virtqueue_add_buf() multiple times before finally
calling virtqueue_kick(); previously we only exposed the added buffers
in the virtqueue_kick() call.  This means we don't need a memory
barrier in virtqueue_add_buf(), but it reduces concurrency as the
device (ie. host) can't see the buffers until the kick.

In the unusual (but now possible) case where a driver does add_buf()
and get_buf() without doing a kick, we do need to insert one before
our counter wraps.  Otherwise we could wrap num_added, and later on
not realize that we have passed the marker where we should have
kicked.

Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
</content>
</entry>
<entry>
<title>virtio: avoid modulus operation.</title>
<updated>2012-01-12T05:14:43Z</updated>
<author>
<name>Rusty Russell</name>
<email>rusty@rustcorp.com.au</email>
</author>
<published>2012-01-12T05:14:43Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=3b720b8c865098c49c1570b6b5c7832bcfa6e6c2'/>
<id>urn:sha1:3b720b8c865098c49c1570b6b5c7832bcfa6e6c2</id>
<content type='text'>
Since we know vq-&gt;vring.num is a power of 2, modulus is lazy (it's asserted
in vring_new_virtqueue()).

Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
</content>
</entry>
</feed>
