[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20221019095620.124909-3-alexander.atanasov@virtuozzo.com>
Date: Wed, 19 Oct 2022 12:56:14 +0300
From: Alexander Atanasov <alexander.atanasov@...tuozzo.com>
To: "Michael S. Tsirkin" <mst@...hat.com>,
David Hildenbrand <david@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: kernel@...nvz.org,
Alexander Atanasov <alexander.atanasov@...tuozzo.com>,
virtualization@...ts.linux-foundation.org,
linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: [RFC PATCH v5 2/8] mm: Enable balloon drivers to report inflated memory
Add counters to be updated by the balloon drivers.
Signed-off-by: Alexander Atanasov <alexander.atanasov@...tuozzo.com>
---
include/linux/balloon.h | 6 ++++++
mm/balloon.c | 15 +++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/include/linux/balloon.h b/include/linux/balloon.h
index 46ac8f61f607..dd8fb8ac5737 100644
--- a/include/linux/balloon.h
+++ b/include/linux/balloon.h
@@ -57,6 +57,12 @@ struct balloon_dev_info {
struct page *page, enum migrate_mode mode);
};
+extern atomic_long_t mem_balloon_inflated_total_kb;
+extern atomic_long_t mem_balloon_inflated_free_kb;
+
+void balloon_set_inflated_total(long inflated_kb);
+void balloon_set_inflated_free(long inflated_kb);
+
struct page *balloon_page_alloc(void);
void balloon_page_enqueue(struct balloon_dev_info *b_dev_info,
struct page *page);
diff --git a/mm/balloon.c b/mm/balloon.c
index 22b3e876bc78..59f606bf4390 100644
--- a/mm/balloon.c
+++ b/mm/balloon.c
@@ -9,6 +9,21 @@
#include <linux/export.h>
#include <linux/balloon.h>
+atomic_long_t mem_balloon_inflated_total_kb = ATOMIC_LONG_INIT(0);
+atomic_long_t mem_balloon_inflated_free_kb = ATOMIC_LONG_INIT(0);
+
+void balloon_set_inflated_total(long inflated_kb)
+{
+ atomic_long_set(&mem_balloon_inflated_total_kb, inflated_kb);
+}
+EXPORT_SYMBOL(balloon_set_inflated_total);
+
+void balloon_set_inflated_free(long inflated_kb)
+{
+ atomic_long_set(&mem_balloon_inflated_free_kb, inflated_kb);
+}
+EXPORT_SYMBOL(balloon_set_inflated_free);
+
static void balloon_page_enqueue_one(struct balloon_dev_info *b_dev_info,
struct page *page)
{
--
2.31.1
Powered by blists - more mailing lists