Add counters to be updated by the balloon drivers. Print balloon stats when logging kernel memory usage.
https://jira.sw.ru/browse/PSBM-142436 Signed-off-by: Alexander Atanasov <alexander.atana...@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. -- 2.31.1 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel