[Devel] [PATCH RHEL7 COMMIT] mm: Add counters to be updated by the balloon drivers

Konstantin Khorenko khorenko at virtuozzo.com
Mon Oct 17 13:31:04 MSK 2022


The commit is pushed to "branch-rh7-3.10.0-1160.76.1.vz7.189.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.76.1.vz7.189.4
------>
commit 2c0e190f155d3d16e1f6c4590278df26f7721505
Author: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
Date:   Wed Oct 5 13:25:28 2022 +0300

    mm: Add counters to be updated by the balloon drivers
    
    Add counters to be updated by the balloon drivers.
    
    Print balloon stats when logging kernel memory usage
    (in particular on OOM and Alt+SysRQ+m).
    
    https://jira.sw.ru/browse/PSBM-142436
    Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
---
 include/linux/balloon_compaction.h |  7 +++++++
 lib/show_mem.c                     |  8 ++++++++
 mm/balloon_compaction.c            | 16 ++++++++++++++++
 3 files changed, 31 insertions(+)

diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_compaction.h
index 58caefc55dbd..becc9d1ed8a8 100644
--- a/include/linux/balloon_compaction.h
+++ b/include/linux/balloon_compaction.h
@@ -246,4 +246,11 @@ static inline struct page *balloon_page_pop(struct list_head *pages)
 	list_del(&page->lru);
 	return page;
 }
+
+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);
+
 #endif /* _LINUX_BALLOON_COMPACTION_H */
diff --git a/lib/show_mem.c b/lib/show_mem.c
index 5ba505ab8319..e1b8b73ddd26 100644
--- a/lib/show_mem.c
+++ b/lib/show_mem.c
@@ -9,6 +9,9 @@
 #include <linux/nmi.h>
 #include <linux/quicklist.h>
 #include <linux/module.h>
+#ifdef CONFIG_MEMORY_BALLOON
+#include <linux/balloon_compaction.h>
+#endif
 
 void show_mem(unsigned int filter)
 {
@@ -47,5 +50,10 @@ void show_mem(unsigned int filter)
 	printk("%lu pages in pagetable cache\n",
 		quicklist_total_size());
 #endif
+#ifdef CONFIG_MEMORY_BALLOON
+       printk("Balloon InflatedTotal:%ldkB InflatedFree:%ldkB\n",
+               atomic_long_read(&mem_balloon_inflated_total_kb),
+               atomic_long_read(&mem_balloon_inflated_free_kb));
+#endif
 }
 EXPORT_SYMBOL(show_mem);
diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c
index 0559c6095b2f..68480076248f 100644
--- a/mm/balloon_compaction.c
+++ b/mm/balloon_compaction.c
@@ -10,6 +10,22 @@
 #include <linux/export.h>
 #include <linux/balloon_compaction.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);
+
 /*
  * balloon_page_alloc - allocates a new page for insertion into the balloon
  *			  page list.


More information about the Devel mailing list