[Devel] [PATCH RHEL9 COMMIT] drivers/hyperv: Balloon report stats to mm core

Konstantin Khorenko khorenko at virtuozzo.com
Mon Oct 17 16:14:30 MSK 2022


The commit is pushed to "branch-rh9-5.14.0-70.22.1.vz9.17.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-70.22.1.vz9.17.7
------>
commit f8d95cc89535867e08144a64922b2695b6e0b699
Author: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
Date:   Mon Oct 17 14:52:54 2022 +0300

    drivers/hyperv: Balloon report stats to mm core
    
    Propagate balloon stats to mm core.
    
    Hyper-V balloon driver changes TOTAL RAM size reported by the guest,
    thus propagating the "InflatedTotal" counter to mm.
    
    https://jira.sw.ru/browse/PSBM-142436
    Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
    
    Feature: balloon: usage information visible by guest
---
 drivers/hv/hv_balloon.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index 2384d702cc3d..090b8a0375ae 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -24,6 +24,7 @@
 #include <linux/percpu_counter.h>
 #include <linux/page_reporting.h>
 
+#include <linux/balloon_compaction.h>
 #include <linux/hyperv.h>
 #include <asm/hyperv-tlfs.h>
 
@@ -1273,6 +1274,14 @@ static unsigned int alloc_balloon_pages(struct hv_dynmem_device *dm,
 	return i * alloc_unit;
 }
 
+static void report_ballooned_pages(struct hv_dynmem_device *dm)
+{
+	u32 actual = dm->num_pages_ballooned;
+	long inflated_kb = actual << (HV_HYP_PAGE_SHIFT - 10);
+
+	balloon_set_inflated_total(inflated_kb);
+}
+
 static void balloon_up(struct work_struct *dummy)
 {
 	unsigned int num_pages = dm_device.balloon_wrk.num_pages;
@@ -1361,6 +1370,7 @@ static void balloon_up(struct work_struct *dummy)
 		}
 	}
 
+	report_ballooned_pages(&dm_device);
 }
 
 static void balloon_down(struct hv_dynmem_device *dm,
@@ -1380,6 +1390,8 @@ static void balloon_down(struct hv_dynmem_device *dm,
 	pr_debug("Freed %u ballooned pages.\n",
 		prev_pages_ballooned - dm->num_pages_ballooned);
 
+	report_ballooned_pages(dm);
+
 	if (req->more_pages == 1)
 		return;
 


More information about the Devel mailing list