Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1202014
| From | "Philip P. Moltmann" <moltmann@vmware.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v4 1/9] VMware balloon: partially inline vmballoon_reserve_page. |
| Date | 2015-08-06 22:40 +0200 |
| Message-ID | <pUA7g-34H-35@gated-at.bofh.it> (permalink) |
| References | <pUA7g-34H-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Xavier Deguillard <xdeguillard@vmware.com>
This split the function in two: the allocation part is inlined into the
inflate function and the lock part is kept into his own function.
This change is needed in order to be able to allocate more than one page
before doing the hypervisor call.
Signed-off-by: Xavier Deguillard <xdeguillard@vmware.com>
Acked-by: Dmitry Torokhov <dtor@vmware.com>
Signed-off-by: Philip P. Moltmann <moltmann@vmware.com>
Acked-by: Andy King <acking@vmware.com>
---
drivers/misc/vmw_balloon.c | 98 ++++++++++++++++++++--------------------------
1 file changed, 42 insertions(+), 56 deletions(-)
diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
index 1916174..2799c46 100644
--- a/drivers/misc/vmw_balloon.c
+++ b/drivers/misc/vmw_balloon.c
@@ -46,7 +46,7 @@
MODULE_AUTHOR("VMware, Inc.");
MODULE_DESCRIPTION("VMware Memory Control (Balloon) Driver");
-MODULE_VERSION("1.2.1.3-k");
+MODULE_VERSION("1.2.2.0-k");
MODULE_ALIAS("dmi:*:svnVMware*:*");
MODULE_ALIAS("vmware_vmmemctl");
MODULE_LICENSE("GPL");
@@ -402,55 +402,37 @@ static void vmballoon_reset(struct vmballoon *b)
}
/*
- * Allocate (or reserve) a page for the balloon and notify the host. If host
- * refuses the page put it on "refuse" list and allocate another one until host
- * is satisfied. "Refused" pages are released at the end of inflation cycle
- * (when we allocate b->rate_alloc pages).
+ * Notify the host of a ballooned page. If host rejects the page put it on the
+ * refuse list, those refused page are then released at the end of the
+ * inflation cycle.
*/
-static int vmballoon_reserve_page(struct vmballoon *b, bool can_sleep)
+static int vmballoon_lock_page(struct vmballoon *b, struct page *page)
{
- struct page *page;
- gfp_t flags;
- unsigned int hv_status;
- int locked;
- flags = can_sleep ? VMW_PAGE_ALLOC_CANSLEEP : VMW_PAGE_ALLOC_NOSLEEP;
-
- do {
- if (!can_sleep)
- STATS_INC(b->stats.alloc);
- else
- STATS_INC(b->stats.sleep_alloc);
-
- page = alloc_page(flags);
- if (!page) {
- if (!can_sleep)
- STATS_INC(b->stats.alloc_fail);
- else
- STATS_INC(b->stats.sleep_alloc_fail);
- return -ENOMEM;
- }
+ int locked, hv_status;
- /* inform monitor */
- locked = vmballoon_send_lock_page(b, page_to_pfn(page), &hv_status);
- if (locked > 0) {
- STATS_INC(b->stats.refused_alloc);
+ locked = vmballoon_send_lock_page(b, page_to_pfn(page), &hv_status);
+ if (locked > 0) {
+ STATS_INC(b->stats.refused_alloc);
- if (hv_status == VMW_BALLOON_ERROR_RESET ||
- hv_status == VMW_BALLOON_ERROR_PPN_NOTNEEDED) {
- __free_page(page);
- return -EIO;
- }
+ if (hv_status == VMW_BALLOON_ERROR_RESET ||
+ hv_status == VMW_BALLOON_ERROR_PPN_NOTNEEDED) {
+ __free_page(page);
+ return -EIO;
+ }
- /*
- * Place page on the list of non-balloonable pages
- * and retry allocation, unless we already accumulated
- * too many of them, in which case take a breather.
- */
+ /*
+ * Place page on the list of non-balloonable pages
+ * and retry allocation, unless we already accumulated
+ * too many of them, in which case take a breather.
+ */
+ if (b->n_refused_pages < VMW_BALLOON_MAX_REFUSED) {
+ b->n_refused_pages++;
list_add(&page->lru, &b->refused_pages);
- if (++b->n_refused_pages >= VMW_BALLOON_MAX_REFUSED)
- return -EIO;
+ } else {
+ __free_page(page);
}
- } while (locked != 0);
+ return -EIO;
+ }
/* track allocated page */
list_add(&page->lru, &b->pages);
@@ -512,7 +494,7 @@ static void vmballoon_inflate(struct vmballoon *b)
unsigned int i;
unsigned int allocations = 0;
int error = 0;
- bool alloc_can_sleep = false;
+ gfp_t flags = VMW_PAGE_ALLOC_NOSLEEP;
pr_debug("%s - size: %d, target %d\n", __func__, b->size, b->target);
@@ -543,19 +525,16 @@ static void vmballoon_inflate(struct vmballoon *b)
__func__, goal, rate, b->rate_alloc);
for (i = 0; i < goal; i++) {
+ struct page *page;
- error = vmballoon_reserve_page(b, alloc_can_sleep);
- if (error) {
- if (error != -ENOMEM) {
- /*
- * Not a page allocation failure, stop this
- * cycle. Maybe we'll get new target from
- * the host soon.
- */
- break;
- }
+ if (flags == VMW_PAGE_ALLOC_NOSLEEP)
+ STATS_INC(b->stats.alloc);
+ else
+ STATS_INC(b->stats.sleep_alloc);
- if (alloc_can_sleep) {
+ page = alloc_page(flags);
+ if (!page) {
+ if (flags == VMW_PAGE_ALLOC_CANSLEEP) {
/*
* CANSLEEP page allocation failed, so guest
* is under severe memory pressure. Quickly
@@ -563,8 +542,10 @@ static void vmballoon_inflate(struct vmballoon *b)
*/
b->rate_alloc = max(b->rate_alloc / 2,
VMW_BALLOON_RATE_ALLOC_MIN);
+ STATS_INC(b->stats.sleep_alloc_fail);
break;
}
+ STATS_INC(b->stats.alloc_fail);
/*
* NOSLEEP page allocation failed, so the guest is
@@ -579,11 +560,16 @@ static void vmballoon_inflate(struct vmballoon *b)
if (i >= b->rate_alloc)
break;
- alloc_can_sleep = true;
+ flags = VMW_PAGE_ALLOC_CANSLEEP;
/* Lower rate for sleeping allocations. */
rate = b->rate_alloc;
+ continue;
}
+ error = vmballoon_lock_page(b, page);
+ if (error)
+ break;
+
if (++allocations > VMW_BALLOON_YIELD_THRESHOLD) {
cond_resched();
allocations = 0;
--
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [PATCH v3 3/9] VMware balloon: add batching to the vmw_balloon. Greg KH <gregkh@linuxfoundation.org> - 2015-08-05 22:20 +0200
[PATCH v4 3/9] VMware balloon: add batching to the vmw_balloon. "Philip P. Moltmann" <moltmann@vmware.com> - 2015-08-06 00:40 +0200
Re: [PATCH v4 3/9] VMware balloon: add batching to the vmw_balloon. Philip Moltmann <moltmann@vmware.com> - 2015-08-06 00:50 +0200
Re: [PATCH v4 3/9] VMware balloon: add batching to the vmw_balloon. "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org> - 2015-08-06 01:30 +0200
[PATCH v4 0/9] Fourth revision of the performance improvement patch to the VMware balloon driver "Philip P. Moltmann" <moltmann@vmware.com> - 2015-08-06 22:40 +0200
[PATCH v4 5/9] VMware balloon: Show capabilities of balloon and resulting capabilities in the debug-fs node. "Philip P. Moltmann" <moltmann@vmware.com> - 2015-08-06 22:40 +0200
[PATCH v4 6/9] VMware balloon: Do not limit the amount of frees and allocations in non-sleep mode. "Philip P. Moltmann" <moltmann@vmware.com> - 2015-08-06 22:40 +0200
[PATCH v4 8/9] VMware balloon: Treat init like reset "Philip P. Moltmann" <moltmann@vmware.com> - 2015-08-06 22:40 +0200
[PATCH v4 4/9] VMware balloon: Update balloon target on each lock/unlock. "Philip P. Moltmann" <moltmann@vmware.com> - 2015-08-06 22:40 +0200
[PATCH v4 1/9] VMware balloon: partially inline vmballoon_reserve_page. "Philip P. Moltmann" <moltmann@vmware.com> - 2015-08-06 22:40 +0200
Re: [PATCH v4 1/9] VMware balloon: partially inline vmballoon_reserve_page. Greg KH <gregkh@linuxfoundation.org> - 2015-08-06 23:10 +0200
[PATCH v5 0/7] Fifth revision of the performance improvement patch to the VMware balloon driver "Philip P. Moltmann" <moltmann@vmware.com> - 2015-08-07 00:30 +0200
[PATCH v5 4/7] VMware balloon: Do not limit the amount of frees and allocations in non-sleep mode. "Philip P. Moltmann" <moltmann@vmware.com> - 2015-08-07 00:30 +0200
[PATCH v5 2/7] VMware balloon: Update balloon target on each lock/unlock. "Philip P. Moltmann" <moltmann@vmware.com> - 2015-08-07 00:30 +0200
[PATCH v5 6/7] VMware balloon: Treat init like reset "Philip P. Moltmann" <moltmann@vmware.com> - 2015-08-07 00:30 +0200
[PATCH v5 5/7] VMware balloon: Support 2m page ballooning. "Philip P. Moltmann" <moltmann@vmware.com> - 2015-08-07 00:30 +0200
[PATCH v5 1/7] VMware balloon: add batching to the vmw_balloon. "Philip P. Moltmann" <moltmann@vmware.com> - 2015-08-07 00:30 +0200
[PATCH v5 7/7] VMware balloon: Enable notification via VMCI "Philip P. Moltmann" <moltmann@vmware.com> - 2015-08-07 00:30 +0200
Re: [PATCH v5 0/7] Fifth revision of the performance improvement patch to the VMware balloon driver Philip Moltmann <moltmann@vmware.com> - 2015-08-15 01:30 +0200
[PATCH v4 3/9] VMware balloon: add batching to the vmw_balloon. "Philip P. Moltmann" <moltmann@vmware.com> - 2015-08-06 22:40 +0200
[PATCH v4 2/9] VMware balloon: Add support for balloon capabilities. "Philip P. Moltmann" <moltmann@vmware.com> - 2015-08-06 22:40 +0200
[PATCH v4 7/9] VMware balloon: Support 2m page ballooning. "Philip P. Moltmann" <moltmann@vmware.com> - 2015-08-06 22:40 +0200
[PATCH v4 9/9] VMware balloon: Enable notification via VMCI "Philip P. Moltmann" <moltmann@vmware.com> - 2015-08-06 22:40 +0200
Re: [PATCH v4 3/9] VMware balloon: add batching to the vmw_balloon. Greg KH <gregkh@linuxfoundation.org> - 2015-08-06 00:50 +0200
csiph-web