From nobody Fri Apr 19 20:41:47 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=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 1543255103175469.563901066618; Mon, 26 Nov 2018 09:58:23 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D5DAA8E3C5; Mon, 26 Nov 2018 17:58:20 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 758475DD96; Mon, 26 Nov 2018 17:58:20 +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 7032C181A968; Mon, 26 Nov 2018 17:58:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAQHwHni003996 for ; Mon, 26 Nov 2018 12:58:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3D6425B081; Mon, 26 Nov 2018 17:58:17 +0000 (UTC) Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8B19F87A8; Mon, 26 Nov 2018 17:58:14 +0000 (UTC) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (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 38011307D964; Mon, 26 Nov 2018 17:58:13 +0000 (UTC) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Nov 2018 09:58:12 -0800 Received: from david-unc.bj.intel.com ([10.238.145.63]) by fmsmga005.fm.intel.com with ESMTP; 26 Nov 2018 09:58:11 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,283,1539673200"; d="scan'208";a="283751527" From: Wang Huaqiang To: jferlan@redhat.com, libvir-list@redhat.com Date: Tue, 27 Nov 2018 01:56:14 +0800 Message-Id: <1543254977-23949-2-git-send-email-huaqiang.wang@intel.com> In-Reply-To: <1543254977-23949-1-git-send-email-huaqiang.wang@intel.com> References: <1543254977-23949-1-git-send-email-huaqiang.wang@intel.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Mon, 26 Nov 2018 17:58:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Mon, 26 Nov 2018 17:58:13 +0000 (UTC) for IP:'134.134.136.126' DOMAIN:'mga18.intel.com' HELO:'mga18.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 134.134.136.126 mga18.intel.com 134.134.136.126 mga18.intel.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.48 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: huaqiang.wang@intel.com Subject: [libvirt] [PATCHv10 1/4] util: Return a list of pointer in virResctrlMonitorGetStats 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.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 26 Nov 2018 17:58:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Return a list of virResctrlMonitorStatsPtr instead of a virResctrlMonitorStats array in virResctrlMonitorGetStats. Signed-off-by: Wang Huaqiang Reviewed-by: John Ferlan --- src/util/virresctrl.c | 10 +++++----- src/util/virresctrl.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index b32eedc..3268310 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -2647,8 +2647,8 @@ virResctrlMonitorStatsSorter(const void *a, * @monitor: The monitor that the statistic data will be retrieved from. * @resource: The name for resource name. 'llc_occupancy' for cache resour= ce. * "mbm_total_bytes" and "mbm_local_bytes" for memory bandwidth resource. - * @stats: Array of virResctrlMonitorStatsPtr for holding cache or memory - * bandwidth usage data. + * @stats: Pointer of of virResctrlMonitorStatsPtr array for holding cache= or + * memory bandwidth usage data. * @nstats: A size_t pointer to hold the returned array length of @stats * * Get cache or memory bandwidth utilization information. @@ -2658,7 +2658,7 @@ virResctrlMonitorStatsSorter(const void *a, static int virResctrlMonitorGetStats(virResctrlMonitorPtr monitor, const char *resource, - virResctrlMonitorStatsPtr *stats, + virResctrlMonitorStatsPtr **stats, size_t *nstats) { int rv =3D -1; @@ -2729,7 +2729,7 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monito= r, if (rv < 0) goto cleanup; =20 - if (VIR_APPEND_ELEMENT(*stats, *nstats, *stat) < 0) + if (VIR_APPEND_ELEMENT(*stats, *nstats, stat) < 0) goto cleanup; } =20 @@ -2762,7 +2762,7 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monito= r, =20 int virResctrlMonitorGetCacheOccupancy(virResctrlMonitorPtr monitor, - virResctrlMonitorStatsPtr *stats, + virResctrlMonitorStatsPtr **stats, size_t *nstats) { return virResctrlMonitorGetStats(monitor, "llc_occupancy", diff --git a/src/util/virresctrl.h b/src/util/virresctrl.h index 45ec967..e2ed4ee 100644 --- a/src/util/virresctrl.h +++ b/src/util/virresctrl.h @@ -229,6 +229,6 @@ virResctrlMonitorRemove(virResctrlMonitorPtr monitor); =20 int virResctrlMonitorGetCacheOccupancy(virResctrlMonitorPtr monitor, - virResctrlMonitorStatsPtr *caches, - size_t *ncaches); + virResctrlMonitorStatsPtr **stats, + size_t *nstats); #endif /* __VIR_RESCTRL_H__ */ --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 19 20:41:47 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=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 1543255103578940.6156175843637; Mon, 26 Nov 2018 09:58:23 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D990A81F0D; Mon, 26 Nov 2018 17:58:21 +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 A7389173DF; Mon, 26 Nov 2018 17:58:21 +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 4F9D93F602; Mon, 26 Nov 2018 17:58:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAQHwINu004007 for ; Mon, 26 Nov 2018 12:58:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id 342785C227; Mon, 26 Nov 2018 17:58:18 +0000 (UTC) Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 284DE5C1B2; Mon, 26 Nov 2018 17:58:16 +0000 (UTC) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (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 8E6B4307D867; Mon, 26 Nov 2018 17:58:14 +0000 (UTC) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Nov 2018 09:58:13 -0800 Received: from david-unc.bj.intel.com ([10.238.145.63]) by fmsmga005.fm.intel.com with ESMTP; 26 Nov 2018 09:58:12 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,283,1539673200"; d="scan'208";a="283751537" From: Wang Huaqiang To: jferlan@redhat.com, libvir-list@redhat.com Date: Tue, 27 Nov 2018 01:56:15 +0800 Message-Id: <1543254977-23949-3-git-send-email-huaqiang.wang@intel.com> In-Reply-To: <1543254977-23949-1-git-send-email-huaqiang.wang@intel.com> References: <1543254977-23949-1-git-send-email-huaqiang.wang@intel.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Mon, 26 Nov 2018 17:58:14 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Mon, 26 Nov 2018 17:58:14 +0000 (UTC) for IP:'134.134.136.126' DOMAIN:'mga18.intel.com' HELO:'mga18.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 134.134.136.126 mga18.intel.com 134.134.136.126 mga18.intel.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.48 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: huaqiang.wang@intel.com Subject: [libvirt] [PATCHv10 2/4] util: Add function to free monitor statistical data 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.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 26 Nov 2018 17:58:22 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The call of virResctrlMonitorGetStats will allocate the memory for holding cache occupancy or memory bandwidth statistics. This patch added an function, virResctrlMonitorFreeStats, as the opposing action of virResctrlMonitorGetStats to free these memory. Signed-off-by: Wang Huaqiang Reviewed-by: John Ferlan --- src/libvirt_private.syms | 1 + src/util/virresctrl.c | 16 ++++++++++++++++ src/util/virresctrl.h | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 8889aaa..5018a13 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2692,6 +2692,7 @@ virResctrlInfoNew; virResctrlMonitorAddPID; virResctrlMonitorCreate; virResctrlMonitorDeterminePath; +virResctrlMonitorFreeStats; virResctrlMonitorGetCacheOccupancy; virResctrlMonitorGetID; virResctrlMonitorNew; diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 3268310..6ffd71f 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -2747,6 +2747,22 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monit= or, } =20 =20 +void +virResctrlMonitorFreeStats(virResctrlMonitorStatsPtr *stats, + size_t nstats) +{ + size_t i =3D 0; + + if (!stats) + return; + + for (i =3D 0; i < nstats; i++) + VIR_FREE(stats[i]); + + VIR_FREE(stats); +} + + /* * virResctrlMonitorGetCacheOccupancy * diff --git a/src/util/virresctrl.h b/src/util/virresctrl.h index e2ed4ee..8ea9758 100644 --- a/src/util/virresctrl.h +++ b/src/util/virresctrl.h @@ -231,4 +231,8 @@ int virResctrlMonitorGetCacheOccupancy(virResctrlMonitorPtr monitor, virResctrlMonitorStatsPtr **stats, size_t *nstats); + +void +virResctrlMonitorFreeStats(virResctrlMonitorStatsPtr *stats, + size_t nstats); #endif /* __VIR_RESCTRL_H__ */ --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 19 20:41:47 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=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 1543255122598959.7483087743417; Mon, 26 Nov 2018 09:58:42 -0800 (PST) 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 9B88C5277B; Mon, 26 Nov 2018 17:58:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6042E60910; Mon, 26 Nov 2018 17:58:40 +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 0FEA4181B9F6; Mon, 26 Nov 2018 17:58:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAQHwH2t003995 for ; Mon, 26 Nov 2018 12:58:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3C1519CB6; Mon, 26 Nov 2018 17:58:17 +0000 (UTC) Received: from mx1.redhat.com (ext-mx18.extmail.prod.ext.phx2.redhat.com [10.5.110.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 631F59CD2; Mon, 26 Nov 2018 17:58:16 +0000 (UTC) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (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 D62F530820CE; Mon, 26 Nov 2018 17:58:14 +0000 (UTC) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Nov 2018 09:58:14 -0800 Received: from david-unc.bj.intel.com ([10.238.145.63]) by fmsmga005.fm.intel.com with ESMTP; 26 Nov 2018 09:58:13 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,283,1539673200"; d="scan'208";a="283751549" From: Wang Huaqiang To: jferlan@redhat.com, libvir-list@redhat.com Date: Tue, 27 Nov 2018 01:56:16 +0800 Message-Id: <1543254977-23949-4-git-send-email-huaqiang.wang@intel.com> In-Reply-To: <1543254977-23949-1-git-send-email-huaqiang.wang@intel.com> References: <1543254977-23949-1-git-send-email-huaqiang.wang@intel.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 26 Nov 2018 17:58:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 26 Nov 2018 17:58:15 +0000 (UTC) for IP:'134.134.136.126' DOMAIN:'mga18.intel.com' HELO:'mga18.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 134.134.136.126 mga18.intel.com 134.134.136.126 mga18.intel.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.47 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: huaqiang.wang@intel.com Subject: [libvirt] [PATCHv10 3/4] qemu: Report cache occupancy (CMT) with domstats 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.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.29]); Mon, 26 Nov 2018 17:58:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Adding the interface in qemu to report CMT statistic information through command 'virsh domstats --cpu-total'. Below is a typical output: # virsh domstats 1 --cpu-total Domain: 'ubuntu16.04-base' ... cpu.cache.monitor.count=3D2 cpu.cache.monitor.0.name=3Dvcpus_1 cpu.cache.monitor.0.vcpus=3D1 cpu.cache.monitor.0.bank.count=3D2 cpu.cache.monitor.0.bank.0.id=3D0 cpu.cache.monitor.0.bank.0.bytes=3D4505600 cpu.cache.monitor.0.bank.1.id=3D1 cpu.cache.monitor.0.bank.1.bytes=3D5586944 cpu.cache.monitor.1.name=3Dvcpus_4-6 cpu.cache.monitor.1.vcpus=3D4,5,6 cpu.cache.monitor.1.bank.count=3D2 cpu.cache.monitor.1.bank.0.id=3D0 cpu.cache.monitor.1.bank.0.bytes=3D17571840 cpu.cache.monitor.1.bank.1.id=3D1 cpu.cache.monitor.1.bank.1.bytes=3D29106176 Signed-off-by: Wang Huaqiang Reviewed-by: John Ferlan --- src/libvirt-domain.c | 12 ++++ src/qemu/qemu_driver.c | 183 +++++++++++++++++++++++++++++++++++++++++++++= +++- tools/virsh.pod | 14 ++++ 3 files changed, 208 insertions(+), 1 deletion(-) diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 5b76458..73d602e 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -11415,6 +11415,18 @@ virConnectGetDomainCapabilities(virConnectPtr conn, * "cpu.user" - user cpu time spent in nanoseconds as unsigned long lo= ng. * "cpu.system" - system cpu time spent in nanoseconds as unsigned long * long. + * "cpu.cache.monitor.count" - the number of cache monitors for this d= omain + * "cpu.cache.monitor..name" - the name of cache monitor + * "cpu.cache.monitor..vcpus" - vcpu list of cache monitor + * "cpu.cache.monitor..bank.count" - the number of cache banks in + * cache monitor + * "cpu.cache.monitor..bank..id" - host allocated cache id= for + * bank in cache + * monitor + * "cpu.cache.monitor..bank..bytes" - the number of bytes = of + * last level cache tha= t the + * domain is using on c= ache + * bank * * VIR_DOMAIN_STATS_BALLOON: * Return memory balloon device information. diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 7fb9102..ac2be35 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -19929,6 +19929,181 @@ typedef enum { #define HAVE_JOB(flags) ((flags) & QEMU_DOMAIN_STATS_HAVE_JOB) =20 =20 +typedef struct _virQEMUResctrlMonData virQEMUResctrlMonData; +typedef virQEMUResctrlMonData *virQEMUResctrlMonDataPtr; +struct _virQEMUResctrlMonData { + char *name; + char *vcpus; + virResctrlMonitorStatsPtr *stats; + size_t nstats; +}; + + +static void +qemuDomainFreeResctrlMonData(virQEMUResctrlMonDataPtr *resdata, + size_t nresdata) +{ + size_t i =3D 0; + + for (i =3D 0; i < nresdata; i++) { + VIR_FREE(resdata[i]->name); + VIR_FREE(resdata[i]->vcpus); + virResctrlMonitorFreeStats(resdata[i]->stats, resdata[i]->nstats); + VIR_FREE(resdata[i]); + } + + VIR_FREE(resdata); +} + + +/** + * qemuDomainGetResctrlMonData: + * @dom: Pointer for the domain that the resctrl monitors reside in + * @resdata: Pointer of virQEMUResctrlMonDataPtr pointer for receiving the + * virQEMUResctrlMonDataPtr array. Caller is responsible for + * freeing the array. + * @nresdata: Pointer of size_t to report the size virQEMUResctrlMonDataPtr + * array to caller. If *@nresdata is not 0, even if function + * returns an error, the caller is also required to call + * qemuDomainFreeResctrlMonData to free the array in *@resdata + * @tag: Could be VIR_RESCTRL_MONITOR_TYPE_CACHE for getting cache statist= ics + * from @dom cache monitors. VIR_RESCTRL_MONITOR_TYPE_MEMBW for + * getting memory bandwidth statistics from memory bandwidth monitor= s. + * + * Get cache or memory bandwidth statistics from @dom monitors. + * + * Returns -1 on failure, or 0 on success. + */ +static int +qemuDomainGetResctrlMonData(virDomainObjPtr dom, + virQEMUResctrlMonDataPtr **resdata, + size_t *nresdata, + virResctrlMonitorType tag) +{ + virDomainResctrlDefPtr resctrl =3D NULL; + virQEMUResctrlMonDataPtr res =3D NULL; + size_t i =3D 0; + size_t j =3D 0; + + for (i =3D 0; i < dom->def->nresctrls; i++) { + resctrl =3D dom->def->resctrls[i]; + + for (j =3D 0; j < resctrl->nmonitors; j++) { + virDomainResctrlMonDefPtr domresmon =3D NULL; + virResctrlMonitorPtr monitor =3D NULL; + + domresmon =3D resctrl->monitors[j]; + monitor =3D domresmon->instance; + + if (domresmon->tag !=3D tag) + continue; + + if (VIR_ALLOC(res) < 0) + return -1; + + /* If virBitmapFormat successfully returns an vcpu string, then + * res.vcpus is assigned with an memory space holding it, + * let this newly allocated memory buffer to be freed along wi= th + * the free of 'res' */ + if (!(res->vcpus =3D virBitmapFormat(domresmon->vcpus))) + goto error; + + if (VIR_STRDUP(res->name, virResctrlMonitorGetID(monitor)) < 0) + goto error; + + if (virResctrlMonitorGetCacheOccupancy(monitor, + &res->stats, + &res->nstats) < 0) + goto error; + + if (VIR_APPEND_ELEMENT(*resdata, *nresdata, res) < 0) + goto error; + } + } + + return 0; + + error: + if (res) + qemuDomainFreeResctrlMonData(&res, 1); + + return -1; +} + + +static int +qemuDomainGetStatsCpuCache(virDomainObjPtr dom, + virDomainStatsRecordPtr record, + int *maxparams) +{ + char param_name[VIR_TYPED_PARAM_FIELD_LENGTH]; + virQEMUResctrlMonDataPtr *resdata =3D NULL; + size_t nresdata =3D 0; + size_t i =3D 0; + size_t j =3D 0; + int ret =3D -1; + + if (!virDomainObjIsActive(dom)) + return 0; + + if (qemuDomainGetResctrlMonData(dom, &resdata, &nresdata, + VIR_RESCTRL_MONITOR_TYPE_CACHE) < 0) + goto cleanup; + + snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, + "cpu.cache.monitor.count"); + if (virTypedParamsAddUInt(&record->params, &record->nparams, + maxparams, param_name, nresdata) < 0) + goto cleanup; + + for (i =3D 0; i < nresdata; i++) { + snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, + "cpu.cache.monitor.%zu.name", i); + if (virTypedParamsAddString(&record->params, + &record->nparams, + maxparams, + param_name, + resdata[i]->name) < 0) + goto cleanup; + + snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, + "cpu.cache.monitor.%zu.vcpus", i); + if (virTypedParamsAddString(&record->params, &record->nparams, + maxparams, param_name, + resdata[i]->vcpus) < 0) + goto cleanup; + + snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, + "cpu.cache.monitor.%zu.bank.count", i); + if (virTypedParamsAddUInt(&record->params, &record->nparams, + maxparams, param_name, + resdata[i]->nstats) < 0) + goto cleanup; + + for (j =3D 0; j < resdata[i]->nstats; j++) { + snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, + "cpu.cache.monitor.%zu.bank.%zu.id", i, j); + if (virTypedParamsAddUInt(&record->params, &record->nparams, + maxparams, param_name, + resdata[i]->stats[j]->id) < 0) + goto cleanup; + + snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, + "cpu.cache.monitor.%zu.bank.%zu.bytes", i, j); + if (virTypedParamsAddUInt(&record->params, &record->nparams, + maxparams, param_name, + resdata[i]->stats[j]->val) < 0) + goto cleanup; + } + } + + ret =3D 0; + cleanup: + qemuDomainFreeResctrlMonData(resdata, nresdata); + return ret; +} + + static int qemuDomainGetStatsCpuCgroup(virDomainObjPtr dom, virDomainStatsRecordPtr record, @@ -19976,7 +20151,13 @@ qemuDomainGetStatsCpu(virQEMUDriverPtr driver ATTR= IBUTE_UNUSED, int *maxparams, unsigned int privflags ATTRIBUTE_UNUSED) { - return qemuDomainGetStatsCpuCgroup(dom, record, maxparams); + if (qemuDomainGetStatsCpuCgroup(dom, record, maxparams) < 0) + return -1; + + if (qemuDomainGetStatsCpuCache(dom, record, maxparams) < 0) + return -1; + + return 0; } =20 =20 diff --git a/tools/virsh.pod b/tools/virsh.pod index 4876656..86a4996 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1012,6 +1012,20 @@ I<--cpu-total> returns: "cpu.time" - total cpu time spent for this domain in nanoseconds "cpu.user" - user cpu time spent in nanoseconds "cpu.system" - system cpu time spent in nanoseconds + "cpu.cache.monitor.count" - the number of cache monitors for this + domain + "cpu.cache.monitor..name" - the name of cache monitor + "cpu.cache.monitor..vcpus" - vcpu list of cache monitor + "cpu.cache.monitor..bank.count" - the number of cache banks + in cache monitor + "cpu.cache.monitor..bank..id" - host allocated cache id + for bank in + cache monitor + "cpu.cache.monitor..bank..bytes" - the number of bytes + of last level cache + that the domain is + using on cache bank + =20 I<--balloon> returns: =20 --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 19 20:41:47 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=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 1543255122662191.25062192525513; Mon, 26 Nov 2018 09:58:42 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8A6ED80F8D; Mon, 26 Nov 2018 17:58:40 +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 515E45B081; Mon, 26 Nov 2018 17:58:40 +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 053F03F606; Mon, 26 Nov 2018 17:58:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAQHwNB4004027 for ; Mon, 26 Nov 2018 12:58:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id C6E2219744; Mon, 26 Nov 2018 17:58:23 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 199B8272C1; Mon, 26 Nov 2018 17:58:17 +0000 (UTC) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (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 F31F1C036769; Mon, 26 Nov 2018 17:58:15 +0000 (UTC) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Nov 2018 09:58:15 -0800 Received: from david-unc.bj.intel.com ([10.238.145.63]) by fmsmga005.fm.intel.com with ESMTP; 26 Nov 2018 09:58:14 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,283,1539673200"; d="scan'208";a="283751561" From: Wang Huaqiang To: jferlan@redhat.com, libvir-list@redhat.com Date: Tue, 27 Nov 2018 01:56:17 +0800 Message-Id: <1543254977-23949-5-git-send-email-huaqiang.wang@intel.com> In-Reply-To: <1543254977-23949-1-git-send-email-huaqiang.wang@intel.com> References: <1543254977-23949-1-git-send-email-huaqiang.wang@intel.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 26 Nov 2018 17:58:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 26 Nov 2018 17:58:16 +0000 (UTC) for IP:'134.134.136.126' DOMAIN:'mga18.intel.com' HELO:'mga18.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 134.134.136.126 mga18.intel.com 134.134.136.126 mga18.intel.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: huaqiang.wang@intel.com Subject: [libvirt] [PATCHv10 4/4] docs: Updated news.xml for CMT 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.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 26 Nov 2018 17:58:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Wang Huaqiang Reviewed-by: John Ferlan --- docs/news.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index 4406aeb..deadb85 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -68,6 +68,18 @@ be viewed via the domain statistics. + + + qemu: Added support for CMT (Cache Monitoring Technology) + + + Introduced cache monitoring using the monitor + element in cachetune for vCPU threads. Added + interfaces to get and display the cache utilization statistics + through the command 'virsh domstats' via the + virConnectGetAllDomainStats API. + +
--=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list