From nobody Sun Apr 28 23:13:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1556443190; cv=none; d=zoho.com; s=zohoarc; b=Ieg/u8WZAoQQ9Ske9b6nBm7G/uVJB6JfAyn2Hcd84RZatZPXoYXF72j6gj9FcTrFqtufAnXZpLhh2y5FNCoFxf4dKslH3EOXuc29TBqO87CqH5Iv5hND4DStPncku7EHUHXTjOXXMNRWG0Zo/pqyF4lp1qTRqTpOVHpwm/j7A0g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556443190; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=N7nDDqAa/OX6s5cukrxCKikWa3OFuiXuteqANDvRaTw=; b=l4YOAJ37gn7mB+q1mKK7ht+VWYjWIJbDUy3DYdZAiFgdFaiM9LdRl8yvK6JGPjXCWqNhMt2rMfOz+/SnnftyelY0Llg1XO940OdDg9Dy0t2dB0MOzCo4zNQpqKmiTyFdC3cmn+g3Nt9PPowZnvGhukIb6Mh6GWVRmCz+OAWMGs8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1556443190619546.8685259315286; Sun, 28 Apr 2019 02:19:50 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 00644307D857; Sun, 28 Apr 2019 09:19:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 62C8C6E3F5; Sun, 28 Apr 2019 09:19:48 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CABB641F3D; Sun, 28 Apr 2019 09:19:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x3S9IiaK015630 for ; Sun, 28 Apr 2019 05:18:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id DC83A1001E69; Sun, 28 Apr 2019 09:18:44 +0000 (UTC) Received: from hansolo.nay.redhat.com (unknown [10.66.4.176]) by smtp.corp.redhat.com (Postfix) with ESMTP id CBFAA10027DE; Sun, 28 Apr 2019 09:18:41 +0000 (UTC) From: Han Han To: libvir-list@redhat.com Date: Sun, 28 Apr 2019 17:18:05 +0800 Message-Id: <20190428091805.20640-1-hhan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Han Han Subject: [libvirt] [PATCH v2] qemu: Add entry for balloon stats stat-htlb-pgalloc and stat-htlb-pgfail X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Sun, 28 Apr 2019 09:19:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Qemu added reporting of virtio balloon new statistics stat-htlb-pgalloc and stat-htlb-pgfail since qemu-3.0 commit b7b12644297. The value of stat-htlb-pgalloc represents the number of successful hugetlb page allocati= ons while stat-htlb-pgfail represents the number of failed ones. Add this statistics reporting to libvirt. To enable this feature for vm, guest kenel >=3D 4.17 is required because the exporting hugetlb page allocation for virtio balloon is introduced since 6c64fe7f. Signed-off-by: Han Han --- include/libvirt/libvirt-domain.h | 14 +++++++++++++- src/libvirt-domain.c | 5 ++++- src/qemu/qemu_driver.c | 2 ++ src/qemu/qemu_monitor_json.c | 5 +++++ tools/virsh-domain-monitor.c | 4 ++++ tools/virsh.pod | 2 ++ 6 files changed, 30 insertions(+), 2 deletions(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 7d36820b5a..192d25c1db 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 =3D 10, =20 + /* + * The amount of successful hugetlb(Huge Page Tables) allocations via + * virtio balloon. + */ + VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGALLOC =3D 11, + + /* + * The amount of failed hugetlb(Huge Page Tables) allocations via + * virtio balloon. + */ + VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGFAIL =3D 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 =3D 11, + VIR_DOMAIN_MEMORY_STAT_NR =3D 13, =20 # ifdef VIR_ENUM_SENTINELS VIR_DOMAIN_MEMORY_STAT_LAST =3D VIR_DOMAIN_MEMORY_STAT_NR diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 80284a99f0..a95690e8a4 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -5734,7 +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 hugetlb(Huge Page Tables) allocations + * VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGFAIL + * The amount of failed hugetlb(Huge Page Tables) allocations * Returns: The number of stats provided or -1 in case of failure. */ int diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f48d9256e4..2d849beac8 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20245,6 +20245,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") } =20 #undef STORE_MEM_RECORD diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 908967f46c..5e3df5e759 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 =3D got; cleanup: virJSONValueFree(cmd); diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index d87475f6f6..0092a9786e 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 =3D=3D VIR_DOMAIN_MEMORY_STAT_DISK_CACHES) vshPrint(ctl, "disk_caches %llu\n", stats[i].val); + if (stats[i].tag =3D=3D VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGALLOC) + vshPrint(ctl, "hugetlb_pgalloc %llu\n", stats[i].val); + if (stats[i].tag =3D=3D VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGFAIL) + vshPrint(ctl, "hugetlb_pgfail %llu\n", stats[i].val); } =20 ret =3D true; diff --git a/tools/virsh.pod b/tools/virsh.pod index afc1684db0..ef27c527d6 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -938,6 +938,8 @@ without causing host swapping (in KiB) last-update - Timestamp of the last update of statistics (in secon= ds) 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 table allocations + hugetlb_pgfail - The number of failed huge page table allocations =20 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 --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list