public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virtio-balloon: do not attempt to release more than available pages
@ 2008-03-05 16:28 Marcelo Tosatti
  2008-03-05 16:59 ` Avi Kivity
  2008-03-05 22:39 ` Rusty Russell
  0 siblings, 2 replies; 14+ messages in thread
From: Marcelo Tosatti @ 2008-03-05 16:28 UTC (permalink / raw)
  To: Rusty Russell; +Cc: kvm-devel


Handle the case where the balloon target is larger than total ram size.

BUG: unable to handle kernel paging request at 0000000000100100
IP: [<ffffffff881970f9>] :virtio_balloon:leak__balloon+0x2e/0xbe

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: virtio/virtio_balloon.c
===================================================================
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -122,10 +122,21 @@ static void release_pages_by_pfn(const u
 	}
 }
 
+static void update_target_size(struct virtio_balloon *vb)
+{
+	__le32 num_pages = cpu_to_le32(vb->num_pages);
+
+	vb->vdev->config->set(vb->vdev,
+			      offsetof(struct virtio_balloon_config, num_pages),
+			      &num_pages, sizeof(num_pages));
+}
+
+
 static void leak_balloon(struct virtio_balloon *vb, size_t num)
 {
 	struct page *page;
 
+	num = min_t(unsigned int, vb->num_pages, num);
 	/* We can only do one array worth at a time. */
 	num = min(num, ARRAY_SIZE(vb->pfns));
 
@@ -136,6 +147,12 @@ static void leak_balloon(struct virtio_b
 		vb->num_pages--;
 	}
 
+	/* Have nothing to release? update target accordingly. */
+	if (vb->num_pfns == 0) {
+		update_target_size(vb);
+		return;
+	}
+
 	if (vb->tell_host_first) {
 		tell_host(vb, vb->deflate_vq);
 		release_pages_by_pfn(vb->pfns, vb->num_pfns);

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2008-03-11 11:54 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-05 16:28 [PATCH] virtio-balloon: do not attempt to release more than available pages Marcelo Tosatti
2008-03-05 16:59 ` Avi Kivity
2008-03-05 18:12   ` Marcelo Tosatti
2008-03-05 18:13     ` Avi Kivity
2008-03-05 18:43     ` Anthony Liguori
2008-03-05 19:39       ` Marcelo Tosatti
2008-03-05 19:42         ` Anthony Liguori
2008-03-06  7:06           ` Avi Kivity
2008-03-05 18:42   ` Anthony Liguori
2008-03-05 22:39 ` Rusty Russell
2008-03-08 19:06   ` Marcelo Tosatti
2008-03-11  0:26     ` Rusty Russell
2008-03-11  0:52       ` Anthony Liguori
2008-03-11 11:54         ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox