From nobody Sat May 4 23:26:36 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 1542029633483176.6841832435672; Mon, 12 Nov 2018 05:33:53 -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 9DF5081DF3; Mon, 12 Nov 2018 13:33:50 +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 5E3565D736; Mon, 12 Nov 2018 13:33:50 +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 EFE3814B1D; Mon, 12 Nov 2018 13:33:49 +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 wACDXbXs019783 for ; Mon, 12 Nov 2018 08:33:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1BEFE5C578; Mon, 12 Nov 2018 13:33:37 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CB2295C5E0; Mon, 12 Nov 2018 13:33:29 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 308453082AF5; Mon, 12 Nov 2018 13:33:28 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Nov 2018 05:33:27 -0800 Received: from david-unc.bj.intel.com ([10.238.145.63]) by orsmga004.jf.intel.com with ESMTP; 12 Nov 2018 05:33:26 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,495,1534834800"; d="scan'208";a="249041220" From: Wang Huaqiang To: jferlan@redhat.com, libvir-list@redhat.com Date: Mon, 12 Nov 2018 21:31:32 +0800 Message-Id: <1542029508-25671-2-git-send-email-huaqiang.wang@intel.com> In-Reply-To: <1542029508-25671-1-git-send-email-huaqiang.wang@intel.com> References: <1542029508-25671-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.45]); Mon, 12 Nov 2018 13:33:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 12 Nov 2018 13:33:28 +0000 (UTC) for IP:'192.55.52.93' DOMAIN:'mga11.intel.com' HELO:'mga11.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -5.001 (RCVD_IN_DNSWL_HI, SPF_PASS) 192.55.52.93 mga11.intel.com 192.55.52.93 mga11.intel.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: shaohe.feng@intel.com, huaqiang.wang@intel.com, rui.zang@intel.com, jian-feng.ding@intel.com Subject: [libvirt] [PATCHv8 01/17] docs, util: Refactor schemas and virresctrl to support optional cache 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.25]); Mon, 12 Nov 2018 13:33:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Refactor schemas and virresctrl to support optional element in . Later, the monitor entry will be introduced and to be placed under . Either cache entry or monitor entry is an optional element of . An cachetune has no element is taking the default resource allocating policy defined in '/sys/fs/resctrl/schemata'. Signed-off-by: Wang Huaqiang Reviewed-by: John Ferlan --- docs/formatdomain.html.in | 4 ++-- docs/schemas/domaincommon.rng | 4 ++-- src/util/virresctrl.c | 27 +++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 269741a..8850a71 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -943,8 +943,8 @@
cache
- This element controls the allocation of CPU cache and has the - following attributes: + This optional element controls the allocation of CPU cache and= has + the following attributes:
level
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index b9ac5df..2b465be 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -956,7 +956,7 @@ - + @@ -980,7 +980,7 @@ - + diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 5d811a2..7339e9b 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -234,6 +234,11 @@ virResctrlInfoMonFree(virResctrlInfoMonPtr mon) * in case there is no allocation for that particular cache allocation (le= vel, * cache, ...) or memory allocation for particular node). * + * Allocation corresponding to root directory, /sys/fs/sysctrl/, defines t= he + * default resource allocating policy, which is created immediately after + * mounting, and owns all the tasks and cpus in the system. Cache or memory + * bandwidth resource will be shared for tasks in this allocation. + * * =3D=3D=3D=3D=3DCache allocation technology (CAT)=3D=3D=3D=3D=3D * * Since one allocation can be made for caches on different levels, the fi= rst @@ -2215,6 +2220,15 @@ virResctrlAllocDeterminePath(virResctrlAllocPtr allo= c, return -1; } =20 + /* If the allocation is empty, then the path will be SYSFS_RESCTRL_PAT= H */ + if (virResctrlAllocIsEmpty(alloc)) { + if (!alloc->path && + VIR_STRDUP(alloc->path, SYSFS_RESCTRL_PATH) < 0) + return -1; + + return 0; + } + if (!alloc->path && virAsprintf(&alloc->path, "%s/%s-%s", SYSFS_RESCTRL_PATH, machinename, alloc->id) < 0) @@ -2248,6 +2262,10 @@ virResctrlAllocCreate(virResctrlInfoPtr resctrl, if (virResctrlAllocDeterminePath(alloc, machinename) < 0) return -1; =20 + /* If using the system/default path for the allocation, then we're don= e */ + if (STREQ(alloc->path, SYSFS_RESCTRL_PATH)) + return 0; + if (virFileExists(alloc->path)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Path '%s' for resctrl allocation exists"), @@ -2302,6 +2320,11 @@ virResctrlAllocAddPID(virResctrlAllocPtr alloc, char *pidstr =3D NULL; int ret =3D 0; =20 + /* If allocation is empty, then no resctrl directory and the 'tasks' f= ile + * exists, just return */ + if (virResctrlAllocIsEmpty(alloc)) + return 0; + if (!alloc->path) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot add pid to non-existing resctrl allocatio= n")); @@ -2334,6 +2357,10 @@ virResctrlAllocRemove(virResctrlAllocPtr alloc) { int ret =3D 0; =20 + /* Do not destroy if path is the system/default path for the allocatio= n */ + if (STREQ(alloc->path, SYSFS_RESCTRL_PATH)) + return 0; + if (!alloc->path) return 0; =20 --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 23:26:36 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 1542029621169831.7849365401282; Mon, 12 Nov 2018 05:33:41 -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 465B07F3F4; Mon, 12 Nov 2018 13:33:38 +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 EFC75608F8; Mon, 12 Nov 2018 13:33:37 +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 723F814B1C; Mon, 12 Nov 2018 13:33:37 +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 wACDXZ4R019745 for ; Mon, 12 Nov 2018 08:33:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id DE0DA101963D; Mon, 12 Nov 2018 13:33:35 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 351F91019634; Mon, 12 Nov 2018 13:33:31 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 BB07CC057F80; Mon, 12 Nov 2018 13:33:29 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Nov 2018 05:33:29 -0800 Received: from david-unc.bj.intel.com ([10.238.145.63]) by orsmga004.jf.intel.com with ESMTP; 12 Nov 2018 05:33:28 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,495,1534834800"; d="scan'208";a="249041223" From: Wang Huaqiang To: jferlan@redhat.com, libvir-list@redhat.com Date: Mon, 12 Nov 2018 21:31:33 +0800 Message-Id: <1542029508-25671-3-git-send-email-huaqiang.wang@intel.com> In-Reply-To: <1542029508-25671-1-git-send-email-huaqiang.wang@intel.com> References: <1542029508-25671-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.32]); Mon, 12 Nov 2018 13:33:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 12 Nov 2018 13:33:30 +0000 (UTC) for IP:'192.55.52.93' DOMAIN:'mga11.intel.com' HELO:'mga11.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -5.001 (RCVD_IN_DNSWL_HI, SPF_PASS) 192.55.52.93 mga11.intel.com 192.55.52.93 mga11.intel.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: shaohe.feng@intel.com, huaqiang.wang@intel.com, rui.zang@intel.com, jian-feng.ding@intel.com Subject: [libvirt] [PATCHv8 02/17] util: Introduce resctrl monitor 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 12 Nov 2018 13:33:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Cache Monitoring Technology (aka CMT) provides the capability to report cache utilization information of system task. This patch introduces the concept of resctrl monitor through data structure virResctrlMonitor. Signed-off-by: Wang Huaqiang Reviewed-by: John Ferlan --- src/libvirt_private.syms | 1 + src/util/virresctrl.c | 80 ++++++++++++++++++++++++++++++++++++++++++++= ---- src/util/virresctrl.h | 9 ++++++ 3 files changed, 84 insertions(+), 6 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 335210c..d2573c5 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2680,6 +2680,7 @@ virResctrlInfoGetCache; virResctrlInfoGetMonitorPrefix; virResctrlInfoMonFree; virResctrlInfoNew; +virResctrlMonitorNew; =20 =20 # util/virrotatingfile.h diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 7339e9b..e3c84a3 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -36,9 +36,9 @@ VIR_LOG_INIT("util.virresctrl") =20 =20 /* Resctrl is short for Resource Control. It might be implemented for var= ious - * resources. Currently this supports cache allocation technology (aka CAT= ) and - * memory bandwidth allocation (aka MBA). More resources technologies may = be - * added in the future. + * resources. Currently this supports cache allocation technology (aka CAT= ), + * memory bandwidth allocation (aka MBA) and cache monitoring technology (= aka + * CMT). More resources technologies may be added in the future. */ =20 =20 @@ -105,6 +105,7 @@ typedef virResctrlAllocMemBW *virResctrlAllocMemBWPtr; /* Class definitions and initializations */ static virClassPtr virResctrlInfoClass; static virClassPtr virResctrlAllocClass; +static virClassPtr virResctrlMonitorClass; =20 =20 /* virResctrlInfo */ @@ -224,11 +225,16 @@ virResctrlInfoMonFree(virResctrlInfoMonPtr mon) } =20 =20 -/* virResctrlAlloc */ +/* virResctrlAlloc and virResctrlMonitor*/ =20 /* - * virResctrlAlloc represents one allocation (in XML under cputune/cachetu= ne and - * consequently a directory under /sys/fs/resctrl). Since it can have mul= tiple + * virResctrlAlloc and virResctrlMonitor are representing a resource contr= ol + * group (in XML under cputune/cachetune and consequently a directory under + * /sys/fs/resctrl). virResctrlAlloc is the data structure for resource + * allocation, while the virResctrlMonitor represents the resource monitor= ing + * part. + * + * virResctrlAlloc represents one allocation. Since it can have multiple * parts of multiple caches allocated it is represented as bunch of nested * sparse arrays (by sparse I mean array of pointers so that each might be= NULL * in case there is no allocation for that particular cache allocation (le= vel, @@ -275,6 +281,18 @@ virResctrlInfoMonFree(virResctrlInfoMonPtr mon) * a sparse array to represent whether a memory bandwidth allocation happe= ns * on corresponding node. The available memory controller number is collec= ted * in 'virResctrlInfo'. + * + * =3D=3D=3D=3D=3DCache monitoring technology (CMT)=3D=3D=3D=3D=3D + * + * Cache monitoring technology is used to perceive how many cache the proc= ess + * is using actually. virResctrlMonitor represents the resource control + * monitoring group, it is supported to monitor resource utilization + * information on granularity of vcpu. + * + * From hardware perspective, cache monitoring technology (CMT), memory + * bandwidth technology (MBM), as well as the CAT and MBA, are all orthogo= nal + * features. The monitor will be created under the scope of default resctrl + * group if no specific CAT or MBA entries are provided for the guest." */ struct _virResctrlAllocPerType { /* There could be bool saying whether this is set or not, but since ev= erything @@ -320,6 +338,30 @@ struct _virResctrlAlloc { char *path; }; =20 +/* + * virResctrlMonitor is the data structure for resctrl monitor. Resctrl + * monitor represents a resctrl monitoring group, which can be used to + * monitor the resource utilization information for either cache or + * memory bandwidth. + */ +struct _virResctrlMonitor { + virObject parent; + + /* Each virResctrlMonitor is associated with one specific allocation, + * either the root directory allocation under /sys/fs/resctrl or a + * specific allocation defined under the root directory. + * This pointer points to the allocation this monitor is associated wi= th. + */ + virResctrlAllocPtr alloc; + /* The monitor identifier. For a monitor has the same @path name as its + * @alloc, the @id will be set to the same value as it is in @alloc->i= d. + */ + char *id; + /* libvirt-generated path in /sys/fs/resctrl for this particular + * monitor */ + char *path; +}; + =20 static void virResctrlAllocDispose(void *obj) @@ -369,6 +411,17 @@ virResctrlAllocDispose(void *obj) } =20 =20 +static void +virResctrlMonitorDispose(void *obj) +{ + virResctrlMonitorPtr monitor =3D obj; + + virObjectUnref(monitor->alloc); + VIR_FREE(monitor->id); + VIR_FREE(monitor->path); +} + + /* Global initialization for classes */ static int virResctrlOnceInit(void) @@ -379,6 +432,9 @@ virResctrlOnceInit(void) if (!VIR_CLASS_NEW(virResctrlAlloc, virClassForObject())) return -1; =20 + if (!VIR_CLASS_NEW(virResctrlMonitor, virClassForObject())) + return -1; + return 0; } =20 @@ -2372,3 +2428,15 @@ virResctrlAllocRemove(virResctrlAllocPtr alloc) =20 return ret; } + + +/* virResctrlMonitor-related definitions */ + +virResctrlMonitorPtr +virResctrlMonitorNew(void) +{ + if (virResctrlInitialize() < 0) + return NULL; + + return virObjectNew(virResctrlMonitorClass); +} diff --git a/src/util/virresctrl.h b/src/util/virresctrl.h index 10505e9..eaa077d 100644 --- a/src/util/virresctrl.h +++ b/src/util/virresctrl.h @@ -185,4 +185,13 @@ int virResctrlInfoGetMonitorPrefix(virResctrlInfoPtr resctrl, const char *prefix, virResctrlInfoMonPtr *monitor); + +/* Monitor-related things */ + +typedef struct _virResctrlMonitor virResctrlMonitor; +typedef virResctrlMonitor *virResctrlMonitorPtr; + + +virResctrlMonitorPtr +virResctrlMonitorNew(void); #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 Sat May 4 23:26:36 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 1542029665708154.51383085109705; Mon, 12 Nov 2018 05:34:25 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A07C731524C9; Mon, 12 Nov 2018 13:34:23 +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 DEE6E1974D; Mon, 12 Nov 2018 13:34:22 +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 8A168181B9E7; Mon, 12 Nov 2018 13:34:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wACDXc4Q019859 for ; Mon, 12 Nov 2018 08:33:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id E9ADD5D977; Mon, 12 Nov 2018 13:33:38 +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 BFD235D968; Mon, 12 Nov 2018 13:33:34 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 C413CC070137; Mon, 12 Nov 2018 13:33:31 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Nov 2018 05:33:31 -0800 Received: from david-unc.bj.intel.com ([10.238.145.63]) by orsmga004.jf.intel.com with ESMTP; 12 Nov 2018 05:33:29 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,495,1534834800"; d="scan'208";a="249041227" From: Wang Huaqiang To: jferlan@redhat.com, libvir-list@redhat.com Date: Mon, 12 Nov 2018 21:31:34 +0800 Message-Id: <1542029508-25671-4-git-send-email-huaqiang.wang@intel.com> In-Reply-To: <1542029508-25671-1-git-send-email-huaqiang.wang@intel.com> References: <1542029508-25671-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, 12 Nov 2018 13:33:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 12 Nov 2018 13:33:32 +0000 (UTC) for IP:'192.55.52.93' DOMAIN:'mga11.intel.com' HELO:'mga11.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -5.001 (RCVD_IN_DNSWL_HI, SPF_PASS) 192.55.52.93 mga11.intel.com 192.55.52.93 mga11.intel.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: shaohe.feng@intel.com, huaqiang.wang@intel.com, rui.zang@intel.com, jian-feng.ding@intel.com Subject: [libvirt] [PATCHv8 03/17] util: Refactor code for determining allocation path 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 12 Nov 2018 13:34:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The code for determining resctrl allocation path could be reused for monitor. Refactor it for reuse. Signed-off-by: Wang Huaqiang Reviewed-by: John Ferlan --- src/util/virresctrl.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index e3c84a3..463555c 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -2266,28 +2266,50 @@ virResctrlAllocAssign(virResctrlInfoPtr resctrl, } =20 =20 +static char * +virResctrlDeterminePath(const char *parentpath, + const char *prefix, + const char *id) +{ + char *path =3D NULL; + + if (!id) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Resctrl ID must be set before determining resctr= l " + "parentpath=3D'%s' prefix=3D'%s'"), parentpath, p= refix); + return NULL; + } + + if (virAsprintf(&path, "%s/%s-%s", parentpath, prefix, id) < 0) + return NULL; + + return path; +} + + int virResctrlAllocDeterminePath(virResctrlAllocPtr alloc, const char *machinename) { - if (!alloc->id) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Resctrl Allocation ID must be set before creatio= n")); + if (alloc->path) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Resctrl allocation path is already set to '%s'"), + alloc->path); return -1; } =20 /* If the allocation is empty, then the path will be SYSFS_RESCTRL_PAT= H */ if (virResctrlAllocIsEmpty(alloc)) { - if (!alloc->path && - VIR_STRDUP(alloc->path, SYSFS_RESCTRL_PATH) < 0) + if (VIR_STRDUP(alloc->path, SYSFS_RESCTRL_PATH) < 0) return -1; =20 return 0; } =20 - if (!alloc->path && - virAsprintf(&alloc->path, "%s/%s-%s", - SYSFS_RESCTRL_PATH, machinename, alloc->id) < 0) + alloc->path =3D virResctrlDeterminePath(SYSFS_RESCTRL_PATH, + machinename, alloc->id); + + if (!alloc->path) return -1; =20 return 0; --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 23:26:36 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 1542029644465899.8329608699014; Mon, 12 Nov 2018 05:34:04 -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 4419831256A1; Mon, 12 Nov 2018 13:34:02 +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 01D915D9D6; Mon, 12 Nov 2018 13:34:02 +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 A31FE181A134; Mon, 12 Nov 2018 13:34:01 +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 wACDXbEs019791 for ; Mon, 12 Nov 2018 08:33:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3F78D600D6; Mon, 12 Nov 2018 13:33:37 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 354EC600C6; Mon, 12 Nov 2018 13:33:35 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 4B40C2D805; Mon, 12 Nov 2018 13:33:34 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Nov 2018 05:33:33 -0800 Received: from david-unc.bj.intel.com ([10.238.145.63]) by orsmga004.jf.intel.com with ESMTP; 12 Nov 2018 05:33:31 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,495,1534834800"; d="scan'208";a="249041231" From: Wang Huaqiang To: jferlan@redhat.com, libvir-list@redhat.com Date: Mon, 12 Nov 2018 21:31:35 +0800 Message-Id: <1542029508-25671-5-git-send-email-huaqiang.wang@intel.com> In-Reply-To: <1542029508-25671-1-git-send-email-huaqiang.wang@intel.com> References: <1542029508-25671-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.30]); Mon, 12 Nov 2018 13:33:34 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 12 Nov 2018 13:33:34 +0000 (UTC) for IP:'192.55.52.93' DOMAIN:'mga11.intel.com' HELO:'mga11.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -5.001 (RCVD_IN_DNSWL_HI, SPF_PASS) 192.55.52.93 mga11.intel.com 192.55.52.93 mga11.intel.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: shaohe.feng@intel.com, huaqiang.wang@intel.com, rui.zang@intel.com, jian-feng.ding@intel.com Subject: [libvirt] [PATCHv8 04/17] util: Add interface to determine monitor path 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.46]); Mon, 12 Nov 2018 13:34:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add interface for resctrl monitor to determine the path. Signed-off-by: Wang Huaqiang Reviewed-by: John Ferlan --- src/libvirt_private.syms | 1 + src/util/virresctrl.c | 55 ++++++++++++++++++++++++++++++++++++++++++++= ++++ src/util/virresctrl.h | 5 ++++- 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index d2573c5..5235046 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2680,6 +2680,7 @@ virResctrlInfoGetCache; virResctrlInfoGetMonitorPrefix; virResctrlInfoMonFree; virResctrlInfoNew; +virResctrlMonitorDeterminePath; virResctrlMonitorNew; =20 =20 diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 463555c..aa062c3 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -2462,3 +2462,58 @@ virResctrlMonitorNew(void) =20 return virObjectNew(virResctrlMonitorClass); } + + +/* + * virResctrlMonitorDeterminePath + * + * @monitor: Pointer to a resctrl monitor + * @machinename: Name string of the VM + * + * Determines the directory path that the underlying resctrl group will be + * created with. + * + * A monitor represents a directory under resource control file system, + * its directory path could be the same path as @monitor->alloc, could be a + * path of directory under 'mon_groups' of @monitor->alloc, or a path of + * directory under '/sys/fs/resctrl/mon_groups' if @monitor->alloc is NULL. + * + * Returns 0 on success, -1 on error. + */ +int +virResctrlMonitorDeterminePath(virResctrlMonitorPtr monitor, + const char *machinename) +{ + VIR_AUTOFREE(char *) parentpath =3D NULL; + + if (!monitor) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Invalid resctrl monitor")); + return -1; + } + + if (monitor->path) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Resctrl monitor path is already set to '%s'"), + monitor->path); + return -1; + } + + if (monitor->id && monitor->alloc && monitor->alloc->id) { + if (STREQ(monitor->id, monitor->alloc->id)) { + if (VIR_STRDUP(monitor->path, monitor->alloc->path) < 0) + return -1; + return 0; + } + } + + if (virAsprintf(&parentpath, "%s/mon_groups", monitor->alloc->path) < = 0) + return -1; + + monitor->path =3D virResctrlDeterminePath(parentpath, machinename, + monitor->id); + if (!monitor->path) + return -1; + + return 0; +} diff --git a/src/util/virresctrl.h b/src/util/virresctrl.h index eaa077d..baae554 100644 --- a/src/util/virresctrl.h +++ b/src/util/virresctrl.h @@ -191,7 +191,10 @@ virResctrlInfoGetMonitorPrefix(virResctrlInfoPtr resct= rl, typedef struct _virResctrlMonitor virResctrlMonitor; typedef virResctrlMonitor *virResctrlMonitorPtr; =20 - virResctrlMonitorPtr virResctrlMonitorNew(void); + +int +virResctrlMonitorDeterminePath(virResctrlMonitorPtr monitor, + const char *machinename); #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 Sat May 4 23:26:36 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 1542029667602953.6995616786929; Mon, 12 Nov 2018 05:34:27 -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 6D67F4E916; Mon, 12 Nov 2018 13:34:25 +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 354E25D736; Mon, 12 Nov 2018 13:34:25 +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 C084214B1E; Mon, 12 Nov 2018 13:34:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wACDXcDO019858 for ; Mon, 12 Nov 2018 08:33:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id E93295D970; Mon, 12 Nov 2018 13:33:38 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A1B3C5D96F; Mon, 12 Nov 2018 13:33:37 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 D5CA23082A30; Mon, 12 Nov 2018 13:33:35 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Nov 2018 05:33:35 -0800 Received: from david-unc.bj.intel.com ([10.238.145.63]) by orsmga004.jf.intel.com with ESMTP; 12 Nov 2018 05:33:33 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,495,1534834800"; d="scan'208";a="249041238" From: Wang Huaqiang To: jferlan@redhat.com, libvir-list@redhat.com Date: Mon, 12 Nov 2018 21:31:36 +0800 Message-Id: <1542029508-25671-6-git-send-email-huaqiang.wang@intel.com> In-Reply-To: <1542029508-25671-1-git-send-email-huaqiang.wang@intel.com> References: <1542029508-25671-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.45]); Mon, 12 Nov 2018 13:33:36 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 12 Nov 2018 13:33:36 +0000 (UTC) for IP:'192.55.52.93' DOMAIN:'mga11.intel.com' HELO:'mga11.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -5.001 (RCVD_IN_DNSWL_HI, SPF_PASS) 192.55.52.93 mga11.intel.com 192.55.52.93 mga11.intel.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: shaohe.feng@intel.com, huaqiang.wang@intel.com, rui.zang@intel.com, jian-feng.ding@intel.com Subject: [libvirt] [PATCHv8 05/17] util: Refactor code for adding PID to the resource group 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.38]); Mon, 12 Nov 2018 13:34:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The code of adding PID to the allocation could be reused, refactor it for later reuse. Signed-off-by: Wang Huaqiang Reviewed-by: John Ferlan --- src/util/virresctrl.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index aa062c3..0bac032 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -2390,26 +2390,21 @@ virResctrlAllocCreate(virResctrlInfoPtr resctrl, } =20 =20 -int -virResctrlAllocAddPID(virResctrlAllocPtr alloc, - pid_t pid) +static int +virResctrlAddPID(const char *path, + pid_t pid) { char *tasks =3D NULL; char *pidstr =3D NULL; int ret =3D 0; =20 - /* If allocation is empty, then no resctrl directory and the 'tasks' f= ile - * exists, just return */ - if (virResctrlAllocIsEmpty(alloc)) - return 0; - - if (!alloc->path) { + if (!path) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot add pid to non-existing resctrl allocatio= n")); + _("Cannot add pid to non-existing resctrl group")); return -1; } =20 - if (virAsprintf(&tasks, "%s/tasks", alloc->path) < 0) + if (virAsprintf(&tasks, "%s/tasks", path) < 0) return -1; =20 if (virAsprintf(&pidstr, "%lld", (long long int) pid) < 0) @@ -2431,6 +2426,19 @@ virResctrlAllocAddPID(virResctrlAllocPtr alloc, =20 =20 int +virResctrlAllocAddPID(virResctrlAllocPtr alloc, + pid_t pid) +{ + /* If allocation is empty, then no resctrl directory and the 'tasks' f= ile + * exists, just return */ + if (virResctrlAllocIsEmpty(alloc)) + return 0; + + return virResctrlAddPID(alloc->path, pid); +} + + +int virResctrlAllocRemove(virResctrlAllocPtr alloc) { int ret =3D 0; --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 23:26:36 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 1542029655877522.6630362108032; Mon, 12 Nov 2018 05:34:15 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D6CEA804EC; Mon, 12 Nov 2018 13:34:13 +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 93C5219940; Mon, 12 Nov 2018 13:34:13 +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 2E860181B9E3; Mon, 12 Nov 2018 13:34:13 +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 wACDXce8019846 for ; Mon, 12 Nov 2018 08:33:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id A8A01101963E; Mon, 12 Nov 2018 13:33:38 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 94AEE101963D; Mon, 12 Nov 2018 13:33:38 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 700CC3082AF5; Mon, 12 Nov 2018 13:33:37 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Nov 2018 05:33:37 -0800 Received: from david-unc.bj.intel.com ([10.238.145.63]) by orsmga004.jf.intel.com with ESMTP; 12 Nov 2018 05:33:35 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,495,1534834800"; d="scan'208";a="249041241" From: Wang Huaqiang To: jferlan@redhat.com, libvir-list@redhat.com Date: Mon, 12 Nov 2018 21:31:37 +0800 Message-Id: <1542029508-25671-7-git-send-email-huaqiang.wang@intel.com> In-Reply-To: <1542029508-25671-1-git-send-email-huaqiang.wang@intel.com> References: <1542029508-25671-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.45]); Mon, 12 Nov 2018 13:33:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 12 Nov 2018 13:33:37 +0000 (UTC) for IP:'192.55.52.93' DOMAIN:'mga11.intel.com' HELO:'mga11.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -5.001 (RCVD_IN_DNSWL_HI, SPF_PASS) 192.55.52.93 mga11.intel.com 192.55.52.93 mga11.intel.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: shaohe.feng@intel.com, huaqiang.wang@intel.com, rui.zang@intel.com, jian-feng.ding@intel.com Subject: [libvirt] [PATCHv8 06/17] util: Add interface for adding PID to the monitor 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 12 Nov 2018 13:34:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add interface for adding task PID to the monitor. Signed-off-by: Wang Huaqiang Reviewed-by: John Ferlan --- src/libvirt_private.syms | 1 + src/util/virresctrl.c | 8 ++++++++ src/util/virresctrl.h | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 5235046..e175c8b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2680,6 +2680,7 @@ virResctrlInfoGetCache; virResctrlInfoGetMonitorPrefix; virResctrlInfoMonFree; virResctrlInfoNew; +virResctrlMonitorAddPID; virResctrlMonitorDeterminePath; virResctrlMonitorNew; =20 diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 0bac032..7bd52cd 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -2525,3 +2525,11 @@ virResctrlMonitorDeterminePath(virResctrlMonitorPtr = monitor, =20 return 0; } + + +int +virResctrlMonitorAddPID(virResctrlMonitorPtr monitor, + pid_t pid) +{ + return virResctrlAddPID(monitor->path, pid); +} diff --git a/src/util/virresctrl.h b/src/util/virresctrl.h index baae554..52d283a 100644 --- a/src/util/virresctrl.h +++ b/src/util/virresctrl.h @@ -197,4 +197,8 @@ virResctrlMonitorNew(void); int virResctrlMonitorDeterminePath(virResctrlMonitorPtr monitor, const char *machinename); + +int +virResctrlMonitorAddPID(virResctrlMonitorPtr monitor, + pid_t pid); #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 Sat May 4 23:26:36 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 1542029680433468.57187035429286; Mon, 12 Nov 2018 05:34:40 -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 5701630832E3; Mon, 12 Nov 2018 13:34:38 +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 DE641600C1; Mon, 12 Nov 2018 13:34:37 +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 177A4181A134; Mon, 12 Nov 2018 13:34:37 +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 wACDXikq019913 for ; Mon, 12 Nov 2018 08:33:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id C709E19940; Mon, 12 Nov 2018 13:33:44 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 949D219743; Mon, 12 Nov 2018 13:33:40 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 3A3A13082AF5; Mon, 12 Nov 2018 13:33:39 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Nov 2018 05:33:39 -0800 Received: from david-unc.bj.intel.com ([10.238.145.63]) by orsmga004.jf.intel.com with ESMTP; 12 Nov 2018 05:33:37 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,495,1534834800"; d="scan'208";a="249041260" From: Wang Huaqiang To: jferlan@redhat.com, libvir-list@redhat.com Date: Mon, 12 Nov 2018 21:31:38 +0800 Message-Id: <1542029508-25671-8-git-send-email-huaqiang.wang@intel.com> In-Reply-To: <1542029508-25671-1-git-send-email-huaqiang.wang@intel.com> References: <1542029508-25671-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.45]); Mon, 12 Nov 2018 13:33:39 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 12 Nov 2018 13:33:39 +0000 (UTC) for IP:'192.55.52.93' DOMAIN:'mga11.intel.com' HELO:'mga11.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -5.001 (RCVD_IN_DNSWL_HI, SPF_PASS) 192.55.52.93 mga11.intel.com 192.55.52.93 mga11.intel.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: shaohe.feng@intel.com, huaqiang.wang@intel.com, rui.zang@intel.com, jian-feng.ding@intel.com Subject: [libvirt] [PATCHv8 07/17] util: Refactor code for creating resctrl group 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.44]); Mon, 12 Nov 2018 13:34:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The code for creating resctrl allocation group could be reused for monitoring group, refactor it for reuse in the later patch. Signed-off-by: Wang Huaqiang Reviewed-by: John Ferlan --- src/util/virresctrl.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 7bd52cd..94689dd 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -2316,6 +2316,26 @@ virResctrlAllocDeterminePath(virResctrlAllocPtr allo= c, } =20 =20 +/* This function creates a resctrl directory in resource control file syst= em, + * and the directory path is specified by @path. */ +static int +virResctrlCreateGroupPath(const char *path) +{ + /* Directory exists, return */ + if (virFileExists(path)) + return 0; + + if (virFileMakePath(path) < 0) { + virReportSystemError(errno, + _("Cannot create resctrl directory '%s'"), + path); + return -1; + } + + return 0; +} + + /* This checks if the directory for the alloc exists. If not it tries to = create * it and apply appropriate alloc settings. */ int @@ -2344,13 +2364,6 @@ virResctrlAllocCreate(virResctrlInfoPtr resctrl, if (STREQ(alloc->path, SYSFS_RESCTRL_PATH)) return 0; =20 - if (virFileExists(alloc->path)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Path '%s' for resctrl allocation exists"), - alloc->path); - goto cleanup; - } - lockfd =3D virResctrlLockWrite(); if (lockfd < 0) goto cleanup; @@ -2358,6 +2371,9 @@ virResctrlAllocCreate(virResctrlInfoPtr resctrl, if (virResctrlAllocAssign(resctrl, alloc) < 0) goto cleanup; =20 + if (virResctrlCreateGroupPath(alloc->path) < 0) + goto cleanup; + alloc_str =3D virResctrlAllocFormat(alloc); if (!alloc_str) goto cleanup; @@ -2365,13 +2381,6 @@ virResctrlAllocCreate(virResctrlInfoPtr resctrl, if (virAsprintf(&schemata_path, "%s/schemata", alloc->path) < 0) goto cleanup; =20 - if (virFileMakePath(alloc->path) < 0) { - virReportSystemError(errno, - _("Cannot create resctrl directory '%s'"), - alloc->path); - goto cleanup; - } - VIR_DEBUG("Writing resctrl schemata '%s' into '%s'", alloc_str, schema= ta_path); if (virFileWriteStr(schemata_path, alloc_str, 0) < 0) { rmdir(alloc->path); --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 23:26:36 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 1542029677088768.1293939236557; Mon, 12 Nov 2018 05:34:37 -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 3BC5689AE8; Mon, 12 Nov 2018 13:34:35 +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 CD24E6090A; Mon, 12 Nov 2018 13:34:34 +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 81CD6181A133; Mon, 12 Nov 2018 13:34:34 +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 wACDXgTS019898 for ; Mon, 12 Nov 2018 08:33:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3A8E96015E; Mon, 12 Nov 2018 13:33:42 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2835C600D7; Mon, 12 Nov 2018 13:33:42 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 074923082A34; Mon, 12 Nov 2018 13:33:41 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Nov 2018 05:33:40 -0800 Received: from david-unc.bj.intel.com ([10.238.145.63]) by orsmga004.jf.intel.com with ESMTP; 12 Nov 2018 05:33:39 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,495,1534834800"; d="scan'208";a="249041269" From: Wang Huaqiang To: jferlan@redhat.com, libvir-list@redhat.com Date: Mon, 12 Nov 2018 21:31:39 +0800 Message-Id: <1542029508-25671-9-git-send-email-huaqiang.wang@intel.com> In-Reply-To: <1542029508-25671-1-git-send-email-huaqiang.wang@intel.com> References: <1542029508-25671-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.45]); Mon, 12 Nov 2018 13:33:41 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 12 Nov 2018 13:33:41 +0000 (UTC) for IP:'192.55.52.93' DOMAIN:'mga11.intel.com' HELO:'mga11.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -5.001 (RCVD_IN_DNSWL_HI, SPF_PASS) 192.55.52.93 mga11.intel.com 192.55.52.93 mga11.intel.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: shaohe.feng@intel.com, huaqiang.wang@intel.com, rui.zang@intel.com, jian-feng.ding@intel.com Subject: [libvirt] [PATCHv8 08/17] util: Add interface for creating monitor group 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.26]); Mon, 12 Nov 2018 13:34:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add interface for creating the resource monitoring group according to '@virResctrlMonitor->path'. Signed-off-by: Wang Huaqiang Reviewed-by: John Ferlan --- src/libvirt_private.syms | 1 + src/util/virresctrl.c | 24 ++++++++++++++++++++++++ src/util/virresctrl.h | 4 ++++ 3 files changed, 29 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index e175c8b..a878083 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2681,6 +2681,7 @@ virResctrlInfoGetMonitorPrefix; virResctrlInfoMonFree; virResctrlInfoNew; virResctrlMonitorAddPID; +virResctrlMonitorCreate; virResctrlMonitorDeterminePath; virResctrlMonitorNew; =20 diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 94689dd..3216abe 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -2542,3 +2542,27 @@ virResctrlMonitorAddPID(virResctrlMonitorPtr monitor, { return virResctrlAddPID(monitor->path, pid); } + + +int +virResctrlMonitorCreate(virResctrlMonitorPtr monitor, + const char *machinename) +{ + int lockfd =3D -1; + int ret =3D -1; + + if (!monitor) + return 0; + + if (virResctrlMonitorDeterminePath(monitor, machinename) < 0) + return -1; + + lockfd =3D virResctrlLockWrite(); + if (lockfd < 0) + return -1; + + ret =3D virResctrlCreateGroupPath(monitor->path); + + virResctrlUnlock(lockfd); + return ret; +} diff --git a/src/util/virresctrl.h b/src/util/virresctrl.h index 52d283a..76e40a2 100644 --- a/src/util/virresctrl.h +++ b/src/util/virresctrl.h @@ -201,4 +201,8 @@ virResctrlMonitorDeterminePath(virResctrlMonitorPtr mon= itor, int virResctrlMonitorAddPID(virResctrlMonitorPtr monitor, pid_t pid); + +int +virResctrlMonitorCreate(virResctrlMonitorPtr monitor, + const char *machinename); #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 Sat May 4 23:26:36 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 154202963569964.54218395890291; Mon, 12 Nov 2018 05:33:55 -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 9B1683082E4F; Mon, 12 Nov 2018 13:33:53 +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 54423600D6; Mon, 12 Nov 2018 13:33:53 +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 EF1C6181A968; Mon, 12 Nov 2018 13:33:52 +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 wACDXiN2019908 for ; Mon, 12 Nov 2018 08:33:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5C500101E597; Mon, 12 Nov 2018 13:33:44 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4E9F0101963F; Mon, 12 Nov 2018 13:33:44 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 CFA8F3082A34; Mon, 12 Nov 2018 13:33:42 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Nov 2018 05:33:42 -0800 Received: from david-unc.bj.intel.com ([10.238.145.63]) by orsmga004.jf.intel.com with ESMTP; 12 Nov 2018 05:33:41 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,495,1534834800"; d="scan'208";a="249041281" From: Wang Huaqiang To: jferlan@redhat.com, libvir-list@redhat.com Date: Mon, 12 Nov 2018 21:31:40 +0800 Message-Id: <1542029508-25671-10-git-send-email-huaqiang.wang@intel.com> In-Reply-To: <1542029508-25671-1-git-send-email-huaqiang.wang@intel.com> References: <1542029508-25671-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.45]); Mon, 12 Nov 2018 13:33:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 12 Nov 2018 13:33:43 +0000 (UTC) for IP:'192.55.52.93' DOMAIN:'mga11.intel.com' HELO:'mga11.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -5.001 (RCVD_IN_DNSWL_HI, SPF_PASS) 192.55.52.93 mga11.intel.com 192.55.52.93 mga11.intel.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: shaohe.feng@intel.com, huaqiang.wang@intel.com, rui.zang@intel.com, jian-feng.ding@intel.com Subject: [libvirt] [PATCHv8 09/17] util: Refactor virResctrlAllocSetID to set allocation ID 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.46]); Mon, 12 Nov 2018 13:33:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Refactor virResctrlAllocSetID. In new code the error of id overwriting is reported promptly. Signed-off-by: Wang Huaqiang Reviewed-by: John Ferlan --- src/util/virresctrl.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 3216abe..4e4831c 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -1361,17 +1361,32 @@ virResctrlAllocForeachMemory(virResctrlAllocPtr all= oc, } =20 =20 -int -virResctrlAllocSetID(virResctrlAllocPtr alloc, - const char *id) +static int +virResctrlSetID(char **resctrlid, + const char *id) { if (!id) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Resctrl allocation 'id' cannot be NULL")); + _("New resctrl 'id' cannot be NULL")); + return -1; + } + + if (*resctrlid) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Attempt to overwrite resctrlid=3D'%s' with id=3D= '%s'"), + *resctrlid, id); return -1; } =20 - return VIR_STRDUP(alloc->id, id); + return VIR_STRDUP(*resctrlid, id); +} + + +int +virResctrlAllocSetID(virResctrlAllocPtr alloc, + const char *id) +{ + return virResctrlSetID(&alloc->id, id); } =20 =20 --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 23:26:36 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 1542029689378856.8807725972872; Mon, 12 Nov 2018 05:34:49 -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 95300C059B73; Mon, 12 Nov 2018 13:34:47 +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 5E2455D75F; Mon, 12 Nov 2018 13:34:47 +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 03C6F14B1F; Mon, 12 Nov 2018 13:34:47 +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 wACDXj00019919 for ; Mon, 12 Nov 2018 08:33:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id C15276013F; Mon, 12 Nov 2018 13:33:45 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B2F30600D6; Mon, 12 Nov 2018 13:33:45 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 980643082A34; Mon, 12 Nov 2018 13:33:44 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Nov 2018 05:33:44 -0800 Received: from david-unc.bj.intel.com ([10.238.145.63]) by orsmga004.jf.intel.com with ESMTP; 12 Nov 2018 05:33:42 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,495,1534834800"; d="scan'208";a="249041288" From: Wang Huaqiang To: jferlan@redhat.com, libvir-list@redhat.com Date: Mon, 12 Nov 2018 21:31:41 +0800 Message-Id: <1542029508-25671-11-git-send-email-huaqiang.wang@intel.com> In-Reply-To: <1542029508-25671-1-git-send-email-huaqiang.wang@intel.com> References: <1542029508-25671-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.45]); Mon, 12 Nov 2018 13:33:44 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 12 Nov 2018 13:33:44 +0000 (UTC) for IP:'192.55.52.93' DOMAIN:'mga11.intel.com' HELO:'mga11.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -5.001 (RCVD_IN_DNSWL_HI, SPF_PASS) 192.55.52.93 mga11.intel.com 192.55.52.93 mga11.intel.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: shaohe.feng@intel.com, huaqiang.wang@intel.com, rui.zang@intel.com, jian-feng.ding@intel.com Subject: [libvirt] [PATCHv8 10/17] util: Add interface for setting monitor ID. 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.32]); Mon, 12 Nov 2018 13:34:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add virResctrlMonitorSetID by leveraging previous refactored patch. Signed-off-by: Wang Huaqiang Reviewed-by: John Ferlan --- src/util/virresctrl.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 4e4831c..ed682c9 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -2581,3 +2581,12 @@ virResctrlMonitorCreate(virResctrlMonitorPtr monitor, virResctrlUnlock(lockfd); return ret; } + + +int +virResctrlMonitorSetID(virResctrlMonitorPtr monitor, + const char *id) + +{ + return virResctrlSetID(&monitor->id, id); +} --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 23:26:36 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 1542029647700514.8223208056595; Mon, 12 Nov 2018 05:34:07 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E17BE804E0; Mon, 12 Nov 2018 13:34:04 +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 A8D8A101962F; Mon, 12 Nov 2018 13:34:04 +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 4975C14B1E; Mon, 12 Nov 2018 13:34:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wACDXoni019945 for ; Mon, 12 Nov 2018 08:33:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id B71D160C6D; Mon, 12 Nov 2018 13:33:50 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0249060C6C; Mon, 12 Nov 2018 13:33:47 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 6CFF53082A43; Mon, 12 Nov 2018 13:33:46 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Nov 2018 05:33:46 -0800 Received: from david-unc.bj.intel.com ([10.238.145.63]) by orsmga004.jf.intel.com with ESMTP; 12 Nov 2018 05:33:44 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,495,1534834800"; d="scan'208";a="249041293" From: Wang Huaqiang To: jferlan@redhat.com, libvir-list@redhat.com Date: Mon, 12 Nov 2018 21:31:42 +0800 Message-Id: <1542029508-25671-12-git-send-email-huaqiang.wang@intel.com> In-Reply-To: <1542029508-25671-1-git-send-email-huaqiang.wang@intel.com> References: <1542029508-25671-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.45]); Mon, 12 Nov 2018 13:33:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 12 Nov 2018 13:33:46 +0000 (UTC) for IP:'192.55.52.93' DOMAIN:'mga11.intel.com' HELO:'mga11.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -5.001 (RCVD_IN_DNSWL_HI, SPF_PASS) 192.55.52.93 mga11.intel.com 192.55.52.93 mga11.intel.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: shaohe.feng@intel.com, huaqiang.wang@intel.com, rui.zang@intel.com, jian-feng.ding@intel.com Subject: [libvirt] [PATCHv8 11/17] util: Add more interfaces for resctrl monitor 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 12 Nov 2018 13:34:05 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add interfaces monitor group to support operations such as add PID, get ID, remove group ... etc. Signed-off-by: Wang Huaqiang Reviewed-by: John Ferlan --- src/libvirt_private.syms | 5 ++ src/util/virresctrl.c | 167 +++++++++++++++++++++++++++++++++++++++++++= ++++ src/util/virresctrl.h | 26 ++++++++ 3 files changed, 198 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index a878083..2938833 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2683,7 +2683,12 @@ virResctrlInfoNew; virResctrlMonitorAddPID; virResctrlMonitorCreate; virResctrlMonitorDeterminePath; +virResctrlMonitorGetCacheOccupancy; +virResctrlMonitorGetID; virResctrlMonitorNew; +virResctrlMonitorRemove; +virResctrlMonitorSetAlloc; +virResctrlMonitorSetID; =20 =20 # util/virrotatingfile.h diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index ed682c9..9e7de62 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -2590,3 +2590,170 @@ virResctrlMonitorSetID(virResctrlMonitorPtr monitor, { return virResctrlSetID(&monitor->id, id); } + + +const char * +virResctrlMonitorGetID(virResctrlMonitorPtr monitor) +{ + return monitor->id; +} + + +void +virResctrlMonitorSetAlloc(virResctrlMonitorPtr monitor, + virResctrlAllocPtr alloc) +{ + monitor->alloc =3D virObjectRef(alloc); +} + + +int +virResctrlMonitorRemove(virResctrlMonitorPtr monitor) +{ + int ret =3D 0; + + if (!monitor->path) + return 0; + + if (STREQ(monitor->path, monitor->alloc->path)) + return 0; + + VIR_DEBUG("Removing resctrl monitor path=3D%s", monitor->path); + if (rmdir(monitor->path) !=3D 0 && errno !=3D ENOENT) { + ret =3D -errno; + VIR_ERROR(_("Unable to remove %s (%d)"), monitor->path, errno); + } + + return ret; +} + + +static int +virResctrlMonitorStatsSorter(const void *a, + const void *b) +{ + return ((virResctrlMonitorStatsPtr)a)->id + - ((virResctrlMonitorStatsPtr)b)->id; +} + + +/* + * virResctrlMonitorGetStats + * + * @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. + * @nstats: A size_t pointer to hold the returned array length of @stats + * + * Get cache or memory bandwidth utilization information. + * + * Returns 0 on success, -1 on error. + */ +static int +virResctrlMonitorGetStats(virResctrlMonitorPtr monitor, + const char *resource, + virResctrlMonitorStatsPtr *stats, + size_t *nstats) +{ + int rv =3D -1; + int ret =3D -1; + DIR *dirp =3D NULL; + char *datapath =3D NULL; + struct dirent *ent =3D NULL; + virResctrlMonitorStatsPtr stat =3D NULL; + + if (!monitor) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Invalid resctrl monitor")); + return -1; + } + + if (virAsprintf(&datapath, "%s/mon_data", monitor->path) < 0) + return -1; + + if (virDirOpen(&dirp, datapath) < 0) + goto cleanup; + + *nstats =3D 0; + while (virDirRead(dirp, &ent, datapath) > 0) { + char *node_id =3D NULL; + + if (VIR_ALLOC(stat) < 0) + goto cleanup; + + /* Looking for directory that contains resource utilization + * information file. The directory name is arranged in format + * "mon__". For example, "mon_L3_00" and + * "mon_L3_01" are two target directories for a two nodes system + * with resource utilization data file for each node respectively. + */ + if (ent->d_type !=3D DT_DIR) + continue; + + /* Looking for directory has a prefix 'mon_L' */ + if (!(node_id =3D STRSKIP(ent->d_name, "mon_L"))) + continue; + + /* Looking for directory has another '_' */ + node_id =3D strchr(node_id, '_'); + if (!node_id) + continue; + + /* Skip the character '_' */ + if (!(node_id =3D STRSKIP(node_id, "_"))) + continue; + + /* The node ID number should be here, parsing it. */ + if (virStrToLong_uip(node_id, NULL, 0, &stat->id) < 0) + goto cleanup; + + rv =3D virFileReadValueUint(&stat->val, "%s/%s/%s", datapath, + ent->d_name, resource); + if (rv =3D=3D -2) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("File '%s/%s/%s' does not exist."), + datapath, ent->d_name, resource); + } + if (rv < 0) + goto cleanup; + + if (VIR_APPEND_ELEMENT(*stats, *nstats, *stat) < 0) + goto cleanup; + } + + /* Sort in id's ascending order */ + if (*nstats) + qsort(*stats, *nstats, sizeof(*stat), virResctrlMonitorStatsSorter= ); + + ret =3D 0; + cleanup: + VIR_FREE(datapath); + VIR_FREE(stat); + VIR_DIR_CLOSE(dirp); + return ret; +} + + +/* + * virResctrlMonitorGetCacheOccupancy + * + * @monitor: The monitor that the statistic data will be retrieved from. + * @stats: Array of virResctrlMonitorStatsPtr for receiving cache occupancy + * data. Caller is responsible to free this array. + * @nstats: A size_t pointer to hold the returned array length of @caches + * + * Get cache or memory bandwidth utilization information. + * + * Returns 0 on success, -1 on error. + */ + +int +virResctrlMonitorGetCacheOccupancy(virResctrlMonitorPtr monitor, + virResctrlMonitorStatsPtr *stats, + size_t *nstats) +{ + return virResctrlMonitorGetStats(monitor, "llc_occupancy", + stats, nstats); +} diff --git a/src/util/virresctrl.h b/src/util/virresctrl.h index 76e40a2..45ec967 100644 --- a/src/util/virresctrl.h +++ b/src/util/virresctrl.h @@ -191,6 +191,13 @@ virResctrlInfoGetMonitorPrefix(virResctrlInfoPtr resct= rl, typedef struct _virResctrlMonitor virResctrlMonitor; typedef virResctrlMonitor *virResctrlMonitorPtr; =20 +typedef struct _virResctrlMonitorStats virResctrlMonitorStats; +typedef virResctrlMonitorStats *virResctrlMonitorStatsPtr; +struct _virResctrlMonitorStats { + unsigned int id; + unsigned int val; +}; + virResctrlMonitorPtr virResctrlMonitorNew(void); =20 @@ -205,4 +212,23 @@ virResctrlMonitorAddPID(virResctrlMonitorPtr monitor, int virResctrlMonitorCreate(virResctrlMonitorPtr monitor, const char *machinename); + +int +virResctrlMonitorSetID(virResctrlMonitorPtr monitor, + const char *id); + +const char * +virResctrlMonitorGetID(virResctrlMonitorPtr monitor); + +void +virResctrlMonitorSetAlloc(virResctrlMonitorPtr monitor, + virResctrlAllocPtr alloc); + +int +virResctrlMonitorRemove(virResctrlMonitorPtr monitor); + +int +virResctrlMonitorGetCacheOccupancy(virResctrlMonitorPtr monitor, + virResctrlMonitorStatsPtr *caches, + size_t *ncaches); #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 Sat May 4 23:26:36 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 1542029692109503.08128344081695; Mon, 12 Nov 2018 05:34:52 -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 E8F1A307EA82; Mon, 12 Nov 2018 13:34: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 ABE025D757; Mon, 12 Nov 2018 13:34:49 +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 519184BB79; Mon, 12 Nov 2018 13:34:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wACDXqLo019960 for ; Mon, 12 Nov 2018 08:33:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id C6F7D6090B; Mon, 12 Nov 2018 13:33:52 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9959E608F8; Mon, 12 Nov 2018 13:33:49 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 4146E3082A38; Mon, 12 Nov 2018 13:33:48 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Nov 2018 05:33:48 -0800 Received: from david-unc.bj.intel.com ([10.238.145.63]) by orsmga004.jf.intel.com with ESMTP; 12 Nov 2018 05:33:46 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,495,1534834800"; d="scan'208";a="249041298" From: Wang Huaqiang To: jferlan@redhat.com, libvir-list@redhat.com Date: Mon, 12 Nov 2018 21:31:43 +0800 Message-Id: <1542029508-25671-13-git-send-email-huaqiang.wang@intel.com> In-Reply-To: <1542029508-25671-1-git-send-email-huaqiang.wang@intel.com> References: <1542029508-25671-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.45]); Mon, 12 Nov 2018 13:33:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 12 Nov 2018 13:33:48 +0000 (UTC) for IP:'192.55.52.93' DOMAIN:'mga11.intel.com' HELO:'mga11.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -5.001 (RCVD_IN_DNSWL_HI, SPF_PASS) 192.55.52.93 mga11.intel.com 192.55.52.93 mga11.intel.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: shaohe.feng@intel.com, huaqiang.wang@intel.com, rui.zang@intel.com, jian-feng.ding@intel.com Subject: [libvirt] [PATCHv8 12/17] conf: Remove virDomainResctrlAppend and introduce virDomainResctrlNew 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.44]); Mon, 12 Nov 2018 13:34:51 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Introduced virDomainResctrlNew to do the most part of virDomainResctrlAppend and move the operation of appending resctrl to @def->resctrls out of function. Rather than rely on virDomainResctrlAppend to perform the allocation, move the onus to the caller and make use of virBitmapNewCopy for @vcpus and virObjectRef for @alloc, thus removing the need to set each to NULL after t= he call. Signed-off-by: Wang Huaqiang Reviewed-by: John Ferlan --- src/conf/domain_conf.c | 56 +++++++++++++++++++++++++++++-----------------= ---- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 237540b..8433214 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -18948,26 +18948,22 @@ virDomainCachetuneDefParseCache(xmlXPathContextPt= r ctxt, } =20 =20 -static int -virDomainResctrlAppend(virDomainDefPtr def, - xmlNodePtr node, - virResctrlAllocPtr alloc, - virBitmapPtr vcpus, - unsigned int flags) +static virDomainResctrlDefPtr +virDomainResctrlNew(xmlNodePtr node, + virResctrlAllocPtr alloc, + virBitmapPtr vcpus, + unsigned int flags) { char *vcpus_str =3D NULL; char *alloc_id =3D NULL; - virDomainResctrlDefPtr tmp_resctrl =3D NULL; - int ret =3D -1; - - if (VIR_ALLOC(tmp_resctrl) < 0) - goto cleanup; + virDomainResctrlDefPtr resctrl =3D NULL; + virDomainResctrlDefPtr ret =3D NULL; =20 /* We need to format it back because we need to be consistent in the n= aming * even when users specify some "sub-optimal" string there. */ vcpus_str =3D virBitmapFormat(vcpus); if (!vcpus_str) - goto cleanup; + return NULL; =20 if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) alloc_id =3D virXMLPropString(node, "id"); @@ -18985,15 +18981,20 @@ virDomainResctrlAppend(virDomainDefPtr def, if (virResctrlAllocSetID(alloc, alloc_id) < 0) goto cleanup; =20 - tmp_resctrl->vcpus =3D vcpus; - tmp_resctrl->alloc =3D alloc; + if (VIR_ALLOC(resctrl) < 0) + goto cleanup; =20 - if (VIR_APPEND_ELEMENT(def->resctrls, def->nresctrls, tmp_resctrl) < 0) + if (!(resctrl->vcpus =3D virBitmapNewCopy(vcpus))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to copy 'vcpus'")); goto cleanup; + } =20 - ret =3D 0; + resctrl->alloc =3D virObjectRef(alloc); + + VIR_STEAL_PTR(ret, resctrl); cleanup: - virDomainResctrlDefFree(tmp_resctrl); + virDomainResctrlDefFree(resctrl); VIR_FREE(alloc_id); VIR_FREE(vcpus_str); return ret; @@ -19010,6 +19011,7 @@ virDomainCachetuneDefParse(virDomainDefPtr def, xmlNodePtr *nodes =3D NULL; virBitmapPtr vcpus =3D NULL; virResctrlAllocPtr alloc =3D NULL; + virDomainResctrlDefPtr resctrl =3D NULL; ssize_t i =3D 0; int n; int ret =3D -1; @@ -19048,19 +19050,22 @@ virDomainCachetuneDefParse(virDomainDefPtr def, goto cleanup; } =20 + resctrl =3D virDomainResctrlNew(node, alloc, vcpus, flags); + if (!resctrl) + goto cleanup; + if (virResctrlAllocIsEmpty(alloc)) { ret =3D 0; goto cleanup; } =20 - if (virDomainResctrlAppend(def, node, alloc, vcpus, flags) < 0) + if (VIR_APPEND_ELEMENT(def->resctrls, def->nresctrls, resctrl) < 0) goto cleanup; - vcpus =3D NULL; - alloc =3D NULL; =20 ret =3D 0; cleanup: ctxt->node =3D oldnode; + virDomainResctrlDefFree(resctrl); virObjectUnref(alloc); virBitmapFree(vcpus); VIR_FREE(nodes); @@ -19218,6 +19223,8 @@ virDomainMemorytuneDefParse(virDomainDefPtr def, xmlNodePtr *nodes =3D NULL; virBitmapPtr vcpus =3D NULL; virResctrlAllocPtr alloc =3D NULL; + virDomainResctrlDefPtr resctrl =3D NULL; + ssize_t i =3D 0; int n; int ret =3D -1; @@ -19262,15 +19269,18 @@ virDomainMemorytuneDefParse(virDomainDefPtr def, * just update the existing alloc information, which is done in above * virDomainMemorytuneDefParseMemory */ if (new_alloc) { - if (virDomainResctrlAppend(def, node, alloc, vcpus, flags) < 0) + resctrl =3D virDomainResctrlNew(node, alloc, vcpus, flags); + if (!resctrl) + goto cleanup; + + if (VIR_APPEND_ELEMENT(def->resctrls, def->nresctrls, resctrl) < 0) goto cleanup; - vcpus =3D NULL; - alloc =3D NULL; } =20 ret =3D 0; cleanup: ctxt->node =3D oldnode; + virDomainResctrlDefFree(resctrl); virObjectUnref(alloc); virBitmapFree(vcpus); VIR_FREE(nodes); --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 23:26:36 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 1542029660740643.6630589178468; Mon, 12 Nov 2018 05:34:20 -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 6E2493013038; Mon, 12 Nov 2018 13:34:18 +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 31CDE5D971; Mon, 12 Nov 2018 13:34:18 +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 BCF5F181B9E4; Mon, 12 Nov 2018 13:34:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wACDXq2K019955 for ; Mon, 12 Nov 2018 08:33:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id 500DF5D969; Mon, 12 Nov 2018 13:33:52 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 42ADD5D961; Mon, 12 Nov 2018 13:33:52 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 3DE813082AF5; Mon, 12 Nov 2018 13:33:50 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Nov 2018 05:33:50 -0800 Received: from david-unc.bj.intel.com ([10.238.145.63]) by orsmga004.jf.intel.com with ESMTP; 12 Nov 2018 05:33:48 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,495,1534834800"; d="scan'208";a="249041302" From: Wang Huaqiang To: jferlan@redhat.com, libvir-list@redhat.com Date: Mon, 12 Nov 2018 21:31:44 +0800 Message-Id: <1542029508-25671-14-git-send-email-huaqiang.wang@intel.com> In-Reply-To: <1542029508-25671-1-git-send-email-huaqiang.wang@intel.com> References: <1542029508-25671-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.45]); Mon, 12 Nov 2018 13:33:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 12 Nov 2018 13:33:50 +0000 (UTC) for IP:'192.55.52.93' DOMAIN:'mga11.intel.com' HELO:'mga11.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -5.001 (RCVD_IN_DNSWL_HI, SPF_PASS) 192.55.52.93 mga11.intel.com 192.55.52.93 mga11.intel.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: shaohe.feng@intel.com, huaqiang.wang@intel.com, rui.zang@intel.com, jian-feng.ding@intel.com Subject: [libvirt] [PATCHv8 13/17] conf: Introduce cache monitor element in cachetune 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.43]); Mon, 12 Nov 2018 13:34:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Introducing element under to represent a cache monitor. Signed-off-by: Wang Huaqiang Reviewed-by: John Ferlan --- docs/formatdomain.html.in | 26 +++ docs/schemas/domaincommon.rng | 10 + src/conf/domain_conf.c | 234 +++++++++++++++++= +++- src/conf/domain_conf.h | 11 + tests/genericxml2xmlindata/cachetune-cdp.xml | 3 + .../cachetune-colliding-monitor.xml | 30 +++ tests/genericxml2xmlindata/cachetune-small.xml | 7 + tests/genericxml2xmltest.c | 2 + 8 files changed, 322 insertions(+), 1 deletion(-) create mode 100644 tests/genericxml2xmlindata/cachetune-colliding-monitor.= xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 8850a71..92ad4b2 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -759,6 +759,12 @@ <cachetune vcpus=3D'0-3'> <cache id=3D'0' level=3D'3' type=3D'both' size=3D'3' unit=3D'MiB'= /> <cache id=3D'1' level=3D'3' type=3D'both' size=3D'3' unit=3D'MiB'= /> + <monitor level=3D'3' vcpus=3D'1'/> + <monitor level=3D'3' vcpus=3D'0-3'/> + </cachetune> + <cachetune vcpus=3D'4-5'> + <monitor level=3D'3' vcpus=3D'4'/> + <monitor level=3D'3' vcpus=3D'5'/> </cachetune> <memorytune vcpus=3D'0-3'> <node id=3D'0' bandwidth=3D'60'/> @@ -978,6 +984,26 @@
+
monitorSince 4.10.0
+
+ The optional element monitor creates the cache + monitor(s) for current cache allocation and has the following + required attributes: +
+
level
+
+ Host cache level the monitor belongs to. +
+
vcpus
+
+ vCPU list the monitor applies to. A monitor's vCPU list + can only be the member(s) of the vCPU list of the associat= ed + allocation. The default monitor has the same vCPU list as = the + associated allocation. For non-default monitors, overlappi= ng + vCPUs are not permitted. +
+
+
=20 diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 2b465be..1296b7f 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -981,6 +981,16 @@ + + + + + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8433214..7696098 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2955,13 +2955,31 @@ virDomainLoaderDefFree(virDomainLoaderDefPtr loader) =20 =20 static void +virDomainResctrlMonDefFree(virDomainResctrlMonDefPtr domresmon) +{ + if (!domresmon) + return; + + virBitmapFree(domresmon->vcpus); + virObjectUnref(domresmon->instance); + VIR_FREE(domresmon); +} + + +static void virDomainResctrlDefFree(virDomainResctrlDefPtr resctrl) { + size_t i =3D 0; + if (!resctrl) return; =20 + for (i =3D 0; i < resctrl->nmonitors; i++) + virDomainResctrlMonDefFree(resctrl->monitors[i]); + virObjectUnref(resctrl->alloc); virBitmapFree(resctrl->vcpus); + VIR_FREE(resctrl->monitors); VIR_FREE(resctrl); } =20 @@ -18948,6 +18966,177 @@ virDomainCachetuneDefParseCache(xmlXPathContextPt= r ctxt, } =20 =20 +/* Checking if the monitor's vcpus is conflicted with existing allocation + * and monitors. + * + * Returns 1 if @vcpus equals to @resctrl->vcpus, then the monitor will + * share the underlying resctrl group with @resctrl->alloc. Returns - 1 + * if any conflict found. Returns 0 if no conflict and @vcpus is not equal + * to @resctrl->vcpus. + */ +static int +virDomainResctrlMonValidateVcpus(virDomainResctrlDefPtr resctrl, + virBitmapPtr vcpus) +{ + size_t i =3D 0; + int vcpu =3D -1; + size_t mons_same_alloc_vcpus =3D 0; + + if (virBitmapIsAllClear(vcpus)) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("vcpus is empty")); + return -1; + } + + while ((vcpu =3D virBitmapNextSetBit(vcpus, vcpu)) >=3D 0) { + if (!virBitmapIsBitSet(resctrl->vcpus, vcpu)) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("Monitor vcpus conflicts with allocation")); + return -1; + } + } + + if (virBitmapEqual(vcpus, resctrl->vcpus)) + return 1; + + for (i =3D 0; i < resctrl->nmonitors; i++) { + if (virBitmapEqual(resctrl->vcpus, resctrl->monitors[i]->vcpus)) { + mons_same_alloc_vcpus++; + continue; + } + + if (virBitmapOverlaps(vcpus, resctrl->monitors[i]->vcpus)) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("Monitor vcpus conflicts with monitors")); + + return -1; + } + } + + if (mons_same_alloc_vcpus > 1) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("Too many monitors have the same vcpu as allocati= on")); + return -1; + } + + return 0; +} + + +#define VIR_DOMAIN_RESCTRL_MONITOR_CACHELEVEL 3 + +static int +virDomainResctrlMonDefParse(virDomainDefPtr def, + xmlXPathContextPtr ctxt, + xmlNodePtr node, + virResctrlMonitorType tag, + virDomainResctrlDefPtr resctrl) +{ + virDomainResctrlMonDefPtr domresmon =3D NULL; + xmlNodePtr oldnode =3D ctxt->node; + xmlNodePtr *nodes =3D NULL; + unsigned int level =3D 0; + char *tmp =3D NULL; + char *id =3D NULL; + size_t i =3D 0; + int n =3D 0; + int rv =3D -1; + int ret =3D -1; + + ctxt->node =3D node; + + if ((n =3D virXPathNodeSet("./monitor", ctxt, &nodes)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot extract monitor nodes")); + goto cleanup; + } + + for (i =3D 0; i < n; i++) { + if (VIR_ALLOC(domresmon) < 0) + goto cleanup; + + domresmon->tag =3D tag; + + domresmon->instance =3D virResctrlMonitorNew(); + if (!domresmon->instance) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not create monitor")); + goto cleanup; + } + + if (tag =3D=3D VIR_RESCTRL_MONITOR_TYPE_CACHE) { + tmp =3D virXMLPropString(nodes[i], "level"); + if (!tmp) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing monitor attribute 'level'")); + goto cleanup; + } + + if (virStrToLong_uip(tmp, NULL, 10, &level) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid monitor attribute 'level' value = '%s'"), + tmp); + goto cleanup; + } + + if (level !=3D VIR_DOMAIN_RESCTRL_MONITOR_CACHELEVEL) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid monitor cache level '%d'"), + level); + goto cleanup; + } + + VIR_FREE(tmp); + } + + if (virDomainResctrlParseVcpus(def, nodes[i], &domresmon->vcpus) <= 0) + goto cleanup; + + rv =3D virDomainResctrlMonValidateVcpus(resctrl, domresmon->vcpus); + if (rv < 0) + goto cleanup; + + /* If monitor's vcpu list is identical to the vcpu list of the + * associated allocation, set monitor's id to the same value + * as the allocation. */ + if (rv =3D=3D 1) { + const char *alloc_id =3D virResctrlAllocGetID(resctrl->alloc); + + if (VIR_STRDUP(id, alloc_id) < 0) + goto cleanup; + } else { + if (!(tmp =3D virBitmapFormat(domresmon->vcpus))) + goto cleanup; + + if (virAsprintf(&id, "vcpus_%s", tmp) < 0) + goto cleanup; + } + + virResctrlMonitorSetAlloc(domresmon->instance, resctrl->alloc); + + if (virResctrlMonitorSetID(domresmon->instance, id) < 0) + goto cleanup; + + if (VIR_APPEND_ELEMENT(resctrl->monitors, + resctrl->nmonitors, + domresmon) < 0) + goto cleanup; + + VIR_FREE(id); + VIR_FREE(tmp); + } + + ret =3D 0; + cleanup: + ctxt->node =3D oldnode; + VIR_FREE(id); + VIR_FREE(tmp); + VIR_FREE(nodes); + virDomainResctrlMonDefFree(domresmon); + return ret; +} + + static virDomainResctrlDefPtr virDomainResctrlNew(xmlNodePtr node, virResctrlAllocPtr alloc, @@ -19054,7 +19243,14 @@ virDomainCachetuneDefParse(virDomainDefPtr def, if (!resctrl) goto cleanup; =20 - if (virResctrlAllocIsEmpty(alloc)) { + if (virDomainResctrlMonDefParse(def, ctxt, node, + VIR_RESCTRL_MONITOR_TYPE_CACHE, + resctrl) < 0) + goto cleanup; + + /* If no element or element in , do not + * append any resctrl element */ + if (!resctrl->nmonitors && virResctrlAllocIsEmpty(alloc)) { ret =3D 0; goto cleanup; } @@ -27091,12 +27287,41 @@ virDomainCachetuneDefFormatHelper(unsigned int le= vel, =20 =20 static int +virDomainResctrlMonDefFormatHelper(virDomainResctrlMonDefPtr domresmon, + virResctrlMonitorType tag, + virBufferPtr buf) +{ + char *vcpus =3D NULL; + + if (domresmon->tag !=3D tag) + return 0; + + virBufferAddLit(buf, "vcpus); + if (!vcpus) + return -1; + + virBufferAsprintf(buf, "vcpus=3D'%s'/>\n", vcpus); + + VIR_FREE(vcpus); + return 0; +} + + +static int virDomainCachetuneDefFormat(virBufferPtr buf, virDomainResctrlDefPtr resctrl, unsigned int flags) { virBuffer childrenBuf =3D VIR_BUFFER_INITIALIZER; char *vcpus =3D NULL; + size_t i =3D 0; int ret =3D -1; =20 virBufferSetChildIndent(&childrenBuf, buf); @@ -27105,6 +27330,13 @@ virDomainCachetuneDefFormat(virBufferPtr buf, &childrenBuf) < 0) goto cleanup; =20 + for (i =3D 0; i < resctrl->nmonitors; i ++) { + if (virDomainResctrlMonDefFormatHelper(resctrl->monitors[i], + VIR_RESCTRL_MONITOR_TYPE_CA= CHE, + &childrenBuf) < 0) + goto cleanup; + } + if (virBufferCheckError(&childrenBuf) < 0) goto cleanup; =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e30a4b2..60f6464 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2236,12 +2236,23 @@ struct _virDomainCputune { }; =20 =20 +typedef struct _virDomainResctrlMonDef virDomainResctrlMonDef; +typedef virDomainResctrlMonDef *virDomainResctrlMonDefPtr; +struct _virDomainResctrlMonDef { + virBitmapPtr vcpus; + virResctrlMonitorType tag; + virResctrlMonitorPtr instance; +}; + typedef struct _virDomainResctrlDef virDomainResctrlDef; typedef virDomainResctrlDef *virDomainResctrlDefPtr; =20 struct _virDomainResctrlDef { virBitmapPtr vcpus; virResctrlAllocPtr alloc; + + virDomainResctrlMonDefPtr *monitors; + size_t nmonitors; }; =20 =20 diff --git a/tests/genericxml2xmlindata/cachetune-cdp.xml b/tests/genericxm= l2xmlindata/cachetune-cdp.xml index 9718f06..9f4c139 100644 --- a/tests/genericxml2xmlindata/cachetune-cdp.xml +++ b/tests/genericxml2xmlindata/cachetune-cdp.xml @@ -8,9 +8,12 @@ + + + diff --git a/tests/genericxml2xmlindata/cachetune-colliding-monitor.xml b/t= ests/genericxml2xmlindata/cachetune-colliding-monitor.xml new file mode 100644 index 0000000..d481fb5 --- /dev/null +++ b/tests/genericxml2xmlindata/cachetune-colliding-monitor.xml @@ -0,0 +1,30 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 4 + + + + + + + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + + + diff --git a/tests/genericxml2xmlindata/cachetune-small.xml b/tests/generic= xml2xmlindata/cachetune-small.xml index ab2d9cf..748be08 100644 --- a/tests/genericxml2xmlindata/cachetune-small.xml +++ b/tests/genericxml2xmlindata/cachetune-small.xml @@ -7,6 +7,13 @@ + + + + + + + diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c index fa941f0..4393d44 100644 --- a/tests/genericxml2xmltest.c +++ b/tests/genericxml2xmltest.c @@ -137,6 +137,8 @@ mymain(void) TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); DO_TEST_FULL("cachetune-colliding-types", false, true, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); + DO_TEST_FULL("cachetune-colliding-monitor", false, true, + TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); DO_TEST("memorytune"); DO_TEST_FULL("memorytune-colliding-allocs", false, true, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 23:26:36 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 1542029702651931.6376640485282; Mon, 12 Nov 2018 05:35:02 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1BC8230832EE; Mon, 12 Nov 2018 13:35:00 +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 BBF645C207; Mon, 12 Nov 2018 13:34:59 +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 647EA181A86C; Mon, 12 Nov 2018 13:34:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wACDXrIW019965 for ; Mon, 12 Nov 2018 08:33:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8A603608FA; Mon, 12 Nov 2018 13:33:53 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 78F37608F8; Mon, 12 Nov 2018 13:33:53 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 41B283082A31; Mon, 12 Nov 2018 13:33:52 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Nov 2018 05:33:51 -0800 Received: from david-unc.bj.intel.com ([10.238.145.63]) by orsmga004.jf.intel.com with ESMTP; 12 Nov 2018 05:33:50 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,495,1534834800"; d="scan'208";a="249041311" From: Wang Huaqiang To: jferlan@redhat.com, libvir-list@redhat.com Date: Mon, 12 Nov 2018 21:31:45 +0800 Message-Id: <1542029508-25671-15-git-send-email-huaqiang.wang@intel.com> In-Reply-To: <1542029508-25671-1-git-send-email-huaqiang.wang@intel.com> References: <1542029508-25671-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.45]); Mon, 12 Nov 2018 13:33:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 12 Nov 2018 13:33:52 +0000 (UTC) for IP:'192.55.52.93' DOMAIN:'mga11.intel.com' HELO:'mga11.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -5.001 (RCVD_IN_DNSWL_HI, SPF_PASS) 192.55.52.93 mga11.intel.com 192.55.52.93 mga11.intel.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: shaohe.feng@intel.com, huaqiang.wang@intel.com, rui.zang@intel.com, jian-feng.ding@intel.com Subject: [libvirt] [PATCHv8 14/17] qemu: enable resctrl monitor in qemu 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Mon, 12 Nov 2018 13:35:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add functions for creating, destroying, reconnecting resctrl monitor in qemu according to the configuration in domain XML. Signed-off-by: Wang Huaqiang Reviewed-by: John Ferlan --- src/qemu/qemu_process.c | 49 +++++++++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 1850923..096fea1 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2597,10 +2597,20 @@ qemuProcessResctrlCreate(virQEMUDriverPtr driver, return -1; =20 for (i =3D 0; i < vm->def->nresctrls; i++) { + size_t j =3D 0; if (virResctrlAllocCreate(caps->host.resctrl, vm->def->resctrls[i]->alloc, priv->machineName) < 0) goto cleanup; + + for (j =3D 0; j < vm->def->resctrls[i]->nmonitors; j++) { + virDomainResctrlMonDefPtr mon =3D NULL; + + mon =3D vm->def->resctrls[i]->monitors[j]; + if (virResctrlMonitorCreate(mon->instance, + priv->machineName) < 0) + goto cleanup; + } } =20 ret =3D 0; @@ -5414,6 +5424,7 @@ qemuProcessSetupVcpu(virDomainObjPtr vm, { pid_t vcpupid =3D qemuDomainGetVcpuPid(vm, vcpuid); virDomainVcpuDefPtr vcpu =3D virDomainDefGetVcpu(vm->def, vcpuid); + virDomainResctrlMonDefPtr mon =3D NULL; size_t i =3D 0; =20 if (qemuProcessSetupPid(vm, vcpupid, VIR_CGROUP_THREAD_VCPU, @@ -5424,11 +5435,26 @@ qemuProcessSetupVcpu(virDomainObjPtr vm, return -1; =20 for (i =3D 0; i < vm->def->nresctrls; i++) { + size_t j =3D 0; virDomainResctrlDefPtr ct =3D vm->def->resctrls[i]; =20 if (virBitmapIsBitSet(ct->vcpus, vcpuid)) { if (virResctrlAllocAddPID(ct->alloc, vcpupid) < 0) return -1; + + for (j =3D 0; j < ct->nmonitors; j++) { + mon =3D ct->monitors[j]; + + if (virBitmapEqual(ct->vcpus, mon->vcpus)) + continue; + + if (virBitmapIsBitSet(mon->vcpus, vcpuid)) { + if (virResctrlMonitorAddPID(mon->instance, vcpupid) < = 0) + return -1; + break; + } + } + break; } } @@ -7190,8 +7216,18 @@ void qemuProcessStop(virQEMUDriverPtr driver, /* Remove resctrl allocation after cgroups are cleaned up which makes = it * kind of safer (although removing the allocation should work even wi= th * pids in tasks file */ - for (i =3D 0; i < vm->def->nresctrls; i++) + for (i =3D 0; i < vm->def->nresctrls; i++) { + size_t j =3D 0; + + for (j =3D 0; j < vm->def->resctrls[i]->nmonitors; j++) { + virDomainResctrlMonDefPtr mon =3D NULL; + + mon =3D vm->def->resctrls[i]->monitors[j]; + virResctrlMonitorRemove(mon->instance); + } + virResctrlAllocRemove(vm->def->resctrls[i]->alloc); + } =20 qemuProcessRemoveDomainStatus(driver, vm); =20 @@ -7926,9 +7962,20 @@ qemuProcessReconnect(void *opaque) goto error; =20 for (i =3D 0; i < obj->def->nresctrls; i++) { + size_t j =3D 0; + if (virResctrlAllocDeterminePath(obj->def->resctrls[i]->alloc, priv->machineName) < 0) goto error; + + for (j =3D 0; j < obj->def->resctrls[i]->nmonitors; j++) { + virDomainResctrlMonDefPtr mon =3D NULL; + + mon =3D obj->def->resctrls[i]->monitors[j]; + if (virResctrlMonitorDeterminePath(mon->instance, + priv->machineName) < 0) + goto error; + } } =20 /* update domain state XML with possibly updated state in virDomainObj= */ --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 23:26:36 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 1542029716305506.0289545154616; Mon, 12 Nov 2018 05:35:16 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6B55980F82; Mon, 12 Nov 2018 13:35:14 +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 178D75C207; Mon, 12 Nov 2018 13:35:14 +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 A32EE1808841; Mon, 12 Nov 2018 13:35:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wACDXxdD019991 for ; Mon, 12 Nov 2018 08:33:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5297B5D969; Mon, 12 Nov 2018 13:33:59 +0000 (UTC) Received: from mx1.redhat.com (ext-mx17.extmail.prod.ext.phx2.redhat.com [10.5.110.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AFF335D968; Mon, 12 Nov 2018 13:33:55 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 AE0503082E10; Mon, 12 Nov 2018 13:33:54 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Nov 2018 05:33:54 -0800 Received: from david-unc.bj.intel.com ([10.238.145.63]) by orsmga004.jf.intel.com with ESMTP; 12 Nov 2018 05:33:52 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,495,1534834800"; d="scan'208";a="249041315" From: Wang Huaqiang To: jferlan@redhat.com, libvir-list@redhat.com Date: Mon, 12 Nov 2018 21:31:46 +0800 Message-Id: <1542029508-25671-16-git-send-email-huaqiang.wang@intel.com> In-Reply-To: <1542029508-25671-1-git-send-email-huaqiang.wang@intel.com> References: <1542029508-25671-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.46]); Mon, 12 Nov 2018 13:33:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Mon, 12 Nov 2018 13:33:54 +0000 (UTC) for IP:'192.55.52.93' DOMAIN:'mga11.intel.com' HELO:'mga11.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -5.001 (RCVD_IN_DNSWL_HI, SPF_PASS) 192.55.52.93 mga11.intel.com 192.55.52.93 mga11.intel.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.46 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: shaohe.feng@intel.com, huaqiang.wang@intel.com, rui.zang@intel.com, jian-feng.ding@intel.com Subject: [libvirt] [PATCHv8 15/17] qemu: Refactor qemuDomainGetStatsCpu 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 12 Nov 2018 13:35:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Refactoring qemuDomainGetStatsCpu, make it possible to add more CPU statistics. Signed-off-by: Wang Huaqiang Reviewed-by: John Ferlan --- src/qemu/qemu_driver.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 09e04b8..89d46ee 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -19699,11 +19699,9 @@ typedef enum { =20 =20 static int -qemuDomainGetStatsCpu(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, - virDomainObjPtr dom, - virDomainStatsRecordPtr record, - int *maxparams, - unsigned int privflags ATTRIBUTE_UNUSED) +qemuDomainGetStatsCpuCgroup(virDomainObjPtr dom, + virDomainStatsRecordPtr record, + int *maxparams) { qemuDomainObjPrivatePtr priv =3D dom->privateData; unsigned long long cpu_time =3D 0; @@ -19739,6 +19737,19 @@ qemuDomainGetStatsCpu(virQEMUDriverPtr driver ATTR= IBUTE_UNUSED, return 0; } =20 + +static int +qemuDomainGetStatsCpu(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, + virDomainObjPtr dom, + virDomainStatsRecordPtr record, + int *maxparams, + unsigned int privflags ATTRIBUTE_UNUSED) +{ + if (qemuDomainGetStatsCpuCgroup(dom, record, maxparams) < 0) + return -1; +} + + static int qemuDomainGetStatsBalloon(virQEMUDriverPtr driver, virDomainObjPtr dom, --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 23:26:36 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 1542029703723805.3565527468602; Mon, 12 Nov 2018 05:35:03 -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 A43A988E51; Mon, 12 Nov 2018 13:35:01 +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 56E1F5EDE0; Mon, 12 Nov 2018 13:35:01 +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 E66CC14B20; Mon, 12 Nov 2018 13:35:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wACDY0JU020004 for ; Mon, 12 Nov 2018 08:34:00 -0500 Received: by smtp.corp.redhat.com (Postfix) id 452205D757; Mon, 12 Nov 2018 13:34:00 +0000 (UTC) Received: from mx1.redhat.com (ext-mx17.extmail.prod.ext.phx2.redhat.com [10.5.110.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3073F5D738; Mon, 12 Nov 2018 13:33:57 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 ADF5C31256A1; Mon, 12 Nov 2018 13:33:55 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Nov 2018 05:33:55 -0800 Received: from david-unc.bj.intel.com ([10.238.145.63]) by orsmga004.jf.intel.com with ESMTP; 12 Nov 2018 05:33:53 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,495,1534834800"; d="scan'208";a="249041320" From: Wang Huaqiang To: jferlan@redhat.com, libvir-list@redhat.com Date: Mon, 12 Nov 2018 21:31:47 +0800 Message-Id: <1542029508-25671-17-git-send-email-huaqiang.wang@intel.com> In-Reply-To: <1542029508-25671-1-git-send-email-huaqiang.wang@intel.com> References: <1542029508-25671-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.46]); Mon, 12 Nov 2018 13:33:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Mon, 12 Nov 2018 13:33:56 +0000 (UTC) for IP:'192.55.52.93' DOMAIN:'mga11.intel.com' HELO:'mga11.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -5.001 (RCVD_IN_DNSWL_HI, SPF_PASS) 192.55.52.93 mga11.intel.com 192.55.52.93 mga11.intel.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.46 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: shaohe.feng@intel.com, huaqiang.wang@intel.com, rui.zang@intel.com, jian-feng.ding@intel.com Subject: [libvirt] [PATCHv8 16/17] 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 12 Nov 2018 13:35:02 +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 --- src/libvirt-domain.c | 9 +++ src/qemu/qemu_driver.c | 198 +++++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 207 insertions(+) diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 7690339..4895f9f 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -11345,6 +11345,15 @@ 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" - tocal cache monitoring groups + * "cpu.cache.monitor.M.name" - name of cache monitoring group 'M' + * "cpu.cache.monitor.M.vcpus" - vcpus for cache monitoring group 'M' + * "cpu.cache.monitor.M.bank.count" - total bank number of cache monit= oring + * group 'M' + * "cpu.cache.monitor.M.bank.N.id" - OS assigned cache bank id for cac= he + * 'N' in cache monitoring group 'M' + * "cpu.cache.monitor.M.bank.N.bytes" - monitor's cache occupancy of c= ache + * bank 'N' in cache monitoring group 'M' * * VIR_DOMAIN_STATS_BALLOON: * Return memory balloon device information. diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 89d46ee..d41ae66 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -19698,6 +19698,199 @@ typedef enum { #define HAVE_JOB(flags) ((flags) & QEMU_DOMAIN_STATS_HAVE_JOB) =20 =20 +typedef struct _virQEMUCpuResMonitorData virQEMUCpuResMonitorData; +typedef virQEMUCpuResMonitorData *virQEMUCpuResMonitorDataPtr; +struct _virQEMUCpuResMonitorData{ + const char *name; + char *vcpus; + virResctrlMonitorType tag; + virResctrlMonitorStatsPtr stats; + size_t nstats; +}; + + +static int +qemuDomainGetCpuResMonitorData(virDomainObjPtr dom, + virQEMUCpuResMonitorDataPtr mondata) +{ + virDomainResctrlDefPtr resctrl =3D NULL; + size_t i =3D 0; + size_t j =3D 0; + size_t l =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 resctrl->monitors[j]->instanc= e; + + domresmon =3D resctrl->monitors[j]; + mondata[l].tag =3D domresmon->tag; + + /* If virBitmapFormat successfully returns an vcpu string, then + * mondata[l].vcpus is assigned with an memory space holding i= t, + * let this newly allocated memory buffer to be freed along wi= th + * the free of 'mondata' */ + if (!(mondata[l].vcpus =3D virBitmapFormat(domresmon->vcpus))) + return -1; + + if (!(mondata[l].name =3D virResctrlMonitorGetID(monitor))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not get monitor ID")); + return -1; + } + + if (domresmon->tag =3D=3D VIR_RESCTRL_MONITOR_TYPE_CACHE) { + if (virResctrlMonitorGetCacheOccupancy(monitor, + &mondata[l].stats, + &mondata[l].nstats)= < 0) + return -1; + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Invalid CPU resource type")); + return -1; + } + + l++; + } + } + + return 0; +} + + +static int +qemuDomainGetStatsCpuResMonitorPerTag(virQEMUCpuResMonitorDataPtr mondata, + size_t nmondata, + virResctrlMonitorType tag, + virDomainStatsRecordPtr record, + int *maxparams) +{ + char param_name[VIR_TYPED_PARAM_FIELD_LENGTH]; + unsigned int nmonitors =3D 0; + const char *resname =3D NULL; + const char *resnodename =3D NULL; + size_t i =3D 0; + + for (i =3D 0; i < nmondata; i++) { + if (mondata[i].tag =3D=3D tag) + nmonitors++; + } + + if (!nmonitors) + return 0; + + if (tag =3D=3D VIR_RESCTRL_MONITOR_TYPE_CACHE) { + resname =3D "cache"; + resnodename =3D "bank"; + } else if (tag =3D=3D VIR_RESCTRL_MONITOR_TYPE_MEMBW) { + resname =3D "memBW"; + resnodename =3D "node"; + } else { + return 0; + } + + snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, + "cpu.%s.monitor.count", resname); + if (virTypedParamsAddUInt(&record->params, &record->nparams, + maxparams, param_name, nmonitors) < 0) + return -1; + + for (i =3D 0; i < nmonitors; i++) { + size_t l =3D 0; + + snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, + "cpu.%s.monitor.%zd.name", resname, i); + if (virTypedParamsAddString(&record->params, + &record->nparams, + maxparams, + param_name, + mondata[i].name) < 0) + return -1; + + snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, + "cpu.%s.monitor.%zd.vcpus", resname, i); + if (virTypedParamsAddString(&record->params, &record->nparams, + maxparams, param_name, + mondata[i].vcpus) < 0) + return -1; + + snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, + "cpu.%s.monitor.%zd.%s.count", resname, i, resnodename); + if (virTypedParamsAddUInt(&record->params, &record->nparams, + maxparams, param_name, + mondata[i].nstats) < 0) + return -1; + + for (l =3D 0; l < mondata[i].nstats; l++) { + snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, + "cpu.%s.monitor.%zd.%s.%zd.id", + resname, i, resnodename, l); + if (virTypedParamsAddUInt(&record->params, &record->nparams, + maxparams, param_name, + mondata[i].stats[l].id) < 0) + return -1; + + snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, + "cpu.%s.monitor.%zd.%s.%zd.bytes", + resname, i, resnodename, l); + if (virTypedParamsAddUInt(&record->params, &record->nparams, + maxparams, param_name, + mondata[i].stats[l].val) < 0) + return -1; + } + } + + return 0; +} + + +static int +qemuDomainGetStatsCpuResMonitor(virDomainObjPtr dom, + virDomainStatsRecordPtr record, + int *maxparams) +{ + virDomainResctrlDefPtr resctrl =3D NULL; + virQEMUCpuResMonitorDataPtr mondata =3D NULL; + unsigned int nmonitors =3D 0; + size_t i =3D 0; + int ret =3D -1; + + if (!virDomainObjIsActive(dom)) + return 0; + + for (i =3D 0; i < dom->def->nresctrls; i++) { + resctrl =3D dom->def->resctrls[i]; + nmonitors +=3D resctrl->nmonitors; + } + + if (!nmonitors) + return 0; + + if (VIR_ALLOC_N(mondata, nmonitors) < 0) + return -1; + + if (qemuDomainGetCpuResMonitorData(dom, mondata) < 0) + goto cleanup; + + for (i =3D VIR_RESCTRL_MONITOR_TYPE_UNSUPPORT + 1; + i < VIR_RESCTRL_MONITOR_TYPE_LAST; i++) { + if (qemuDomainGetStatsCpuResMonitorPerTag(mondata, nmonitors, i, + record, maxparams) < 0) + goto cleanup; + } + + ret =3D 0; + cleanup: + for (i =3D 0; i < nmonitors; i++) + VIR_FREE(mondata[i].vcpus); + VIR_FREE(mondata); + + return ret; +} + + static int qemuDomainGetStatsCpuCgroup(virDomainObjPtr dom, virDomainStatsRecordPtr record, @@ -19747,6 +19940,11 @@ qemuDomainGetStatsCpu(virQEMUDriverPtr driver ATTR= IBUTE_UNUSED, { if (qemuDomainGetStatsCpuCgroup(dom, record, maxparams) < 0) return -1; + + if (qemuDomainGetStatsCpuResMonitor(dom, record, maxparams) < 0) + return -1; + + return 0; } =20 =20 --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 23:26:36 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 1542029672801235.2429532023649; Mon, 12 Nov 2018 05:34:32 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 38D6A394D53; Mon, 12 Nov 2018 13:34:30 +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 01337194AF; Mon, 12 Nov 2018 13:34:30 +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 7839914B21; Mon, 12 Nov 2018 13:34:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wACDXwUo019986 for ; Mon, 12 Nov 2018 08:33:58 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8F6E86090E; Mon, 12 Nov 2018 13:33:58 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 840DA6090D; Mon, 12 Nov 2018 13:33:58 +0000 (UTC) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 97B3488304; Mon, 12 Nov 2018 13:33:57 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Nov 2018 05:33:57 -0800 Received: from david-unc.bj.intel.com ([10.238.145.63]) by orsmga004.jf.intel.com with ESMTP; 12 Nov 2018 05:33:55 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,495,1534834800"; d="scan'208";a="249041326" From: Wang Huaqiang To: jferlan@redhat.com, libvir-list@redhat.com Date: Mon, 12 Nov 2018 21:31:48 +0800 Message-Id: <1542029508-25671-18-git-send-email-huaqiang.wang@intel.com> In-Reply-To: <1542029508-25671-1-git-send-email-huaqiang.wang@intel.com> References: <1542029508-25671-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.28]); Mon, 12 Nov 2018 13:33:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 12 Nov 2018 13:33:57 +0000 (UTC) for IP:'192.55.52.93' DOMAIN:'mga11.intel.com' HELO:'mga11.intel.com' FROM:'huaqiang.wang@intel.com' RCPT:'' X-RedHat-Spam-Score: -5.001 (RCVD_IN_DNSWL_HI, SPF_PASS) 192.55.52.93 mga11.intel.com 192.55.52.93 mga11.intel.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: shaohe.feng@intel.com, huaqiang.wang@intel.com, rui.zang@intel.com, jian-feng.ding@intel.com Subject: [libvirt] [PATCHv8 17/17] docs: Updated news.xml about the CMT support 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 12 Nov 2018 13:34:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Wang Huaqiang --- docs/news.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index 88774c5..3c84126 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -50,6 +50,17 @@ pvops-based HVM domains. + + + qemu: Added support for CMT (Cache Monitoring Technology) + + + Introduced cache monitor by monitor element + in cachetune for vCPU threads, and added interface + to get the cache utilization information through command + 'virsh domstats'. + + --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list