lkml.org 
[lkml]   [2022]   [Oct]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH v5 7/8] drivers: hyperv: balloon - report inflated memory
Date
Update the inflated memory in the mm core on change.

Signed-off-by: Alexander Atanasov <alexander.atanasov@virtuozzo.com>
---
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 fdf6decacf06..280622ee0e9b 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -24,6 +24,7 @@
#include <linux/notifier.h>
#include <linux/percpu_counter.h>
#include <linux/page_reporting.h>
+#include <linux/balloon.h>

#include <linux/hyperv.h>
#include <asm/hyperv-tlfs.h>
@@ -1280,6 +1281,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;
@@ -1368,6 +1377,7 @@ static void balloon_up(struct work_struct *dummy)
}
}

+ report_ballooned_pages(&dm_device);
}

static void balloon_down(struct hv_dynmem_device *dm,
@@ -1387,6 +1397,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;

--
2.31.1
\
 
 \ /
  Last update: 2022-10-19 13:31    [W:0.030 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site