<div dir="ltr"><div dir="ltr"><div dir="ltr">Ping. Anyone could help review the patch: <a href="https://www.redhat.com/archives/libvir-list/2019-April/msg01454.html" target="_blank">https://www.redhat.com/archives/libvir-list/2019-April/msg01454.html</a><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Apr 28, 2019 at 5:18 PM Han Han <<a href="mailto:hhan@redhat.com" target="_blank">hhan@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Qemu added reporting of virtio balloon new statistics stat-htlb-pgalloc and<br>
stat-htlb-pgfail since qemu-3.0 commit b7b12644297. The value of<br>
stat-htlb-pgalloc represents the number of successful hugetlb page allocations<br>
while stat-htlb-pgfail represents the number of failed ones. Add this<br>
statistics reporting to libvirt.<br>
<br>
To enable this feature for vm, guest kenel >= 4.17 is required because<br>
the exporting hugetlb page allocation for virtio balloon is introduced<br>
since 6c64fe7f.<br>
<br>
Signed-off-by: Han Han <<a href="mailto:hhan@redhat.com" target="_blank">hhan@redhat.com</a>><br>
---<br>
include/libvirt/libvirt-domain.h | 14 +++++++++++++-<br>
src/libvirt-domain.c | 5 ++++-<br>
src/qemu/qemu_driver.c | 2 ++<br>
src/qemu/qemu_monitor_json.c | 5 +++++<br>
tools/virsh-domain-monitor.c | 4 ++++<br>
tools/virsh.pod | 2 ++<br>
6 files changed, 30 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h<br>
index 7d36820b5a..192d25c1db 100644<br>
--- a/include/libvirt/libvirt-domain.h<br>
+++ b/include/libvirt/libvirt-domain.h<br>
@@ -636,11 +636,23 @@ typedef enum {<br>
*/<br>
VIR_DOMAIN_MEMORY_STAT_DISK_CACHES = 10,<br>
<br>
+ /*<br>
+ * The amount of successful hugetlb(Huge Page Tables) allocations via<br>
+ * virtio balloon.<br>
+ */<br>
+ VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGALLOC = 11,<br>
+<br>
+ /*<br>
+ * The amount of failed hugetlb(Huge Page Tables) allocations via<br>
+ * virtio balloon.<br>
+ */<br>
+ VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGFAIL = 12,<br>
+<br>
/*<br>
* The number of statistics supported by this version of the interface.<br>
* To add new statistics, add them to the enum and increase this value.<br>
*/<br>
- VIR_DOMAIN_MEMORY_STAT_NR = 11,<br>
+ VIR_DOMAIN_MEMORY_STAT_NR = 13,<br>
<br>
# ifdef VIR_ENUM_SENTINELS<br>
VIR_DOMAIN_MEMORY_STAT_LAST = VIR_DOMAIN_MEMORY_STAT_NR<br>
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c<br>
index 80284a99f0..a95690e8a4 100644<br>
--- a/src/libvirt-domain.c<br>
+++ b/src/libvirt-domain.c<br>
@@ -5734,7 +5734,10 @@ virDomainGetInterfaceParameters(virDomainPtr domain,<br>
* VIR_DOMAIN_MEMORY_STAT_DISK_CACHES<br>
* Memory that can be reclaimed without additional I/O, typically disk<br>
* caches (in kb).<br>
- *<br>
+ * VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGALLOC<br>
+ * The amount of successful hugetlb(Huge Page Tables) allocations<br>
+ * VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGFAIL<br>
+ * The amount of failed hugetlb(Huge Page Tables) allocations<br>
* Returns: The number of stats provided or -1 in case of failure.<br>
*/<br>
int<br>
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c<br>
index f48d9256e4..2d849beac8 100644<br>
--- a/src/qemu/qemu_driver.c<br>
+++ b/src/qemu/qemu_driver.c<br>
@@ -20245,6 +20245,8 @@ qemuDomainGetStatsBalloon(virQEMUDriverPtr driver,<br>
STORE_MEM_RECORD(LAST_UPDATE, "last-update")<br>
STORE_MEM_RECORD(USABLE, "usable")<br>
STORE_MEM_RECORD(DISK_CACHES, "disk_caches")<br>
+ STORE_MEM_RECORD(HUGETLB_PGALLOC, "hugetlb_pgalloc")<br>
+ STORE_MEM_RECORD(HUGETLB_PGFAIL, "hugetlb_pgfail")<br>
}<br>
<br>
#undef STORE_MEM_RECORD<br>
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c<br>
index 908967f46c..5e3df5e759 100644<br>
--- a/src/qemu/qemu_monitor_json.c<br>
+++ b/src/qemu/qemu_monitor_json.c<br>
@@ -2150,6 +2150,11 @@ int qemuMonitorJSONGetMemoryStats(qemuMonitorPtr mon,<br>
VIR_DOMAIN_MEMORY_STAT_LAST_UPDATE, 1);<br>
GET_BALLOON_STATS(statsdata, "stat-disk-caches",<br>
VIR_DOMAIN_MEMORY_STAT_DISK_CACHES, 1024);<br>
+ GET_BALLOON_STATS(statsdata, "stat-htlb-pgalloc",<br>
+ VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGALLOC, 1);<br>
+ GET_BALLOON_STATS(statsdata, "stat-htlb-pgfail",<br>
+ VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGFAIL, 1);<br>
+<br>
ret = got;<br>
cleanup:<br>
virJSONValueFree(cmd);<br>
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c<br>
index d87475f6f6..0092a9786e 100644<br>
--- a/tools/virsh-domain-monitor.c<br>
+++ b/tools/virsh-domain-monitor.c<br>
@@ -376,6 +376,10 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)<br>
vshPrint(ctl, "last_update %llu\n", stats[i].val);<br>
if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_DISK_CACHES)<br>
vshPrint(ctl, "disk_caches %llu\n", stats[i].val);<br>
+ if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGALLOC)<br>
+ vshPrint(ctl, "hugetlb_pgalloc %llu\n", stats[i].val);<br>
+ if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGFAIL)<br>
+ vshPrint(ctl, "hugetlb_pgfail %llu\n", stats[i].val);<br>
}<br>
<br>
ret = true;<br>
diff --git a/tools/virsh.pod b/tools/virsh.pod<br>
index afc1684db0..ef27c527d6 100644<br>
--- a/tools/virsh.pod<br>
+++ b/tools/virsh.pod<br>
@@ -938,6 +938,8 @@ without causing host swapping (in KiB)<br>
last-update - Timestamp of the last update of statistics (in seconds)<br>
disk_caches - The amount of memory that can be reclaimed without<br>
additional I/O, typically disk caches (in KiB)<br>
+ hugetlb_pgalloc - The number of successful huge page table allocations<br>
+ hugetlb_pgfail - The number of failed huge page table allocations<br>
<br>
For QEMU/KVM with a memory balloon, setting the optional I<--period> to a<br>
value larger than 0 in seconds will allow the balloon driver to return<br>
-- <br>
2.20.1<br>
<br>
</blockquote></div><br clear="all"></div><br>-- <br><div dir="ltr" class="gmail-m_-7941615331629476299gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Best regards,</div><div dir="ltr">-----------------------------------<br></div><div dir="ltr">Han Han<br>Quality Engineer<br>Redhat.<br><br>Email: <a href="mailto:hhan@redhat.com" target="_blank">hhan@redhat.com</a><br>Phone: +861065339333<br></div></div></div></div></div></div>