Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 123979
b: refs/heads/master
c: 1b4aa2f
h: refs/heads/master
i:
  123977: 7be4378
  123975: 48b3509
v: v3
  • Loading branch information
Hollis Blanchard authored and Rusty Russell committed Dec 29, 2008
1 parent a772a20 commit fa28b5b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 87c7d57c17ade5024d95b6ca0da249da49b0672a
refs/heads/master: 1b4aa2faeca1b9922033daf2475b6fc13b0ffea6
13 changes: 11 additions & 2 deletions trunk/drivers/virtio/virtio_balloon.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ static struct virtio_device_id id_table[] = {
{ 0 },
};

static u32 page_to_balloon_pfn(struct page *page)
{
unsigned long pfn = page_to_pfn(page);

BUILD_BUG_ON(PAGE_SHIFT < VIRTIO_BALLOON_PFN_SHIFT);
/* 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;
Expand Down Expand Up @@ -99,7 +108,7 @@ static void fill_balloon(struct virtio_balloon *vb, size_t num)
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);
Expand Down Expand Up @@ -132,7 +141,7 @@ static void leak_balloon(struct virtio_balloon *vb, size_t num)
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--;
}

Expand Down
3 changes: 3 additions & 0 deletions trunk/include/linux/virtio_balloon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down

0 comments on commit fa28b5b

Please sign in to comment.