Skip to content

Commit 835de37

Browse files
PacheNicoakpm00
authored andcommitted
meminfo: add a per node counter for balloon drivers
Patch series "track memory used by balloon drivers", v2. This series introduces a way to track memory used by balloon drivers. Add a NR_BALLOON_PAGES counter to track how many pages are reclaimed by the balloon drivers. First add the accounting, then updates the balloon drivers (virtio, Hyper-V, VMware, Pseries-cmm, and Xen) to maintain this counter. The virtio, Vmware, and pseries-cmm balloon drivers utilize the balloon_compaction interface to allocate and free balloon pages. Other balloon drivers will have to maintain this counter manually. This makes the information visible in memory reporting interfaces like /proc/meminfo, show_mem, and OOM reporting. This provides admins visibility into their VM balloon sizes without requiring different virtualization tooling. Furthermore, this information is helpful when debugging an OOM inside a VM. This patch (of 4): Add NR_BALLOON_PAGES counter to track memory used by balloon drivers and expose it through /proc/meminfo and other memory reporting interfaces. [[email protected]: document Balloon Meminfo entry] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Nico Pache <[email protected]> Cc: Alexander Atanasov <[email protected]> Cc: Chengming Zhou <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Dexuan Cui <[email protected]> Cc: Haiyang Zhang <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Juegren Gross <[email protected]> Cc: Kanchana P Sridhar <[email protected]> Cc: K. Y. Srinivasan <[email protected]> Cc: "Michael S. Tsirkin" <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Muchun Song <[email protected]> Cc: Nhat Pham <[email protected]> Cc: Oleksandr Tyshchenko <[email protected]> Cc: Roman Gushchin <[email protected]> Cc: Shakeel Butt <[email protected]> Cc: Stefano Stabellini <[email protected]> Cc: Wei Liu <[email protected]> Cc: Michael Kelley <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 0d2a260 commit 835de37

File tree

5 files changed

+10
-1
lines changed

5 files changed

+10
-1
lines changed

Documentation/filesystems/proc.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,7 @@ Example output. You may not have all of these fields.
10811081
FilePmdMapped: 0 kB
10821082
CmaTotal: 0 kB
10831083
CmaFree: 0 kB
1084+
Balloon: 0 kB
10841085
HugePages_Total: 0
10851086
HugePages_Free: 0
10861087
HugePages_Rsvd: 0
@@ -1255,6 +1256,8 @@ CmaTotal
12551256
Memory reserved for the Contiguous Memory Allocator (CMA)
12561257
CmaFree
12571258
Free remaining memory in the CMA reserves
1259+
Balloon
1260+
Memory returned to Host by VM Balloon Drivers
12581261
HugePages_Total, HugePages_Free, HugePages_Rsvd, HugePages_Surp, Hugepagesize, Hugetlb
12591262
See Documentation/admin-guide/mm/hugetlbpage.rst.
12601263
DirectMap4k, DirectMap2M, DirectMap1G

fs/proc/meminfo.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
162162
show_val_kb(m, "Unaccepted: ",
163163
global_zone_page_state(NR_UNACCEPTED));
164164
#endif
165+
show_val_kb(m, "Balloon: ",
166+
global_node_page_state(NR_BALLOON_PAGES));
165167

166168
hugetlb_report_meminfo(m);
167169

include/linux/mmzone.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ enum node_stat_item {
224224
#ifdef CONFIG_HUGETLB_PAGE
225225
NR_HUGETLB,
226226
#endif
227+
NR_BALLOON_PAGES,
227228
NR_VM_NODE_STAT_ITEMS
228229
};
229230

mm/show_mem.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ static void show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_z
260260
" pagetables:%lukB"
261261
" sec_pagetables:%lukB"
262262
" all_unreclaimable? %s"
263+
" Balloon:%lukB"
263264
"\n",
264265
pgdat->node_id,
265266
K(node_page_state(pgdat, NR_ACTIVE_ANON)),
@@ -285,7 +286,8 @@ static void show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_z
285286
#endif
286287
K(node_page_state(pgdat, NR_PAGETABLE)),
287288
K(node_page_state(pgdat, NR_SECONDARY_PAGETABLE)),
288-
str_yes_no(pgdat->kswapd_failures >= MAX_RECLAIM_RETRIES));
289+
str_yes_no(pgdat->kswapd_failures >= MAX_RECLAIM_RETRIES),
290+
K(node_page_state(pgdat, NR_BALLOON_PAGES)));
289291
}
290292

291293
for_each_populated_zone(zone) {

mm/vmstat.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,6 +1277,7 @@ const char * const vmstat_text[] = {
12771277
#ifdef CONFIG_HUGETLB_PAGE
12781278
"nr_hugetlb",
12791279
#endif
1280+
"nr_balloon_pages",
12801281
/* system-wide enum vm_stat_item counters */
12811282
"nr_dirty_threshold",
12821283
"nr_dirty_background_threshold",

0 commit comments

Comments
 (0)