diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index 7d36820b5a9a8b4e9ee4abe8aafeb05f6c9b4751..2dbd74d4f3d3c25bc799f4ccc5bb4af2b9f24893 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -636,11 +636,23 @@ typedef enum { */ VIR_DOMAIN_MEMORY_STAT_DISK_CACHES = 10, + /* + * The amount of successful huge page allocations from inside the domain via + * virtio balloon. + */ + VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGALLOC = 11, + + /* + * The amount of failed huge page allocations from inside the domain via + * virtio balloon. + */ + VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGFAIL = 12, + /* * The number of statistics supported by this version of the interface. * To add new statistics, add them to the enum and increase this value. */ - VIR_DOMAIN_MEMORY_STAT_NR = 11, + VIR_DOMAIN_MEMORY_STAT_NR = 13, # ifdef VIR_ENUM_SENTINELS VIR_DOMAIN_MEMORY_STAT_LAST = VIR_DOMAIN_MEMORY_STAT_NR diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 80284a99f0b47a54dbc4449de6ab77f0bcd728b6..df7e405b3e3091c8ce1162ec632a1f06005bde5c 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -5734,6 +5734,10 @@ virDomainGetInterfaceParameters(virDomainPtr domain, * VIR_DOMAIN_MEMORY_STAT_DISK_CACHES * Memory that can be reclaimed without additional I/O, typically disk * caches (in kb). + * VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGALLOC + * The amount of successful huge page allocations from inside the domain + * VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGFAIL + * The amount of failed huge page allocations from inside the domain * * Returns: The number of stats provided or -1 in case of failure. */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index befa87677fde1a06cc7307fb2882babbd65462dd..06d8cb24716ace0b09d334ba6fd27c80aeec070e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20248,6 +20248,8 @@ qemuDomainGetStatsBalloon(virQEMUDriverPtr driver, STORE_MEM_RECORD(LAST_UPDATE, "last-update") STORE_MEM_RECORD(USABLE, "usable") STORE_MEM_RECORD(DISK_CACHES, "disk_caches") + STORE_MEM_RECORD(HUGETLB_PGALLOC, "hugetlb_pgalloc") + STORE_MEM_RECORD(HUGETLB_PGFAIL, "hugetlb_pgfail") } #undef STORE_MEM_RECORD diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 908967f46c64dad3d3c69a9e39f2e2aaf7059566..5e3df5e75992a8c4d55976e661bd981181fc1eb9 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2150,6 +2150,11 @@ int qemuMonitorJSONGetMemoryStats(qemuMonitorPtr mon, VIR_DOMAIN_MEMORY_STAT_LAST_UPDATE, 1); GET_BALLOON_STATS(statsdata, "stat-disk-caches", VIR_DOMAIN_MEMORY_STAT_DISK_CACHES, 1024); + GET_BALLOON_STATS(statsdata, "stat-htlb-pgalloc", + VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGALLOC, 1); + GET_BALLOON_STATS(statsdata, "stat-htlb-pgfail", + VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGFAIL, 1); + ret = got; cleanup: virJSONValueFree(cmd); diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index d2b7e5a0597f0f24e5c4f70db6d6e85970d250b8..e399195debc3216edfe1732167884ab520485317 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -376,6 +376,10 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd) vshPrint(ctl, "last_update %llu\n", stats[i].val); if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_DISK_CACHES) vshPrint(ctl, "disk_caches %llu\n", stats[i].val); + if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGALLOC) + vshPrint(ctl, "hugetlb_pgalloc %llu\n", stats[i].val); + if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGFAIL) + vshPrint(ctl, "hugetlb_pgfail %llu\n", stats[i].val); } ret = true; diff --git a/tools/virsh.pod b/tools/virsh.pod index 6bfeac64928bb951242367dbe17ae2431695570e..9f5bfd27a08bec7b9b3400b512d9850d06ec7c6a 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -938,6 +938,10 @@ without causing host swapping (in KiB) last-update - Timestamp of the last update of statistics (in seconds) disk_caches - The amount of memory that can be reclaimed without additional I/O, typically disk caches (in KiB) + hugetlb_pgalloc - The number of successful huge page allocations initiated +from within the domain + hugetlb_pgfail - The number of failed huge page allocations initiated from +within the domain For QEMU/KVM with a memory balloon, setting the optional I<--period> to a value larger than 0 in seconds will allow the balloon driver to return