Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 355068
b: refs/heads/master
c: 1c7db96
h: refs/heads/master
v: v3
  • Loading branch information
K. Y. Srinivasan authored and Greg Kroah-Hartman committed Feb 8, 2013
1 parent 43525c5 commit 45d7358
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 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: e500d158fb07794724f12655f2eb5702fec613c4
refs/heads/master: 1c7db96f6feac95d90200ddd0f9b5d94614ea759
35 changes: 34 additions & 1 deletion trunk/drivers/hv/hv_balloon.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,34 @@ static void process_info(struct hv_dynmem_device *dm, struct dm_info_msg *msg)
}
}

unsigned long compute_balloon_floor(void)
{
unsigned long min_pages;
#define MB2PAGES(mb) ((mb) << (20 - PAGE_SHIFT))
/* Simple continuous piecewiese linear function:
* max MiB -> min MiB gradient
* 0 0
* 16 16
* 32 24
* 128 72 (1/2)
* 512 168 (1/4)
* 2048 360 (1/8)
* 8192 552 (1/32)
* 32768 1320
* 131072 4392
*/
if (totalram_pages < MB2PAGES(128))
min_pages = MB2PAGES(8) + (totalram_pages >> 1);
else if (totalram_pages < MB2PAGES(512))
min_pages = MB2PAGES(40) + (totalram_pages >> 2);
else if (totalram_pages < MB2PAGES(2048))
min_pages = MB2PAGES(104) + (totalram_pages >> 3);
else
min_pages = MB2PAGES(296) + (totalram_pages >> 5);
#undef MB2PAGES
return min_pages;
}

/*
* Post our status as it relates memory pressure to the
* host. Host expects the guests to post this status
Expand Down Expand Up @@ -552,9 +580,14 @@ static void post_status(struct hv_dynmem_device *dm)
* The host expects the guest to report free memory.
* Further, the host expects the pressure information to
* include the ballooned out pages.
* For a given amount of memory that we are managing, we
* need to compute a floor below which we should not balloon.
* Compute this and add it to the pressure report.
*/
status.num_avail = val.freeram;
status.num_committed = vm_memory_committed() + dm->num_pages_ballooned;
status.num_committed = vm_memory_committed() +
dm->num_pages_ballooned +
compute_balloon_floor();

vmbus_sendpacket(dm->dev->channel, &status,
sizeof(struct dm_status),
Expand Down

0 comments on commit 45d7358

Please sign in to comment.