From nobody Sun Apr 28 21:49:25 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1552299915519243.55881891650506; Mon, 11 Mar 2019 03:25:15 -0700 (PDT) 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 D14B15945B; Mon, 11 Mar 2019 10:25:13 +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 A5B5060C64; Mon, 11 Mar 2019 10:25: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 2884F41F3D; Mon, 11 Mar 2019 10:25:13 +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 x2BAOsoH013628 for ; Mon, 11 Mar 2019 06:24:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3B1995D706; Mon, 11 Mar 2019 10:24:54 +0000 (UTC) Received: from caroline (unknown [10.43.2.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D78435EDE3 for ; Mon, 11 Mar 2019 10:24:48 +0000 (UTC) Received: from caroline.brq.redhat.com (caroline.usersys.redhat.com [127.0.0.1]) by caroline (Postfix) with ESMTP id 20EFC1206B1 for ; Mon, 11 Mar 2019 11:24:47 +0100 (CET) From: Martin Kletzander To: libvir-list@redhat.com Date: Mon, 11 Mar 2019 11:24:41 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] resctrl: Do not calculate free bandwidth for MBA 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: , 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]); Mon, 11 Mar 2019 10:25:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" For CAT we calculate unallocated parts of the cache, however with MBA this = does not make sense as the purpose of that is to limit the bandwidth and the set= ting is only proportional relative to bandwidth settings for other groups. This means it makes sense to set the values to 100% even if there are other groups with some allocations and that we don't need to find the available (unallocated) bandwidth in all the groups. Signed-off-by: Martin Kletzander --- src/util/virresctrl.c | 52 ++++++++++++------------------------------- 1 file changed, 14 insertions(+), 38 deletions(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 0857d4e882be..4a812d7a8be8 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -1823,22 +1823,6 @@ virResctrlAllocSubtract(virResctrlAllocPtr dst, } =20 =20 -static void -virResctrlMemoryBandwidthSubtract(virResctrlAllocPtr free, - virResctrlAllocPtr used) -{ - size_t i; - - if (!used->mem_bw) - return; - - for (i =3D 0; i < used->mem_bw->nbandwidths; i++) { - if (used->mem_bw->bandwidths[i]) - *(free->mem_bw->bandwidths[i]) -=3D *(used->mem_bw->bandwidths= [i]); - } -} - - static virResctrlAllocPtr virResctrlAllocNewFromInfo(virResctrlInfoPtr info) { @@ -1902,15 +1886,18 @@ virResctrlAllocNewFromInfo(virResctrlInfoPtr info) } =20 /* - * This function creates an allocation that represents all unused parts of - * all caches and memory bandwidth in the system. It uses virResctrlInfo - * for creating a new full allocation with all bits set (using the - * virResctrlAllocNewFromInfo()), sets memory bandwidth 100%, and then sca= ns - * for all allocations under /sys/fs/resctrl and subtracts each one of them - * from it. That way it can then return an allocation with only bit set - * being those that are not mentioned in any other allocation for CAT and - * available memory bandwidth for MBA. It is used for two things, calculat= ing - * the masks and bandwidth available when creating allocations and from te= sts. + * This function creates an allocation that represents all unused parts of= all + * caches in the system. It uses virResctrlInfo for creating a new full + * allocation with all bits set (using virResctrlAllocNewFromInfo()) and t= hen + * scans for all allocations under /sys/fs/resctrl and subtracts each one = of + * them from it. That way it can then return an allocation with only bit = set + * being those that are not mentioned in any other allocation. It is used= for + * two things, a) calculating the masks when creating allocations and b) f= rom + * tests. + * + * MBA (Memory Bandwidth Allocation) is not taken into account as it is a + * limiting setting, not an allocating one. The way it works is also vast= ly + * different from CAT. */ virResctrlAllocPtr virResctrlAllocGetUnused(virResctrlInfoPtr resctrl) @@ -1956,7 +1943,6 @@ virResctrlAllocGetUnused(virResctrlInfoPtr resctrl) goto error; } =20 - virResctrlMemoryBandwidthSubtract(ret, alloc); virResctrlAllocSubtract(ret, alloc); virObjectUnref(alloc); alloc =3D NULL; @@ -2109,12 +2095,10 @@ virResctrlAllocFindUnused(virResctrlAllocPtr alloc, =20 static int virResctrlAllocMemoryBandwidth(virResctrlInfoPtr resctrl, - virResctrlAllocPtr alloc, - virResctrlAllocPtr free) + virResctrlAllocPtr alloc) { size_t i; virResctrlAllocMemBWPtr mem_bw_alloc =3D alloc->mem_bw; - virResctrlAllocMemBWPtr mem_bw_free =3D free->mem_bw; virResctrlInfoMemBWPtr mem_bw_info =3D resctrl->membw_info; =20 if (!mem_bw_alloc) @@ -2154,14 +2138,6 @@ virResctrlAllocMemoryBandwidth(virResctrlInfoPtr res= ctrl, i, mem_bw_info->max_id); return -1; } - if (*(mem_bw_alloc->bandwidths[i]) > *(mem_bw_free->bandwidths[i])= ) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Not enough room for allocation of %u%% " - "bandwidth on node %zd, available bandwidth %= u%%"), - *(mem_bw_alloc->bandwidths[i]), i, - *(mem_bw_free->bandwidths[i])); - return -1; - } } return 0; } @@ -2228,7 +2204,7 @@ virResctrlAllocAssign(virResctrlInfoPtr resctrl, if (!alloc_default) goto cleanup; =20 - if (virResctrlAllocMemoryBandwidth(resctrl, alloc, alloc_free) < 0) + if (virResctrlAllocMemoryBandwidth(resctrl, alloc) < 0) goto cleanup; =20 if (virResctrlAllocCopyMasks(alloc, alloc_default) < 0) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 21:49:25 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 155229990069457.645552459534315; Mon, 11 Mar 2019 03:25:00 -0700 (PDT) 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 6EEF461D16; Mon, 11 Mar 2019 10:24:58 +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 1444F60C64; Mon, 11 Mar 2019 10:24:58 +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 DEEAE181A136; Mon, 11 Mar 2019 10:24:56 +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 x2BAOsJe013623 for ; Mon, 11 Mar 2019 06:24:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 132C85D706; Mon, 11 Mar 2019 10:24:54 +0000 (UTC) Received: from caroline (unknown [10.43.2.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D77ED5EDE1 for ; Mon, 11 Mar 2019 10:24:48 +0000 (UTC) Received: from caroline.brq.redhat.com (caroline.usersys.redhat.com [127.0.0.1]) by caroline (Postfix) with ESMTP id 2C090121022 for ; Mon, 11 Mar 2019 11:24:47 +0100 (CET) From: Martin Kletzander To: libvir-list@redhat.com Date: Mon, 11 Mar 2019 11:24:42 +0100 Message-Id: <5c12f846d7241d9a87c52aef3cb26aabd780746a.1552299771.git.mkletzan@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] resctrl: Set MBA defaults properly 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: , 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]); Mon, 11 Mar 2019 10:24:59 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Similarly to CAT, when you set some values in an group, remove the group and recreate it, the previous values will be kept there. In order to not get v= alues from a previous setting (a previous VM, for example), we need to set them to sensible defaults. The same way we do that for CAT, just set the same valu= es as the default group has. Signed-off-by: Martin Kletzander --- src/util/virresctrl.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 4a812d7a8be8..ab977b995c4d 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -2143,6 +2143,42 @@ virResctrlAllocMemoryBandwidth(virResctrlInfoPtr res= ctrl, } =20 =20 +static int +virResctrlAllocCopyMemBW(virResctrlAllocPtr dst, + virResctrlAllocPtr src) +{ + size_t i =3D 0; + virResctrlAllocMemBWPtr dst_bw =3D NULL; + virResctrlAllocMemBWPtr src_bw =3D src->mem_bw; + + if (!src->mem_bw) + return 0; + + if (!dst->mem_bw && + VIR_ALLOC(dst->mem_bw) < 0) + return -1; + + dst_bw =3D dst->mem_bw; + + if (src_bw->nbandwidths > dst_bw->nbandwidths && + VIR_EXPAND_N(dst_bw->bandwidths, dst_bw->nbandwidths, + src_bw->nbandwidths - dst_bw->nbandwidths) < 0) + return -1; + + for (i =3D 0; i < src_bw->nbandwidths; i++) { + if (dst_bw->bandwidths[i]) { + *dst_bw->bandwidths[i] =3D 123; + continue; + } + if (VIR_ALLOC(dst_bw->bandwidths[i]) < 0) + return -1; + *dst_bw->bandwidths[i] =3D *src_bw->bandwidths[i]; + } + + return 0; +} + + static int virResctrlAllocCopyMasks(virResctrlAllocPtr dst, virResctrlAllocPtr src) @@ -2210,6 +2246,9 @@ virResctrlAllocAssign(virResctrlInfoPtr resctrl, if (virResctrlAllocCopyMasks(alloc, alloc_default) < 0) goto cleanup; =20 + if (virResctrlAllocCopyMemBW(alloc, alloc_default) < 0) + goto cleanup; + for (level =3D 0; level < alloc->nlevels; level++) { virResctrlAllocPerLevelPtr a_level =3D alloc->levels[level]; virResctrlAllocPerLevelPtr f_level =3D NULL; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list