|
|
79b470 |
From b96501e90f7b3fbea1427ab6adeade7d8e707d07 Mon Sep 17 00:00:00 2001
|
|
|
79b470 |
Message-Id: <b96501e90f7b3fbea1427ab6adeade7d8e707d07@dist-git>
|
|
|
79b470 |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
79b470 |
Date: Thu, 21 Jan 2021 10:24:05 -0300
|
|
|
79b470 |
Subject: [PATCH] vircgroupv2: use defines for cpu period and quota limits
|
|
|
79b470 |
|
|
|
79b470 |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
79b470 |
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
|
|
|
79b470 |
(cherry picked from commit 98a09ca48ed4fc011abf2aa290e02ce1b8f1bb5f)
|
|
|
79b470 |
|
|
|
79b470 |
https://bugzilla.redhat.com/1915733
|
|
|
79b470 |
|
|
|
79b470 |
Signed-off-by: Daniel Henrique Barboza <dbarboza@redhat.com>
|
|
|
79b470 |
Message-Id: <20210121132406.337681-4-dbarboza@redhat.com>
|
|
|
79b470 |
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
79b470 |
---
|
|
|
79b470 |
src/util/vircgroupv2.c | 25 +++++++++++++------------
|
|
|
79b470 |
1 file changed, 13 insertions(+), 12 deletions(-)
|
|
|
79b470 |
|
|
|
79b470 |
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
|
|
|
79b470 |
index 1d8c599f6a..92ae3ec839 100644
|
|
|
79b470 |
--- a/src/util/vircgroupv2.c
|
|
|
79b470 |
+++ b/src/util/vircgroupv2.c
|
|
|
79b470 |
@@ -1476,12 +1476,12 @@ virCgroupV2SetCpuCfsPeriod(virCgroupPtr group,
|
|
|
79b470 |
g_autofree char *str = NULL;
|
|
|
79b470 |
char *tmp;
|
|
|
79b470 |
|
|
|
79b470 |
- /* The cfs_period should be greater or equal than 1ms, and less or equal
|
|
|
79b470 |
- * than 1s.
|
|
|
79b470 |
- */
|
|
|
79b470 |
- if (cfs_period < 1000 || cfs_period > 1000000) {
|
|
|
79b470 |
+ if (cfs_period < VIR_CGROUP_CPU_PERIOD_MIN ||
|
|
|
79b470 |
+ cfs_period > VIR_CGROUP_CPU_PERIOD_MAX) {
|
|
|
79b470 |
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
79b470 |
- _("cfs_period '%llu' must be in range (1000, 1000000)"),
|
|
|
79b470 |
+ _("cfs_period '%llu' must be in range (%llu, %llu)"),
|
|
|
79b470 |
+ VIR_CGROUP_CPU_PERIOD_MIN,
|
|
|
79b470 |
+ VIR_CGROUP_CPU_PERIOD_MAX,
|
|
|
79b470 |
cfs_period);
|
|
|
79b470 |
return -1;
|
|
|
79b470 |
}
|
|
|
79b470 |
@@ -1537,17 +1537,18 @@ static int
|
|
|
79b470 |
virCgroupV2SetCpuCfsQuota(virCgroupPtr group,
|
|
|
79b470 |
long long cfs_quota)
|
|
|
79b470 |
{
|
|
|
79b470 |
- /* The cfs_quota should be greater or equal than 1ms */
|
|
|
79b470 |
if (cfs_quota >= 0 &&
|
|
|
79b470 |
- (cfs_quota < 1000 ||
|
|
|
79b470 |
- cfs_quota > ULLONG_MAX / 1000)) {
|
|
|
79b470 |
+ (cfs_quota < VIR_CGROUP_CPU_QUOTA_MIN ||
|
|
|
79b470 |
+ cfs_quota > VIR_CGROUP_CPU_QUOTA_MAX)) {
|
|
|
79b470 |
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
79b470 |
- _("cfs_quota '%lld' must be in range (1000, %llu)"),
|
|
|
79b470 |
- cfs_quota, ULLONG_MAX / 1000);
|
|
|
79b470 |
+ _("cfs_quota '%lld' must be in range (%llu, %llu)"),
|
|
|
79b470 |
+ cfs_quota,
|
|
|
79b470 |
+ VIR_CGROUP_CPU_QUOTA_MIN,
|
|
|
79b470 |
+ VIR_CGROUP_CPU_QUOTA_MAX);
|
|
|
79b470 |
return -1;
|
|
|
79b470 |
}
|
|
|
79b470 |
|
|
|
79b470 |
- if (cfs_quota == ULLONG_MAX / 1000) {
|
|
|
79b470 |
+ if (cfs_quota == VIR_CGROUP_CPU_QUOTA_MAX) {
|
|
|
79b470 |
return virCgroupSetValueStr(group,
|
|
|
79b470 |
VIR_CGROUP_CONTROLLER_CPU,
|
|
|
79b470 |
"cpu.max", "max");
|
|
|
79b470 |
@@ -1572,7 +1573,7 @@ virCgroupV2GetCpuCfsQuota(virCgroupPtr group,
|
|
|
79b470 |
}
|
|
|
79b470 |
|
|
|
79b470 |
if (STREQLEN(str, "max", 3)) {
|
|
|
79b470 |
- *cfs_quota = ULLONG_MAX / 1000;
|
|
|
79b470 |
+ *cfs_quota = VIR_CGROUP_CPU_QUOTA_MAX;
|
|
|
79b470 |
return 0;
|
|
|
79b470 |
}
|
|
|
79b470 |
|
|
|
79b470 |
--
|
|
|
79b470 |
2.30.0
|
|
|
79b470 |
|