From nobody Thu May 15 02:45:20 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 1517391745232539.3342697172666; Wed, 31 Jan 2018 01:42:25 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E4D19272B2; Wed, 31 Jan 2018 09:42:23 +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 B2F32609D3; Wed, 31 Jan 2018 09:42:23 +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 7D7513FB19; Wed, 31 Jan 2018 09:42:23 +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 w0V9fxp3025425 for ; Wed, 31 Jan 2018 04:41:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id 27C4060BE7; Wed, 31 Jan 2018 09:41:59 +0000 (UTC) Received: from caroline.localdomain (unknown [10.43.2.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C302460BEC for ; Wed, 31 Jan 2018 09:41:51 +0000 (UTC) Received: from caroline.brq.redhat.com (caroline.usersys.redhat.com [127.0.0.1]) by caroline.localdomain (Postfix) with ESMTP id 7F14C120479 for ; Wed, 31 Jan 2018 10:41:50 +0100 (CET) From: Martin Kletzander To: libvir-list@redhat.com Date: Wed, 31 Jan 2018 10:41:40 +0100 Message-Id: <2caef0171f4cf6a8858e0345fe59d88b9b53f96c.1517391519.git.mkletzan@redhat.com> 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 2/8] 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 31 Jan 2018 09:42:24 +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. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1289368 Signed-off-by: Martin Kletzander --- src/util/virresctrl.c | 64 ++++++++++++++++++++++++++++++++++++++---------= ---- 1 file changed, 48 insertions(+), 16 deletions(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index fa7c28e9b45e..2bdca5455783 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -1296,23 +1296,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, @@ -1415,6 +1400,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 @@ -1428,11 +1451,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; @@ -1480,6 +1511,7 @@ virResctrlAllocMasksAssign(virResctrlInfoPtr resctrl, ret =3D 0; cleanup: virObjectUnref(alloc_free); + virObjectUnref(alloc_default); return ret; } =20 --=20 2.16.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list