From: Hollis Blanchard <hollisb@us.ibm.com>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: aliguori@us.ibm.com, markmc@redhat.com, xiantao.zhang@intel.com,
kvm@vger.kernel.org, kvm-ppc@vger.kernel.org
Subject: Re: [PATCH] [v2] linux: virtio: Standardize virtio's concept of "page size"
Date: Thu, 13 Nov 2008 15:48:33 -0600 [thread overview]
Message-ID: <1226612913.5339.42.camel@localhost.localdomain> (raw)
In-Reply-To: <200811130844.57749.rusty@rustcorp.com.au>
On Thu, 2008-11-13 at 08:44 +1030, Rusty Russell wrote:
>
> Note that I still don't have a balloon patch: want to send me one?
linux: virtio-balloon: avoid implicit use of Linux page size in balloon interface
Make the balloon interface always use 4K pages, and convert Linux pfns if
necessary. This patch assumes that Linux's PAGE_SHIFT will never be less than
12.
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
---
Only build-tested.
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -56,6 +56,14 @@ static struct virtio_device_id id_table[
{ 0 },
};
+static u32 page_to_balloon_pfn(struct page *page)
+{
+ unsigned long pfn = page_to_pfn(page);
+
+ /* Convert pfn from Linux page size to balloon page size. */
+ return pfn >> (PAGE_SHIFT - VIRTIO_BALLOON_PFN_SHIFT);
+}
+
static void balloon_ack(struct virtqueue *vq)
{
struct virtio_balloon *vb;
@@ -99,7 +107,7 @@ static void fill_balloon(struct virtio_b
msleep(200);
break;
}
- vb->pfns[vb->num_pfns] = page_to_pfn(page);
+ vb->pfns[vb->num_pfns] = page_to_balloon_pfn(page);
totalram_pages--;
vb->num_pages++;
list_add(&page->lru, &vb->pages);
@@ -132,7 +140,7 @@ static void leak_balloon(struct virtio_b
for (vb->num_pfns = 0; vb->num_pfns < num; vb->num_pfns++) {
page = list_first_entry(&vb->pages, struct page, lru);
list_del(&page->lru);
- vb->pfns[vb->num_pfns] = page_to_pfn(page);
+ vb->pfns[vb->num_pfns] = page_to_balloon_pfn(page);
vb->num_pages--;
}
diff --git a/include/linux/virtio_balloon.h b/include/linux/virtio_balloon.h
--- a/include/linux/virtio_balloon.h
+++ b/include/linux/virtio_balloon.h
@@ -10,6 +10,9 @@
/* The feature bitmap for virtio balloon */
#define VIRTIO_BALLOON_F_MUST_TELL_HOST 0 /* Tell before reclaiming pages */
+/* Size of a PFN in the balloon interface. */
+#define VIRTIO_BALLOON_PFN_SHIFT 12
+
struct virtio_balloon_config
{
/* Number of pages host wants Guest to give up. */
--
Hollis Blanchard
IBM Linux Technology Center
next prev parent reply other threads:[~2008-11-13 21:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <fa3de103a4e7d70354e0.1226360229@localhost.localdomain>
[not found] ` <200811112347.27844.rusty@rustcorp.com.au>
2008-11-11 17:18 ` [PATCH] [v2] linux: virtio: Standardize virtio's concept of "page size" Hollis Blanchard
2008-11-11 17:21 ` Avi Kivity
2008-11-12 12:21 ` Rusty Russell
[not found] ` <200811122251.14159.rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
2008-11-12 16:16 ` Hollis Blanchard
2008-11-12 22:14 ` Rusty Russell
2008-11-13 21:48 ` Hollis Blanchard [this message]
[not found] ` <1226612913.5339.42.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2008-11-14 1:27 ` Rusty Russell
[not found] ` <200811130844.57749.rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
2008-11-13 21:49 ` Hollis Blanchard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1226612913.5339.42.camel@localhost.localdomain \
--to=hollisb@us.ibm.com \
--cc=aliguori@us.ibm.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=markmc@redhat.com \
--cc=rusty@rustcorp.com.au \
--cc=xiantao.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox