From: "K. Y. Srinivasan" <kys@microsoft.com>
To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com,
vkuznets@redhat.com
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Subject: [PATCH 3/7] Drivers: hv: hv_balloon: refuse to balloon below the floor
Date: Sat, 28 Feb 2015 11:39:00 -0800 [thread overview]
Message-ID: <1425152344-4953-3-git-send-email-kys@microsoft.com> (raw)
In-Reply-To: <1425152344-4953-1-git-send-email-kys@microsoft.com>
From: Vitaly Kuznetsov <vkuznets@redhat.com>
When host asks us to balloon up we need to be sure we're not committing suicide
by overballooning. Use already existent 'floor' metric as our lowest possible
value for free ram.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
drivers/hv/hv_balloon.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index 53932b3..c5bb872 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -1138,6 +1138,8 @@ static void balloon_up(struct work_struct *dummy)
bool alloc_error;
bool done = false;
int i;
+ struct sysinfo val;
+ unsigned long floor;
/* The host balloons pages in 2M granularity. */
WARN_ON_ONCE(num_pages % PAGES_IN_2M != 0);
@@ -1148,6 +1150,15 @@ static void balloon_up(struct work_struct *dummy)
*/
alloc_unit = 512;
+ si_meminfo(&val);
+ floor = compute_balloon_floor();
+
+ /* Refuse to balloon below the floor, keep the 2M granularity. */
+ if (val.freeram - num_pages < floor) {
+ num_pages = val.freeram > floor ? (val.freeram - floor) : 0;
+ num_pages -= num_pages % PAGES_IN_2M;
+ }
+
while (!done) {
bl_resp = (struct dm_balloon_response *)send_buffer;
memset(send_buffer, 0, PAGE_SIZE);
--
1.7.4.1
next prev parent reply other threads:[~2015-02-28 18:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-28 19:38 [PATCH 0/7] Drivers: hv: Collection fixes and enhancements K. Y. Srinivasan
2015-02-28 19:38 ` [PATCH 1/7] Drivers: hv: hv_balloon: eliminate the trylock path in acquire/release_region_mutex K. Y. Srinivasan
2015-02-28 19:38 ` [PATCH 2/7] Drivers: hv: hv_balloon: report offline pages as being used K. Y. Srinivasan
2015-02-28 19:39 ` K. Y. Srinivasan [this message]
2015-02-28 19:39 ` [PATCH 4/7] Drivers: hv: vmbus: Add support for VMBus panic notifier handler K. Y. Srinivasan
2015-02-28 19:39 ` [PATCH 5/7] Drivers: hv: vmbus: Use a round-robin algorithm for picking the outgoing channel K. Y. Srinivasan
2015-02-28 19:39 ` [PATCH 6/7] Drivers: hv: vmbus: Suport an API to send pagebuffers with additional control K. Y. Srinivasan
2015-02-28 19:39 ` [PATCH 7/7] Drivers: hv: vmbus: Suport an API to send packet " K. Y. Srinivasan
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=1425152344-4953-3-git-send-email-kys@microsoft.com \
--to=kys@microsoft.com \
--cc=apw@canonical.com \
--cc=devel@linuxdriverproject.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olaf@aepfle.de \
--cc=vkuznets@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox