From: "Philip P. Moltmann" <moltmann@vmware.com>
To: gregkh@linuxfoundation.org
Cc: "Philip P. Moltmann" <moltmann@vmware.com>,
dmitry.torokhov@gmail.com, linux-kernel@vger.kernel.org,
xdeguillard@vmware.com, akpm@linux-foundation.org,
pv-drivers@vmware.com
Subject: [PATCH v5 7/7] VMware balloon: Enable notification via VMCI
Date: Thu, 6 Aug 2015 15:18:04 -0700 [thread overview]
Message-ID: <1438899484-2426-8-git-send-email-moltmann@vmware.com> (raw)
In-Reply-To: <1438899484-2426-1-git-send-email-moltmann@vmware.com>
In-Reply-To: <20150806210755.GA18346@kroah.com>
Get notified immediately when a balloon target is set, instead of waiting for
up to one second.
The up-to 1 second gap could be long enough to cause swapping inside of the
VM that receives the VM.
Acked-by: Andy King <acking@vmware.com>
Signed-off-by: Xavier Deguillard <xdeguillard@vmware.com>
Tested-by: Siva Sankar Reddy B <sankars@vmware.com>
---
drivers/misc/Kconfig | 2 +-
drivers/misc/vmw_balloon.c | 105 +++++++++++++++++++++++++++++++++++++++++----
2 files changed, 97 insertions(+), 10 deletions(-)
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index ccccc29..22892c7 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -414,7 +414,7 @@ config TI_DAC7512
config VMWARE_BALLOON
tristate "VMware Balloon Driver"
- depends on X86 && HYPERVISOR_GUEST
+ depends on VMWARE_VMCI && X86 && HYPERVISOR_GUEST
help
This is VMware physical memory management driver which acts
like a "balloon" that can be inflated to reclaim physical pages
diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
index 28fe9e5..8930087 100644
--- a/drivers/misc/vmw_balloon.c
+++ b/drivers/misc/vmw_balloon.c
@@ -1,7 +1,7 @@
/*
* VMware Balloon driver.
*
- * Copyright (C) 2000-2013, VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2000-2014, VMware, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -43,11 +43,13 @@
#include <linux/workqueue.h>
#include <linux/debugfs.h>
#include <linux/seq_file.h>
+#include <linux/vmw_vmci_defs.h>
+#include <linux/vmw_vmci_api.h>
#include <asm/hypervisor.h>
MODULE_AUTHOR("VMware, Inc.");
MODULE_DESCRIPTION("VMware Memory Control (Balloon) Driver");
-MODULE_VERSION("1.4.1.0-k");
+MODULE_VERSION("1.5.0.0-k");
MODULE_ALIAS("dmi:*:svnVMware*:*");
MODULE_ALIAS("vmware_vmmemctl");
MODULE_LICENSE("GPL");
@@ -101,14 +103,16 @@ enum vmwballoon_capabilities {
/*
* Bit 0 is reserved and not associated to any capability.
*/
- VMW_BALLOON_BASIC_CMDS = (1 << 1),
- VMW_BALLOON_BATCHED_CMDS = (1 << 2),
- VMW_BALLOON_BATCHED_2M_CMDS = (1 << 3),
+ VMW_BALLOON_BASIC_CMDS = (1 << 1),
+ VMW_BALLOON_BATCHED_CMDS = (1 << 2),
+ VMW_BALLOON_BATCHED_2M_CMDS = (1 << 3),
+ VMW_BALLOON_SIGNALLED_WAKEUP_CMD = (1 << 4),
};
#define VMW_BALLOON_CAPABILITIES (VMW_BALLOON_BASIC_CMDS \
| VMW_BALLOON_BATCHED_CMDS \
- | VMW_BALLOON_BATCHED_2M_CMDS)
+ | VMW_BALLOON_BATCHED_2M_CMDS \
+ | VMW_BALLOON_SIGNALLED_WAKEUP_CMD)
#define VMW_BALLOON_2M_SHIFT (9)
#define VMW_BALLOON_NUM_PAGE_SIZES (2)
@@ -123,7 +127,9 @@ enum vmwballoon_capabilities {
* VMW_BALLOON_BATCHED_CMDS:
* BATCHED_LOCK and BATCHED_UNLOCK commands.
* VMW BALLOON_BATCHED_2M_CMDS:
- * BATCHED_2M_LOCK and BATCHED_2M_UNLOCK commands.
+ * BATCHED_2M_LOCK and BATCHED_2M_UNLOCK commands,
+ * VMW VMW_BALLOON_SIGNALLED_WAKEUP_CMD:
+ * VMW_BALLOON_CMD_VMCI_DOORBELL_SET command.
*/
#define VMW_BALLOON_CMD_START 0
#define VMW_BALLOON_CMD_GET_TARGET 1
@@ -134,6 +140,7 @@ enum vmwballoon_capabilities {
#define VMW_BALLOON_CMD_BATCHED_UNLOCK 7
#define VMW_BALLOON_CMD_BATCHED_2M_LOCK 8
#define VMW_BALLOON_CMD_BATCHED_2M_UNLOCK 9
+#define VMW_BALLOON_CMD_VMCI_DOORBELL_SET 10
/* error codes */
@@ -214,6 +221,7 @@ static void vmballoon_batch_set_pa(struct vmballoon_batch_page *batch, int idx,
#ifdef CONFIG_DEBUG_FS
struct vmballoon_stats {
unsigned int timer;
+ unsigned int doorbell;
/* allocation statistics */
unsigned int alloc[VMW_BALLOON_NUM_PAGE_SIZES];
@@ -235,6 +243,8 @@ struct vmballoon_stats {
unsigned int start_fail;
unsigned int guest_type;
unsigned int guest_type_fail;
+ unsigned int doorbell_set;
+ unsigned int doorbell_unset;
};
#define STATS_INC(stat) (stat)++
@@ -299,6 +309,8 @@ struct vmballoon {
struct sysinfo sysinfo;
struct delayed_work dwork;
+
+ struct vmci_handle vmci_doorbell;
};
static struct vmballoon balloon;
@@ -993,12 +1005,75 @@ static bool vmballoon_init_batching(struct vmballoon *b)
}
/*
+ * Receive notification and resize balloon
+ */
+static void vmballoon_doorbell(void *client_data)
+{
+ struct vmballoon *b = client_data;
+
+ STATS_INC(b->stats.doorbell);
+
+ mod_delayed_work(system_freezable_wq, &b->dwork, 0);
+}
+
+/*
+ * Clean up vmci doorbell
+ */
+static void vmballoon_vmci_cleanup(struct vmballoon *b)
+{
+ int error;
+
+ VMWARE_BALLOON_CMD(VMCI_DOORBELL_SET, VMCI_INVALID_ID,
+ VMCI_INVALID_ID, error);
+ STATS_INC(b->stats.doorbell_unset);
+
+ if (!vmci_handle_is_invalid(b->vmci_doorbell)) {
+ vmci_doorbell_destroy(b->vmci_doorbell);
+ b->vmci_doorbell = VMCI_INVALID_HANDLE;
+ }
+}
+
+/*
+ * Initialize vmci doorbell, to get notified as soon as balloon changes
+ */
+static int vmballoon_vmci_init(struct vmballoon *b)
+{
+ int error = 0;
+
+ if ((b->capabilities & VMW_BALLOON_SIGNALLED_WAKEUP_CMD) != 0) {
+ error = vmci_doorbell_create(&b->vmci_doorbell,
+ VMCI_FLAG_DELAYED_CB,
+ VMCI_PRIVILEGE_FLAG_RESTRICTED,
+ vmballoon_doorbell, b);
+
+ if (error == VMCI_SUCCESS) {
+ VMWARE_BALLOON_CMD(VMCI_DOORBELL_SET,
+ b->vmci_doorbell.context,
+ b->vmci_doorbell.resource, error);
+ STATS_INC(b->stats.doorbell_set);
+ }
+ }
+
+ if (error != 0) {
+ vmballoon_vmci_cleanup(b);
+
+ return -EIO;
+ }
+
+ return 0;
+}
+
+/*
* Perform standard reset sequence by popping the balloon (in case it
* is not empty) and then restarting protocol. This operation normally
* happens when host responds with VMW_BALLOON_ERROR_RESET to a command.
*/
static void vmballoon_reset(struct vmballoon *b)
{
+ int error;
+
+ vmballoon_vmci_cleanup(b);
+
/* free all pages, skipping monitor unlock */
vmballoon_pop(b);
@@ -1024,6 +1099,11 @@ static void vmballoon_reset(struct vmballoon *b)
}
b->reset_required = false;
+
+ error = vmballoon_vmci_init(b);
+ if (error)
+ pr_err("failed to initialize vmci doorbell\n");
+
if (!vmballoon_send_guest_id(b))
pr_err("failed to send guest ID to the host\n");
}
@@ -1097,6 +1177,7 @@ static int vmballoon_debug_show(struct seq_file *f, void *offset)
seq_printf(f,
"\n"
"timer: %8u\n"
+ "doorbell: %8u\n"
"start: %8u (%4u failed)\n"
"guestType: %8u (%4u failed)\n"
"2m-lock: %8u (%4u failed)\n"
@@ -1112,8 +1193,11 @@ static int vmballoon_debug_show(struct seq_file *f, void *offset)
"err2mAlloc: %8u\n"
"errAlloc: %8u\n"
"err2mFree: %8u\n"
- "errFree: %8u\n",
+ "errFree: %8u\n"
+ "doorbellSet: %8u\n"
+ "doorbellUnset: %8u\n",
stats->timer,
+ stats->doorbell,
stats->start, stats->start_fail,
stats->guest_type, stats->guest_type_fail,
stats->lock[true], stats->lock_fail[true],
@@ -1127,7 +1211,8 @@ static int vmballoon_debug_show(struct seq_file *f, void *offset)
stats->free[true],
stats->free[false],
stats->refused_alloc[true], stats->refused_alloc[false],
- stats->refused_free[true], stats->refused_free[false]);
+ stats->refused_free[true], stats->refused_free[false],
+ stats->doorbell_set, stats->doorbell_unset);
return 0;
}
@@ -1204,6 +1289,7 @@ static int __init vmballoon_init(void)
if (error)
return error;
+ balloon.vmci_doorbell = VMCI_INVALID_HANDLE;
balloon.batch_page = NULL;
balloon.page = NULL;
balloon.reset_required = true;
@@ -1216,6 +1302,7 @@ module_init(vmballoon_init);
static void __exit vmballoon_exit(void)
{
+ vmballoon_vmci_cleanup(&balloon);
cancel_delayed_work_sync(&balloon.dwork);
vmballoon_debugfs_exit(&balloon);
--
2.4.3
next prev parent reply other threads:[~2015-08-06 22:21 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-14 17:29 [PATCH 0/9] VMware balloon: Large page ballooning and VMCI support Philip P. Moltmann
2015-04-14 17:29 ` [PATCH 1/9] VMware balloon: partially inline vmballoon_reserve_page Philip P. Moltmann
2015-04-14 17:29 ` [PATCH 2/9] VMware balloon: Add support for balloon capabilities Philip P. Moltmann
2015-04-14 17:29 ` [PATCH 3/9] VMware balloon: add batching to the vmw_balloon Philip P. Moltmann
2015-04-14 17:29 ` [PATCH 4/9] VMware balloon: Update balloon target on each lock/unlock Philip P. Moltmann
2015-04-14 17:29 ` [PATCH 5/9] VMware balloon: Show capabilities of balloon and resulting capabilities in the debug-fs node Philip P. Moltmann
2015-04-14 17:29 ` [PATCH 5/9] VMware balloon: Show capabilities or " Philip P. Moltmann
2015-04-14 17:29 ` [PATCH 6/9] VMware balloon: Do not limit the amount of frees and allocations in non-sleep mode Philip P. Moltmann
2015-04-16 20:55 ` Dmitry Torokhov
2015-06-11 20:10 ` Philip Moltmann
2015-06-12 11:20 ` dmitry.torokhov
2015-06-12 15:06 ` Philip Moltmann
2015-06-12 15:31 ` dmitry.torokhov
2015-06-12 15:40 ` Philip Moltmann
2015-06-12 16:15 ` dmitry.torokhov
2015-06-12 18:43 ` [PATCH v3 0/9] Third revision of the performance improvment patch to the VMWare balloon driver Philip P. Moltmann
2015-06-12 18:43 ` [PATCH v3 1/9] VMware balloon: partially inline vmballoon_reserve_page Philip P. Moltmann
2015-06-12 18:43 ` [PATCH v3 2/9] VMware balloon: Add support for balloon capabilities Philip P. Moltmann
2015-06-12 18:43 ` [PATCH v3 3/9] VMware balloon: add batching to the vmw_balloon Philip P. Moltmann
2015-08-05 20:19 ` Greg KH
2015-08-05 22:36 ` [PATCH v4 " Philip P. Moltmann
2015-08-05 22:44 ` Greg KH
2015-08-05 22:47 ` Philip Moltmann
2015-08-05 23:26 ` gregkh
2015-08-06 20:33 ` [PATCH v4 0/9] Fourth revision of the performance improvement patch to the VMware balloon driver Philip P. Moltmann
2015-08-06 20:33 ` [PATCH v4 1/9] VMware balloon: partially inline vmballoon_reserve_page Philip P. Moltmann
2015-08-06 21:07 ` Greg KH
2015-08-06 22:17 ` [PATCH v5 0/7] Fifth revision of the performance improvement patch to the VMware balloon driver Philip P. Moltmann
2015-08-14 23:27 ` Philip Moltmann
2015-08-06 22:17 ` [PATCH v5 1/7] VMware balloon: add batching to the vmw_balloon Philip P. Moltmann
2015-08-06 22:17 ` [PATCH v5 2/7] VMware balloon: Update balloon target on each lock/unlock Philip P. Moltmann
2015-08-06 22:18 ` [PATCH v5 3/7] VMware balloon: Show capabilities of balloon and resulting capabilities in the debug-fs node Philip P. Moltmann
2015-08-06 22:18 ` [PATCH v5 4/7] VMware balloon: Do not limit the amount of frees and allocations in non-sleep mode Philip P. Moltmann
2015-08-06 22:18 ` [PATCH v5 5/7] VMware balloon: Support 2m page ballooning Philip P. Moltmann
2015-08-21 14:01 ` Kamalneet Singh
2015-08-06 22:18 ` [PATCH v5 6/7] VMware balloon: Treat init like reset Philip P. Moltmann
2015-08-06 22:18 ` Philip P. Moltmann [this message]
2015-08-06 20:33 ` [PATCH v4 2/9] VMware balloon: Add support for balloon capabilities Philip P. Moltmann
2015-08-06 20:33 ` [PATCH v4 3/9] VMware balloon: add batching to the vmw_balloon Philip P. Moltmann
2015-08-06 20:33 ` [PATCH v4 4/9] VMware balloon: Update balloon target on each lock/unlock Philip P. Moltmann
2015-08-06 20:33 ` [PATCH v4 5/9] VMware balloon: Show capabilities of balloon and resulting capabilities in the debug-fs node Philip P. Moltmann
2015-08-06 20:33 ` [PATCH v4 6/9] VMware balloon: Do not limit the amount of frees and allocations in non-sleep mode Philip P. Moltmann
2015-08-06 20:33 ` [PATCH v4 7/9] VMware balloon: Support 2m page ballooning Philip P. Moltmann
2015-08-06 20:33 ` [PATCH v4 8/9] VMware balloon: Treat init like reset Philip P. Moltmann
2015-08-06 20:33 ` [PATCH v4 9/9] VMware balloon: Enable notification via VMCI Philip P. Moltmann
2015-06-12 18:43 ` [PATCH v3 4/9] VMware balloon: Update balloon target on each lock/unlock Philip P. Moltmann
2015-06-12 18:43 ` [PATCH v3 5/9] VMware balloon: Show capabilities of balloon and resulting capabilities in the debug-fs node Philip P. Moltmann
2015-08-05 20:14 ` Greg KH
2015-08-05 20:22 ` Philip Moltmann
2015-08-05 20:33 ` dmitry.torokhov
2015-08-05 20:42 ` John Savanyo
2015-08-05 20:50 ` gregkh
2015-08-05 21:11 ` John Savanyo
2015-08-05 20:40 ` gregkh
2015-06-12 18:43 ` [PATCH v3 6/9] VMware balloon: Do not limit the amount of frees and allocations in non-sleep mode Philip P. Moltmann
2015-06-12 18:43 ` [PATCH v3 7/9] VMware balloon: Support 2m page ballooning Philip P. Moltmann
2015-06-12 18:43 ` [PATCH v3 8/9] VMware balloon: Treat init like reset Philip P. Moltmann
2015-06-12 18:43 ` [PATCH v3 9/9] VMware balloon: Enable notification via VMCI Philip P. Moltmann
2015-04-14 17:29 ` [PATCH 7/9] VMware balloon: Support 2m page ballooning Philip P. Moltmann
2015-04-14 17:29 ` [PATCH 8/9] VMware balloon: Treat init like reset Philip P. Moltmann
2015-04-14 17:29 ` [PATCH 9/9] VMware balloon: Enable notification via VMCI Philip P. Moltmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1438899484-2426-8-git-send-email-moltmann@vmware.com \
--to=moltmann@vmware.com \
--cc=akpm@linux-foundation.org \
--cc=dmitry.torokhov@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pv-drivers@vmware.com \
--cc=xdeguillard@vmware.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.