* [PATCH 0/2] Drivers: hv: balloon
@ 2013-02-08 23:56 K. Y. Srinivasan
2013-02-08 23:57 ` [PATCH 1/2] Drivers: hv: balloon: Add a parameter to delay pressure reporting K. Y. Srinivasan
0 siblings, 1 reply; 3+ messages in thread
From: K. Y. Srinivasan @ 2013-02-08 23:56 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, olaf, apw, jasowang; +Cc: K. Y. Srinivasan
Make furher adjustments to memory pressure reporting and computation.
In the current code, we begin to report pressure soon after the balloon driver
loads and typically report a very low pressure until the system is fully
operational. To avoid having the host take memory balancing decisions on
data that does not fully reflect the memory pressure, delay reporting the
pressure. Additionally, implement a floor for ballooning based on the amount
of memory being managed.
K. Y. Srinivasan (2):
Drivers: hv: balloon: Add a parameter to delay pressure reporting
Drivers: hv: balloon: Prevent the host from ballooning the guest too
low
drivers/hv/hv_balloon.c | 48 ++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 45 insertions(+), 3 deletions(-)
--
1.7.4.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] Drivers: hv: balloon: Add a parameter to delay pressure reporting
2013-02-08 23:56 [PATCH 0/2] Drivers: hv: balloon K. Y. Srinivasan
@ 2013-02-08 23:57 ` K. Y. Srinivasan
2013-02-08 23:57 ` [PATCH 2/2] Drivers: hv: balloon: Prevent the host from ballooning the guest too low K. Y. Srinivasan
0 siblings, 1 reply; 3+ messages in thread
From: K. Y. Srinivasan @ 2013-02-08 23:57 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, olaf, apw, jasowang; +Cc: K. Y. Srinivasan
Delay reporting memory pressure by a specified amount of time.
This addresses the problem where the host may take memory balancing
decisions based on incorrect memory pressure data that will be posted
as soon as the balloon driver is loaded.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
---
drivers/hv/hv_balloon.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index 32a96f1..f8fc996 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -414,10 +414,17 @@ struct dm_info_msg {
static bool hot_add;
static bool do_hot_add;
+/*
+ * Delay reporting memory pressure by
+ * the specified number of seconds.
+ */
+static uint pressure_report_delay = 30;
module_param(hot_add, bool, (S_IRUGO | S_IWUSR));
MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
+module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
+MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
static atomic_t trans_id = ATOMIC_INIT(0);
static int dm_ring_size = (5 * PAGE_SIZE);
@@ -531,6 +538,10 @@ static void post_status(struct hv_dynmem_device *dm)
struct dm_status status;
struct sysinfo val;
+ if (pressure_report_delay > 0) {
+ --pressure_report_delay;
+ return;
+ }
si_meminfo(&val);
memset(&status, 0, sizeof(struct dm_status));
status.hdr.type = DM_STATUS_REPORT;
@@ -552,8 +563,6 @@ static void post_status(struct hv_dynmem_device *dm)
}
-
-
static void free_balloon_pages(struct hv_dynmem_device *dm,
union dm_mem_page_range *range_array)
{
--
1.7.4.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] Drivers: hv: balloon: Prevent the host from ballooning the guest too low
2013-02-08 23:57 ` [PATCH 1/2] Drivers: hv: balloon: Add a parameter to delay pressure reporting K. Y. Srinivasan
@ 2013-02-08 23:57 ` K. Y. Srinivasan
0 siblings, 0 replies; 3+ messages in thread
From: K. Y. Srinivasan @ 2013-02-08 23:57 UTC (permalink / raw)
To: gregkh, linux-kernel, devel, olaf, apw, jasowang; +Cc: K. Y. Srinivasan
Based on the amount of memory being managed set a floor on how low the
guest can be ballooned.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
---
drivers/hv/hv_balloon.c | 35 ++++++++++++++++++++++++++++++++++-
1 files changed, 34 insertions(+), 1 deletions(-)
diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index f8fc996..3787321 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -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
@@ -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),
--
1.7.4.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-02-08 23:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-08 23:56 [PATCH 0/2] Drivers: hv: balloon K. Y. Srinivasan
2013-02-08 23:57 ` [PATCH 1/2] Drivers: hv: balloon: Add a parameter to delay pressure reporting K. Y. Srinivasan
2013-02-08 23:57 ` [PATCH 2/2] Drivers: hv: balloon: Prevent the host from ballooning the guest too low K. Y. Srinivasan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).