From nobody Tue Dec 16 08:39:15 2025 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=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152845039208726.32391676542761; Fri, 8 Jun 2018 02:33:12 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BD19E308A945; Fri, 8 Jun 2018 09:33:10 +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 8C351A1105; Fri, 8 Jun 2018 09:33:10 +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 31A0F4CA83; Fri, 8 Jun 2018 09:33:10 +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 w589WsvL010299 for ; Fri, 8 Jun 2018 05:32:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 625561001F44; Fri, 8 Jun 2018 09:32:54 +0000 (UTC) Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5919210018FD for ; Fri, 8 Jun 2018 09:32:51 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BD32F3082122 for ; Fri, 8 Jun 2018 09:32:50 +0000 (UTC) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jun 2018 02:32:50 -0700 Received: from david-unc.bj.intel.com ([10.238.145.77]) by fmsmga004.fm.intel.com with ESMTP; 08 Jun 2018 02:32:49 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,490,1520924400"; d="scan'208";a="61461062" From: Wang Huaqiang To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 17:02:19 +0800 Message-Id: <1528448539-25588-4-git-send-email-huaqiang.wang@intel.com> In-Reply-To: <1528448539-25588-1-git-send-email-huaqiang.wang@intel.com> References: <1528448539-25588-1-git-send-email-huaqiang.wang@intel.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 08 Jun 2018 09:32:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 08 Jun 2018 09:32:50 +0000 (UTC) for IP:'192.55.52.120' DOMAIN:'mga04.intel.com' HELO:'mga04.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 192.55.52.120 mga04.intel.com 192.55.52.120 mga04.intel.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: shaohe.feng@intel.com, Wang Huaqiang , bing.niu@intel.com, jian-feng.ding@intel.com, rui.zang@intel.com Subject: [libvirt] [PATCH 3/3] tools: virsh domstats: show RDT CMT resource utilization information 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 08 Jun 2018 09:33:11 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" --- include/libvirt/libvirt-domain.h | 1 + src/libvirt-domain.c | 11 +++++++++ src/qemu/qemu_driver.c | 48 ++++++++++++++++++++++++++++++++++++= ++++ tools/virsh-domain-monitor.c | 7 ++++++ 4 files changed, 67 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 598db28..696b686 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -2041,6 +2041,7 @@ typedef enum { VIR_DOMAIN_STATS_INTERFACE =3D (1 << 4), /* return domain interfaces i= nfo */ VIR_DOMAIN_STATS_BLOCK =3D (1 << 5), /* return domain block info */ VIR_DOMAIN_STATS_PERF =3D (1 << 6), /* return domain perf event info */ + VIR_DOMAIN_STATS_RESCTRL =3D (1<<7), /* return resctrlfs mornitoring = info */ } virDomainStatsTypes; =20 typedef enum { diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 07a19a6..3f1e156 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -11486,6 +11486,17 @@ virConnectGetDomainCapabilities(virConnectPtr conn, * long long. It is produced by the * emulation_faults perf event * + * VIR_DOMAIN_STATS_RESCTRL + * "resctrl.cmt" - the usage of l3 cache (bytes) by applications runn= ing on + * the platform as unsigned long long. It is retrieved f= rom + * resctrl file system. + * "resctrl.mbmt" - the total system bandwidth (bytes/s) from one leve= l of + * cache to another as unsigned long long. Retrieved fr= om + * resctrl file system. + * "resctrl.mbml" - the amount of data (bytes/s) sent through the memo= ry + * controller on the socket as unsigned long long. Retr= ieved + * from resctrl file system. + * * Note that entire stats groups or individual stat fields may be missing = from * the output in case they are not supported by the given hypervisor, are = not * applicable for the current state of the guest domain, or their retrieval diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4075daa..8004e26 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20313,6 +20313,53 @@ qemuDomainGetStatsPerf(virQEMUDriverPtr driver ATT= RIBUTE_UNUSED, return ret; } =20 +static int +qemuDomainGetStatsResctrl(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, + virDomainObjPtr vm, + virDomainStatsRecordPtr record, + int *maxparams, + unsigned int privflags ATTRIBUTE_UNUSED) +{ + size_t i; + unsigned int llc_occu; + unsigned int llc_occu_total=3D 0; + int ret =3D -1; +#define DOMAIN_STATE_STR_RESCTRL "resctrl" + + for (i =3D 0; i < vm->def->ncachetunes; i++) { + virDomainCachetuneDefPtr ct =3D vm->def->cachetunes[i]; + + if (virResctrlMonIsRunning(ct->mon)) { + VIR_DEBUG("llc_occupancy: checking cachetune [%ld] ", i); + if (virResctrlMonGetCacheOccupancy(ct->mon, &llc_occu) < 0) + goto cleanup; + llc_occu_total +=3D llc_occu; + } + } + + if (vm->def->resctrlmon_noalloc && + virResctrlMonIsRunning(vm->def->resctrlmon_noalloc)) { + VIR_DEBUG("llc_occupancy: checking resctrl vcpu-rest"); + if (virResctrlMonGetCacheOccupancy( + vm->def->resctrlmon_noalloc, &llc_occu) < 0) + goto cleanup; + llc_occu_total +=3D llc_occu; + } + + if (virTypedParamsAddInt(&record->params, + &record->nparams, + maxparams, + DOMAIN_STATE_STR_RESCTRL + ".cmt", + llc_occu_total) < 0){ + goto cleanup; + } + + ret =3D 0; +cleanup: + return ret; +} + typedef int (*qemuDomainGetStatsFunc)(virQEMUDriverPtr driver, virDomainObjPtr dom, @@ -20334,6 +20381,7 @@ static struct qemuDomainGetStatsWorker qemuDomainGe= tStatsWorkers[] =3D { { qemuDomainGetStatsInterface, VIR_DOMAIN_STATS_INTERFACE, false }, { qemuDomainGetStatsBlock, VIR_DOMAIN_STATS_BLOCK, true }, { qemuDomainGetStatsPerf, VIR_DOMAIN_STATS_PERF, false }, + { qemuDomainGetStatsResctrl, VIR_DOMAIN_STATS_RESCTRL, false }, { NULL, 0, false } }; =20 diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 8cbb3db..b08d977 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -1948,6 +1948,10 @@ static const vshCmdOptDef opts_domstats[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("report domain perf event statistics"), }, + {.name =3D "resctrl", + .type =3D VSH_OT_BOOL, + .help =3D N_("report resctrlfs mon group information"), + }, {.name =3D "list-active", .type =3D VSH_OT_BOOL, .help =3D N_("list only active domains"), @@ -2057,6 +2061,9 @@ cmdDomstats(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "perf")) stats |=3D VIR_DOMAIN_STATS_PERF; =20 + if (vshCommandOptBool(cmd, "resctrl")) + stats |=3D VIR_DOMAIN_STATS_RESCTRL; + if (vshCommandOptBool(cmd, "list-active")) flags |=3D VIR_CONNECT_GET_ALL_DOMAINS_STATS_ACTIVE; =20 --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list