mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: devel@linuxdriverproject.org
Cc: linux-kernel@vger.kernel.org,
	"K. Y. Srinivasan" <kys@microsoft.com>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	Stephen Hemminger <sthemmin@microsoft.com>
Subject: [PATCH] Drivers: hv: balloon: hide the inflated balloon pages
Date: Tue,  7 Feb 2017 15:43:33 +0100	[thread overview]
Message-ID: <20170207144333.6907-1-vkuznets@redhat.com> (raw)

When the balloon is inflated we see it as kernel allocated memory and this
is confusing especially when it is used as a replacement for memory hot
unplug. Hide the balloon with adjust_managed_page_count(). Virtio
ballooning driver does this already.

compute_balloon_floor() is adjusted to keep the existing behavior.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 drivers/hv/hv_balloon.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index 14c3dc4b..8b22451 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -1049,7 +1049,10 @@ static void process_info(struct hv_dynmem_device *dm, struct dm_info_msg *msg)
 
 static unsigned long compute_balloon_floor(void)
 {
+	unsigned long curram_pages = totalram_pages +
+		dm_device.num_pages_ballooned;
 	unsigned long min_pages;
+
 #define MB2PAGES(mb) ((mb) << (20 - PAGE_SHIFT))
 	/* Simple continuous piecewiese linear function:
 	 *  max MiB -> min MiB  gradient
@@ -1062,16 +1065,16 @@ static unsigned long compute_balloon_floor(void)
 	 *    8192       744    (1/16)
 	 *   32768      1512	(1/32)
 	 */
-	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 if (totalram_pages < MB2PAGES(8192))
-		min_pages = MB2PAGES(232) + (totalram_pages >> 4);
+	if (curram_pages < MB2PAGES(128))
+		min_pages = MB2PAGES(8) + (curram_pages >> 1);
+	else if (curram_pages < MB2PAGES(512))
+		min_pages = MB2PAGES(40) + (curram_pages >> 2);
+	else if (curram_pages < MB2PAGES(2048))
+		min_pages = MB2PAGES(104) + (curram_pages >> 3);
+	else if (curram_pages < MB2PAGES(8192))
+		min_pages = MB2PAGES(232) + (curram_pages >> 4);
 	else
-		min_pages = MB2PAGES(488) + (totalram_pages >> 5);
+		min_pages = MB2PAGES(488) + (curram_pages >> 5);
 #undef MB2PAGES
 	return min_pages;
 }
@@ -1156,6 +1159,7 @@ static void free_balloon_pages(struct hv_dynmem_device *dm,
 	for (i = 0; i < num_pages; i++) {
 		pg = pfn_to_page(i + start_frame);
 		__free_page(pg);
+		adjust_managed_page_count(pg, 1);
 		dm->num_pages_ballooned--;
 	}
 }
@@ -1190,6 +1194,7 @@ static unsigned int alloc_balloon_pages(struct hv_dynmem_device *dm,
 			return i * alloc_unit;
 
 		dm->num_pages_ballooned += alloc_unit;
+		adjust_managed_page_count(pg, -alloc_unit);
 
 		/*
 		 * If we allocatted 2M pages; split them so we
-- 
2.9.3

                 reply	other threads:[~2017-02-07 14:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20170207144333.6907-1-vkuznets@redhat.com \
    --to=vkuznets@redhat.com \
    --cc=devel@linuxdriverproject.org \
    --cc=haiyangz@microsoft.com \
    --cc=kys@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sthemmin@microsoft.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

all inboxes | Powered by JetHome®