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 9a4e4594a5dbd9fa70260293d95446e2be315e99
Author: Alexander Atanasov <alexander.atana...@virtuozzo.com>
Date:   Mon Oct 17 14:52:51 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.atana...@virtuozzo.com>
    
    Feature: balloon: usage information visible by guest
---
 include/linux/balloon_compaction.h |  6 ++++++
 lib/show_mem.c                     |  8 ++++++++
 mm/balloon_compaction.c            | 15 +++++++++++++++
 3 files changed, 29 insertions(+)

diff --git a/include/linux/balloon_compaction.h 
b/include/linux/balloon_compaction.h
index 338aa27e4773..04c7a5c1dedd 100644
--- a/include/linux/balloon_compaction.h
+++ b/include/linux/balloon_compaction.h
@@ -207,4 +207,10 @@ 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 1c26c14ffbb9..dee20eb0ee6d 100644
--- a/lib/show_mem.c
+++ b/lib/show_mem.c
@@ -7,6 +7,9 @@
 
 #include <linux/mm.h>
 #include <linux/cma.h>
+#ifdef CONFIG_MEMORY_BALLOON
+#include <linux/balloon_compaction.h>
+#endif
 
 void show_mem(unsigned int filter, nodemask_t *nodemask)
 {
@@ -41,4 +44,9 @@ void show_mem(unsigned int filter, nodemask_t *nodemask)
 #ifdef CONFIG_MEMORY_FAILURE
        printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages));
 #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
 }
diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c
index 907fefde2572..bb6b706ffca1 100644
--- a/mm/balloon_compaction.c
+++ b/mm/balloon_compaction.c
@@ -257,4 +257,19 @@ const struct address_space_operations balloon_aops = {
 };
 EXPORT_SYMBOL_GPL(balloon_aops);
 
+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);
+
 #endif /* CONFIG_BALLOON_COMPACTION */
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to