From nobody Mon Feb 9 13:26:55 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 172615263312184.45910472687615; Thu, 12 Sep 2024 07:50:33 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id F3FA515E4; Thu, 12 Sep 2024 10:50:31 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id C9693151B; Thu, 12 Sep 2024 10:48:24 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 74CD01439; Thu, 12 Sep 2024 10:48:13 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id C783D144E for ; Thu, 12 Sep 2024 10:48:12 -0400 (EDT) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-635-agi5WsX-MXG9abuNmEppyw-1; Thu, 12 Sep 2024 10:48:11 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-374c54e188dso1148114f8f.1 for ; Thu, 12 Sep 2024 07:48:11 -0700 (PDT) Received: from wheatley.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378956e8700sm14559667f8f.116.2024.09.12.07.48.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 07:48:08 -0700 (PDT) Received: from wheatley.redhat.com (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id CD43C2468100 for ; Thu, 12 Sep 2024 16:48:06 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726152492; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+Y81Y+gR9T4jrQldDyBLATgtQ3+a/L6bPV/ultiLDPI=; b=J1kU3tbGuWwdZwsOVQNmDZudOP8xiw1EImQsEVIiHthqR683JwYbmYSVp/9T+TmwHp722d EoUJAdUakqV/yTid6KSabt2wbNK6MuIuxspsiPFoGTG5CBqOM5LB+m5EnlQBy7vKjNWlLz aWpuF8oLX7lNwySyWCVRAFB70QO2T58= X-MC-Unique: agi5WsX-MXG9abuNmEppyw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726152490; x=1726757290; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+Y81Y+gR9T4jrQldDyBLATgtQ3+a/L6bPV/ultiLDPI=; b=i9JjD6CPJUQ2AiTfxls+OUZ4GllT+MaokjUrHu5tSpaaE5sfHnMMJtduJvNmcEHAgh a/JVVTSEIqh+oKq6SpoYltCl1plnBP6KzECg0RxACW6rFmnXGOkGEmy6g17Vwr0yZol9 OYfZptoc08lk4NFnLGxWH98SNvJNV+fSwzeLsE0b+H4u3mErmsn0vgpLDn1+EYZrq6AZ 0lwmxQ8Ohy75BeI6NW/EENyXlUrXlB9B9jG+3FdEMu1TDc/NZHS3Mkh30DrQviUwMF+Y cIPEqf3CxTCrOhiHj7+0HY15Ud/cj56zc0aWMubATZxqCDiACFQ/nU7d43/VXLeekZqw rdPw== X-Gm-Message-State: AOJu0YzB10BChv7O3VnQ4M3oHhBpZXTIEST06AzIPqSQZ5qaUmRXxsCB /gVTbRnURaej9QWNDYgCI3HU6s58EfDZ7ruE1LgC/1bVx/7H1Q8GnV1C/VIifyPBPraVoQb6Kkz t2E5KkRRt63wy35AKiKPfQzQ0gwZGpjX+9mJAu2ZmfyeHCkpp52RrjwSj2Ekhlb/HzVuyv7U0vc fMPj6TXZYlmOPv7aQ1PkVzOAK201LzD/LD4xkXbOU= X-Received: by 2002:a05:600c:458e:b0:42c:bd5a:9471 with SMTP id 5b1f17b1804b1-42cbde23b7cmr63629205e9.16.1726152490020; Thu, 12 Sep 2024 07:48:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEYGm/BLYBEr4Yu1FSU7JBKOyG3oor7+0yjYnZukMK+aZWd5JFG9ZnNZomja6E3P3U57TYhDg== X-Received: by 2002:a05:600c:458e:b0:42c:bd5a:9471 with SMTP id 5b1f17b1804b1-42cbde23b7cmr63628765e9.16.1726152488816; Thu, 12 Sep 2024 07:48:08 -0700 (PDT) From: Martin Kletzander To: devel@lists.libvirt.org Subject: [PATCH 08/10] resctrl: Don't assume MBA availability in virResctrlAllocNewFromInfo Date: Thu, 12 Sep 2024 16:47:57 +0200 Message-ID: <46a97329150241145c6cf12396656a0083767314.1726152457.git.mkletzan@redhat.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: EZRAWEM5GYBKWSOEPMZHAMMM2FHD3742 X-Message-ID-Hash: EZRAWEM5GYBKWSOEPMZHAMMM2FHD3742 X-MailFrom: mkletzan@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1726152635318116600 Content-Type: text/plain; charset="utf-8"; x-default="true" Weirdly, the existence of /sys/fs/resctrl/info/MB does not always mean that MBA is available and used on the system. Instead of assuming that copy the values from the default (root) allocation. This also makes it nicer to use the proper values in case the system does not use percentages or when the root allocation already limits the bandwidth. Signed-off-by: Martin Kletzander --- src/util/virresctrl.c | 16 +++------------- tests/virresctrldata/resctrl.schemata | 1 - 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 30695092a168..f3ec4d67059f 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -1805,19 +1805,6 @@ virResctrlAllocNewFromInfo(virResctrlInfo *info) } } =20 - /* set default free memory bandwidth to 100% */ - if (info->membw_info) { - ret->mem_bw =3D g_new0(virResctrlAllocMemBW, 1); - - VIR_EXPAND_N(ret->mem_bw->bandwidths, ret->mem_bw->nbandwidths, - info->membw_info->max_id + 1); - - for (i =3D 0; i < ret->mem_bw->nbandwidths; i++) { - ret->mem_bw->bandwidths[i] =3D g_new0(unsigned int, 1); - *(ret->mem_bw->bandwidths[i]) =3D 100; - } - } - return g_steal_pointer(&ret); } =20 @@ -1890,6 +1877,9 @@ virResctrlAllocGetUnused(virResctrlInfo *resctrl) if (!alloc_default) return NULL; =20 + /* Take MBA maximums from the root allocation */ + virResctrlAllocCopyMemBW(ret, alloc_default); + virResctrlAllocSubtract(ret, alloc_default); =20 if (virDirOpen(&dirp, SYSFS_RESCTRL_PATH) < 0) diff --git a/tests/virresctrldata/resctrl.schemata b/tests/virresctrldata/r= esctrl.schemata index 2578822b709d..fa980e58c9dd 100644 --- a/tests/virresctrldata/resctrl.schemata +++ b/tests/virresctrldata/resctrl.schemata @@ -1,2 +1 @@ L3:0=3D000ff;1=3D000f0 -MB:0=3D100;1=3D100 --=20 2.46.0