aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/vmware_balloon.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@vmware.com>2010-06-04 17:14:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-06-04 18:21:44 -0400
commit55adaa495edc429be84399f83df80dfb7f36598b (patch)
treee7cf5e2ac61ebfa799484c11e148150c51ec0f60 /drivers/misc/vmware_balloon.c
parentf76f5d71048e116f76d2eb02226b01d50890e2f4 (diff)
vmware balloon: clamp number of collected non-balloonable pages
Limit number of accumulated non-balloonable pages during inflation cycle, otherwise there is a chance we will be spinning and growing the list forever. This happens during torture tests when balloon target changes while we are in the middle of inflation cycle and monitor starts refusing to lock pages (since they are not needed anymore). Signed-off-by: Dmitry Torokhov <dtor@vmware.com> Acked-by: Bhavesh Davda <bhavesh@vmware.com> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/misc/vmware_balloon.c')
-rw-r--r--drivers/misc/vmware_balloon.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/drivers/misc/vmware_balloon.c b/drivers/misc/vmware_balloon.c
index db9cd0240c6..2a1e804a71a 100644
--- a/drivers/misc/vmware_balloon.c
+++ b/drivers/misc/vmware_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.0-K"); 48MODULE_VERSION("1.2.1.1-k");
49MODULE_ALIAS("dmi:*:svnVMware*:*"); 49MODULE_ALIAS("dmi:*:svnVMware*:*");
50MODULE_ALIAS("vmware_vmmemctl"); 50MODULE_ALIAS("vmware_vmmemctl");
51MODULE_LICENSE("GPL"); 51MODULE_LICENSE("GPL");
@@ -101,6 +101,8 @@ MODULE_LICENSE("GPL");
101/* Maximum number of page allocations without yielding processor */ 101/* Maximum number of page allocations without yielding processor */
102#define VMW_BALLOON_YIELD_THRESHOLD 1024 102#define VMW_BALLOON_YIELD_THRESHOLD 1024
103 103
104/* Maximum number of refused pages we accumulate during inflation cycle */
105#define VMW_BALLOON_MAX_REFUSED 16
104 106
105/* 107/*
106 * Hypervisor communication port definitions. 108 * Hypervisor communication port definitions.
@@ -183,6 +185,7 @@ struct vmballoon {
183 185
184 /* transient list of non-balloonable pages */ 186 /* transient list of non-balloonable pages */
185 struct list_head refused_pages; 187 struct list_head refused_pages;
188 unsigned int n_refused_pages;
186 189
187 /* balloon size in pages */ 190 /* balloon size in pages */
188 unsigned int size; 191 unsigned int size;
@@ -428,14 +431,21 @@ static int vmballoon_reserve_page(struct vmballoon *b, bool can_sleep)
428 /* inform monitor */ 431 /* inform monitor */
429 locked = vmballoon_send_lock_page(b, page_to_pfn(page)); 432 locked = vmballoon_send_lock_page(b, page_to_pfn(page));
430 if (!locked) { 433 if (!locked) {
434 STATS_INC(b->stats.refused_alloc);
435
431 if (b->reset_required) { 436 if (b->reset_required) {
432 __free_page(page); 437 __free_page(page);
433 return -EIO; 438 return -EIO;
434 } 439 }
435 440
436 /* place on list of non-balloonable pages, retry allocation */ 441 /*
442 * Place page on the list of non-balloonable pages
443 * and retry allocation, unless we already accumulated
444 * too many of them, in which case take a breather.
445 */
437 list_add(&page->lru, &b->refused_pages); 446 list_add(&page->lru, &b->refused_pages);
438 STATS_INC(b->stats.refused_alloc); 447 if (++b->n_refused_pages >= VMW_BALLOON_MAX_REFUSED)
448 return -EIO;
439 } 449 }
440 } while (!locked); 450 } while (!locked);
441 451
@@ -483,6 +493,8 @@ static void vmballoon_release_refused_pages(struct vmballoon *b)
483 __free_page(page); 493 __free_page(page);
484 STATS_INC(b->stats.refused_free); 494 STATS_INC(b->stats.refused_free);
485 } 495 }
496
497 b->n_refused_pages = 0;
486} 498}
487 499
488/* 500/*