lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20170207144333.6907-1-vkuznets@redhat.com>
Date:   Tue,  7 Feb 2017 15:43:33 +0100
From:   Vitaly Kuznetsov <vkuznets@...hat.com>
To:     devel@...uxdriverproject.org
Cc:     linux-kernel@...r.kernel.org,
        "K. Y. Srinivasan" <kys@...rosoft.com>,
        Haiyang Zhang <haiyangz@...rosoft.com>,
        Stephen Hemminger <sthemmin@...rosoft.com>
Subject: [PATCH] Drivers: hv: balloon: hide the inflated balloon pages

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@...hat.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ