[RFC,v5,2/8] mm: Enable balloon drivers to report inflated memory

Message ID 20221019095620.124909-3-alexander.atanasov@virtuozzo.com
State New
Headers
Series None |

Commit Message

Alexander Atanasov Oct. 19, 2022, 9:56 a.m. UTC
  Add counters to be updated by the balloon drivers.

Signed-off-by: Alexander Atanasov <alexander.atanasov@virtuozzo.com>
---
 include/linux/balloon.h |  6 ++++++
 mm/balloon.c            | 15 +++++++++++++++
 2 files changed, 21 insertions(+)
  

Patch

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)
 {