From nobody Fri Dec 19 06:32:53 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1673948264; cv=none; d=zohomail.com; s=zohoarc; b=meAIVroglgOXiKK92i2qwHJzUBndfvutC6bZsUYvnYaRdsUH32s4v2ja1efqi/nCQMXjhtBwDhFNKYT9sBn8m+AD+i3y0cUvYCw2uS13IgoEyKS07K/otENXEyaTkadkMCXHkdWZz5finfRFPztSUXjf0ijYLKlABbqHyt9dMIY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673948264; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zXX0gr8bcePaQeOD+rrFmUSaCU/Tm2L9+4uSQRRcTU0=; b=WeNHlA7gK9uZ1hFHm55XqeJxOAHrtgQBSmMqZREOdQN0LuLYZC2KE/b7AU4ZCDjz2/pUVn1dr0HplgCTWIikGhtiFmyTobWaP4gN0oczlonH5Qo952iAKLcw1fzHoHOIhTigg4G6Uu6SOCHiYBNbO7yESPNUp7WOlNauZV9whv4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1673948264729982.5364964571988; Tue, 17 Jan 2023 01:37:44 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-149-OLYPUvYVOwaqiEr7bCUXfw-1; Tue, 17 Jan 2023 04:37:40 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 558E83814597; Tue, 17 Jan 2023 09:37:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E0852166B26; Tue, 17 Jan 2023 09:37:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0FB5519465A4; Tue, 17 Jan 2023 09:37:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BBE0419465A3 for ; Tue, 17 Jan 2023 09:37:36 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id AF8A5175A2; Tue, 17 Jan 2023 09:37:36 +0000 (UTC) Received: from localhost.localdomain (ovpn-193-112.brq.redhat.com [10.40.193.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C9167AE5 for ; Tue, 17 Jan 2023 09:37:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673948263; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=zXX0gr8bcePaQeOD+rrFmUSaCU/Tm2L9+4uSQRRcTU0=; b=XfbPyiuXBd7xwvOt+BRycp/W9zKzZPOi2oeKSY0veAELnRmoo0T9gIDJy8ir5n8CYWzsrJ Dv0tC2XjLB1LiJlV/IDlLwyl1NxvIlL54oMfV12AE8N7q3ymRP6v6AtjiXJDL+UnjLaQ0O xxF863sOgKqgAw242Ycm1JUW13tw22k= X-MC-Unique: OLYPUvYVOwaqiEr7bCUXfw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 1/3] vircgroupv2: fix cpu.weight limits check Date: Tue, 17 Jan 2023 10:37:25 +0100 Message-Id: <2ebb0b5fb9289b42dcaf34e585e1a3ac061b62ba.1673948141.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673948266974100004 Content-Type: text/plain; charset="utf-8"; x-default="true" The cgroup v2 cpu.weight limits are different than cgroup v1 cpu.shares limits. Signed-off-by: Pavel Hrdina --- src/util/vircgroup.h | 2 ++ src/util/vircgroupv2.c | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h index 690f09465c..adf3850b22 100644 --- a/src/util/vircgroup.h +++ b/src/util/vircgroup.h @@ -235,6 +235,8 @@ int virCgroupGetCpuShares(virCgroup *group, unsigned lo= ng long *shares); /* Based on kernel code ((1ULL << MAX_BW_BITS) - 1) where MAX_BW_BITS is * (64 - BW_SHIFT) and BW_SHIFT is 20 */ #define VIR_CGROUP_CPU_QUOTA_MAX 17592186044415LL +#define VIR_CGROUPV2_WEIGHT_MIN 1LL +#define VIR_CGROUPV2_WEIGHT_MAX 10000LL =20 int virCgroupSetCpuCfsPeriod(virCgroup *group, unsigned long long cfs_peri= od); int virCgroupGetCpuCfsPeriod(virCgroup *group, unsigned long long *cfs_per= iod); diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index b1f562aa52..219b9c7f21 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -1499,13 +1499,13 @@ static int virCgroupV2SetCpuShares(virCgroup *group, unsigned long long shares) { - if (shares < VIR_CGROUP_CPU_SHARES_MIN || - shares > VIR_CGROUP_CPU_SHARES_MAX) { + if (shares < VIR_CGROUPV2_WEIGHT_MIN || + shares > VIR_CGROUPV2_WEIGHT_MAX) { virReportError(VIR_ERR_INVALID_ARG, _("shares '%llu' must be in range [%llu, %llu]"), shares, - VIR_CGROUP_CPU_SHARES_MIN, - VIR_CGROUP_CPU_SHARES_MAX); + VIR_CGROUPV2_WEIGHT_MIN, + VIR_CGROUPV2_WEIGHT_MAX); return -1; } =20 --=20 2.39.0