From nobody Thu May 15 03:44:29 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1517405841930474.9169907216926; Wed, 31 Jan 2018 05:37:21 -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 9FD883AA1D; Wed, 31 Jan 2018 13:37:20 +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 5FF0B5C552; Wed, 31 Jan 2018 13:37:20 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 199FC4EE4F; Wed, 31 Jan 2018 13:37:20 +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 w0VDbACH006826 for ; Wed, 31 Jan 2018 08:37:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8BB3460C93; Wed, 31 Jan 2018 13:37:10 +0000 (UTC) Received: from wheatley.localdomain (unknown [10.34.244.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1043F60C4B for ; Wed, 31 Jan 2018 13:37:03 +0000 (UTC) Received: from wheatley.brq.redhat.com (wheatley.usersys.redhat.com [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id 8120D7E007F for ; Wed, 31 Jan 2018 14:37:02 +0100 (CET) From: Martin Kletzander To: libvir-list@redhat.com Date: Wed, 31 Jan 2018 14:36:57 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 2/6] util: Use default group's mask for unspecified resctrl allocations 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.38]); Wed, 31 Jan 2018 13:37:21 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Introduce virResctrlAllocCopyMasks() and use that to initially copy the def= ault group schemata to the allocation before reserving any parts of the cache. = The reason for this is that when new group is created the schemata will have un= known data in it. If there was previously group with the same CLoS ID, it will h= ave the previous valies, if not it will have all bits set. And we need to set = all unspecified (in the XML) allocations to the same one as the default group. Some non-Linux functions now need to be made public due to this change. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1289368 Signed-off-by: Martin Kletzander Reviewed-by: Pavel Hrdina --- src/util/virresctrl.c | 72 +++++++++++++++++++++++++++++++++++------------= ---- 1 file changed, 50 insertions(+), 22 deletions(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index df6461a04676..a0ea2748713e 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -667,8 +667,6 @@ virResctrlAllocGetType(virResctrlAllocPtr resctrl, } =20 =20 -#ifdef __linux__ - static int virResctrlAllocUpdateMask(virResctrlAllocPtr resctrl, unsigned int level, @@ -696,8 +694,6 @@ virResctrlAllocUpdateMask(virResctrlAllocPtr resctrl, return virBitmapCopy(a_type->masks[cache], mask); } =20 -#endif - =20 static int virResctrlAllocUpdateSize(virResctrlAllocPtr resctrl, @@ -917,8 +913,6 @@ virResctrlAllocFormat(virResctrlAllocPtr resctrl) } =20 =20 -#ifdef __linux__ - static int virResctrlAllocParseProcessCache(virResctrlInfoPtr resctrl, virResctrlAllocPtr alloc, @@ -1090,6 +1084,8 @@ virResctrlAllocGetDefault(virResctrlInfoPtr resctrl) } =20 =20 +#ifdef __linux__ + static void virResctrlAllocSubtractPerType(virResctrlAllocPerTypePtr dst, virResctrlAllocPerTypePtr src) @@ -1298,23 +1294,8 @@ virResctrlAllocFindUnused(virResctrlAllocPerTypePtr = a_type, ssize_t last_bits =3D 0; ssize_t last_pos =3D -1; =20 - /* If there is no reservation requested we need to set all bits. That= 's due - * to weird interface of the resctrl sysfs. It's also the reason why = we - * cannot reserve the whole cache in one allocation. */ - if (!size) { - a_mask =3D virBitmapNew(i_type->bits); - if (!a_mask) - return -1; - - virBitmapSetAll(a_mask); - - if (virResctrlAllocSetMask(a_type, cache, a_mask) < 0) { - virBitmapFree(a_mask); - return -1; - } - + if (!size) return 0; - } =20 if (cache >=3D f_type->nmasks) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -1417,6 +1398,44 @@ virResctrlAllocFindUnused(virResctrlAllocPerTypePtr = a_type, } =20 =20 +static int +virResctrlAllocCopyMasks(virResctrlAllocPtr dst, + virResctrlAllocPtr src) +{ + unsigned int level =3D 0; + + for (level =3D 0; level < src->nlevels; level++) { + virResctrlAllocPerLevelPtr s_level =3D src->levels[level]; + unsigned int type =3D 0; + + if (!s_level) + continue; + + for (type =3D 0; type < VIR_CACHE_TYPE_LAST; type++) { + virResctrlAllocPerTypePtr s_type =3D s_level->types[type]; + virResctrlAllocPerTypePtr d_type =3D NULL; + unsigned int cache =3D 0; + + if (!s_type) + continue; + + d_type =3D virResctrlAllocGetType(dst, level, type); + if (!d_type) + return -1; + + for (cache =3D 0; cache < s_type->nmasks; cache++) { + virBitmapPtr mask =3D s_type->masks[cache]; + + if (mask && virResctrlAllocUpdateMask(dst, level, type, ca= che, mask) < 0) + return -1; + } + } + } + + return 0; +} + + /* * This function is called when creating an allocation in the system. Wha= t it * does is that it gets all the unused bits using virResctrlAllocGetUnused= () and @@ -1430,11 +1449,19 @@ virResctrlAllocMasksAssign(virResctrlInfoPtr resctr= l, int ret =3D -1; unsigned int level =3D 0; virResctrlAllocPtr alloc_free =3D NULL; + virResctrlAllocPtr alloc_default =3D NULL; =20 alloc_free =3D virResctrlAllocGetUnused(resctrl); if (!alloc_free) return -1; =20 + alloc_default =3D virResctrlAllocGetDefault(resctrl); + if (!alloc_default) + return -1; + + if (virResctrlAllocCopyMasks(alloc, alloc_default) < 0) + return -1; + for (level =3D 0; level < alloc->nlevels; level++) { virResctrlAllocPerLevelPtr a_level =3D alloc->levels[level]; virResctrlAllocPerLevelPtr f_level =3D NULL; @@ -1482,6 +1509,7 @@ virResctrlAllocMasksAssign(virResctrlInfoPtr resctrl, ret =3D 0; cleanup: virObjectUnref(alloc_free); + virObjectUnref(alloc_default); return ret; } =20 --=20 2.15.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list