aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@vmware.com>2011-01-12 20:01:07 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2011-01-13 11:03:22 -0500
commitd27a0c06ec31aadc3582f50cd7b88855922e95ae (patch)
tree973b581f14c05e5de869468d5771ffcdba4fe063
parent17fecb5582962c2ca5627a51ec9ab0979fb673ef (diff)
VMware balloon: stop locking pages when hypervisor tells us enough
When hypervisor decides to decrease target balloon size while the balloon driver tries to lock pages hypervisor may respond with VMW_BALLOON_PPN_NOTNEEDED. Use this data and immediately stop reserving pages and wait for the next update cycle to fetch new target instead of continuing trying to lock pages until size of refused list grows above VMW_BALLOON_MAX_REFUSED (16) pages. As a result the driver stops bothering the hypervisor with its attempts to lock more pages that are not needed anymore. Most likely next order from hypervisor will be to reduce ballon size anyway. It is a small optimization. Signed-off-by: Dmitry Torokhov <dtor@vmware.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/misc/vmw_balloon.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
index 2a1e804a71aa..4d2ea8e80140 100644
--- a/drivers/misc/vmw_balloon.c
+++ b/drivers/misc/vmw_balloon.c
@@ -45,7 +45,7 @@
45 45
46MODULE_AUTHOR("VMware, Inc."); 46MODULE_AUTHOR("VMware, Inc.");
47MODULE_DESCRIPTION("VMware Memory Control (Balloon) Driver"); 47MODULE_DESCRIPTION("VMware Memory Control (Balloon) Driver");
48MODULE_VERSION("1.2.1.1-k"); 48MODULE_VERSION("1.2.1.2-k");
49MODULE_ALIAS("dmi:*:svnVMware*:*"); 49MODULE_ALIAS("dmi:*:svnVMware*:*");
50MODULE_ALIAS("vmware_vmmemctl"); 50MODULE_ALIAS("vmware_vmmemctl");
51MODULE_LICENSE("GPL"); 51MODULE_LICENSE("GPL");
@@ -315,7 +315,8 @@ static bool vmballoon_send_get_target(struct vmballoon *b, u32 *new_target)
315 * fear that guest will need it. Host may reject some pages, we need to 315 * fear that guest will need it. Host may reject some pages, we need to
316 * check the return value and maybe submit a different page. 316 * check the return value and maybe submit a different page.
317 */ 317 */
318static bool vmballoon_send_lock_page(struct vmballoon *b, unsigned long pfn) 318static bool vmballoon_send_lock_page(struct vmballoon *b, unsigned long pfn,
319 unsigned int *hv_status)
319{ 320{
320 unsigned long status, dummy; 321 unsigned long status, dummy;
321 u32 pfn32; 322 u32 pfn32;
@@ -326,7 +327,7 @@ static bool vmballoon_send_lock_page(struct vmballoon *b, unsigned long pfn)
326 327
327 STATS_INC(b->stats.lock); 328 STATS_INC(b->stats.lock);
328 329
329 status = VMWARE_BALLOON_CMD(LOCK, pfn, dummy); 330 *hv_status = status = VMWARE_BALLOON_CMD(LOCK, pfn, dummy);
330 if (vmballoon_check_status(b, status)) 331 if (vmballoon_check_status(b, status))
331 return true; 332 return true;
332 333
@@ -410,6 +411,7 @@ static int vmballoon_reserve_page(struct vmballoon *b, bool can_sleep)
410{ 411{
411 struct page *page; 412 struct page *page;
412 gfp_t flags; 413 gfp_t flags;
414 unsigned int hv_status;
413 bool locked = false; 415 bool locked = false;
414 416
415 do { 417 do {
@@ -429,11 +431,12 @@ static int vmballoon_reserve_page(struct vmballoon *b, bool can_sleep)
429 } 431 }
430 432
431 /* inform monitor */ 433 /* inform monitor */
432 locked = vmballoon_send_lock_page(b, page_to_pfn(page)); 434 locked = vmballoon_send_lock_page(b, page_to_pfn(page), &hv_status);
433 if (!locked) { 435 if (!locked) {
434 STATS_INC(b->stats.refused_alloc); 436 STATS_INC(b->stats.refused_alloc);
435 437
436 if (b->reset_required) { 438 if (hv_status == VMW_BALLOON_ERROR_RESET ||
439 hv_status == VMW_BALLOON_ERROR_PPN_NOTNEEDED) {
437 __free_page(page); 440 __free_page(page);
438 return -EIO; 441 return -EIO;
439 } 442 }