|
Pablo Greco |
40546a |
From a6c731357b9c74e5cc298f04267312ad3bb635fa Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
40546a |
Message-Id: <a6c731357b9c74e5cc298f04267312ad3bb635fa@dist-git>
|
|
Pablo Greco |
40546a |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Date: Tue, 2 Jul 2019 15:13:26 +0200
|
|
Pablo Greco |
40546a |
Subject: [PATCH] util: vircgroupv1: add support for BFQ blkio files
|
|
Pablo Greco |
40546a |
MIME-Version: 1.0
|
|
Pablo Greco |
40546a |
Content-Type: text/plain; charset=UTF-8
|
|
Pablo Greco |
40546a |
Content-Transfer-Encoding: 8bit
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
In kernel 4.12 there was introduced new BFQ scheduler and in kernel
|
|
Pablo Greco |
40546a |
5.0 the old CFQ scheduler was removed. This has an implication on
|
|
Pablo Greco |
40546a |
the cgroups file names.
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
If the CFQ controller is enabled we use these two files:
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
blkio.weight
|
|
Pablo Greco |
40546a |
blkio.weight_device
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
The new BFQ controller expose only one file with different name:
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
blkio.bfq.weight
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
The reason is that BFQ controller doesn't support per-device weight.
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
Pablo Greco |
40546a |
(cherry picked from commit 035ebe9390a630964f391816f05c9cc7792212ad)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1658890
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Message-Id: <b66aa3f8ec343e90f9ccd2e458707051c65b4d0d.1562073117.git.phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
Pablo Greco |
40546a |
---
|
|
Pablo Greco |
40546a |
src/util/vircgroupv1.c | 114 ++++++++++++++++++++++++++++++++---------
|
|
Pablo Greco |
40546a |
1 file changed, 90 insertions(+), 24 deletions(-)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
|
|
Pablo Greco |
40546a |
index e51db6ee1f..a7d6c92e4c 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/vircgroupv1.c
|
|
Pablo Greco |
40546a |
+++ b/src/util/vircgroupv1.c
|
|
Pablo Greco |
40546a |
@@ -949,10 +949,33 @@ static int
|
|
Pablo Greco |
40546a |
virCgroupV1SetBlkioWeight(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
unsigned int weight)
|
|
Pablo Greco |
40546a |
{
|
|
Pablo Greco |
40546a |
- return virCgroupSetValueU64(group,
|
|
Pablo Greco |
40546a |
- VIR_CGROUP_CONTROLLER_BLKIO,
|
|
Pablo Greco |
40546a |
- "blkio.weight",
|
|
Pablo Greco |
40546a |
- weight);
|
|
Pablo Greco |
40546a |
+ VIR_AUTOFREE(char *) path = NULL;
|
|
Pablo Greco |
40546a |
+ VIR_AUTOFREE(char *) value = NULL;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (virCgroupV1PathOfController(group, VIR_CGROUP_CONTROLLER_BLKIO,
|
|
Pablo Greco |
40546a |
+ "blkio.bfq.weight", &path) < 0) {
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (!virFileExists(path)) {
|
|
Pablo Greco |
40546a |
+ VIR_FREE(path);
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (virCgroupV1PathOfController(group, VIR_CGROUP_CONTROLLER_BLKIO,
|
|
Pablo Greco |
40546a |
+ "blkio.weight", &path) < 0) {
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (!virFileExists(path)) {
|
|
Pablo Greco |
40546a |
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
Pablo Greco |
40546a |
+ _("blkio device weight is valid only for bfq or cfq scheduler"));
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (virAsprintf(&value, "%u", weight) < 0)
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ return virCgroupSetValueRaw(path, value);
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
@@ -960,14 +983,40 @@ static int
|
|
Pablo Greco |
40546a |
virCgroupV1GetBlkioWeight(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
unsigned int *weight)
|
|
Pablo Greco |
40546a |
{
|
|
Pablo Greco |
40546a |
- unsigned long long tmp;
|
|
Pablo Greco |
40546a |
- int ret;
|
|
Pablo Greco |
40546a |
- ret = virCgroupGetValueU64(group,
|
|
Pablo Greco |
40546a |
- VIR_CGROUP_CONTROLLER_BLKIO,
|
|
Pablo Greco |
40546a |
- "blkio.weight", &tmp);
|
|
Pablo Greco |
40546a |
- if (ret == 0)
|
|
Pablo Greco |
40546a |
- *weight = tmp;
|
|
Pablo Greco |
40546a |
- return ret;
|
|
Pablo Greco |
40546a |
+ VIR_AUTOFREE(char *) path = NULL;
|
|
Pablo Greco |
40546a |
+ VIR_AUTOFREE(char *) value = NULL;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (virCgroupV1PathOfController(group, VIR_CGROUP_CONTROLLER_BLKIO,
|
|
Pablo Greco |
40546a |
+ "blkio.bfq.weight", &path) < 0) {
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (!virFileExists(path)) {
|
|
Pablo Greco |
40546a |
+ VIR_FREE(path);
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (virCgroupV1PathOfController(group, VIR_CGROUP_CONTROLLER_BLKIO,
|
|
Pablo Greco |
40546a |
+ "blkio.weight", &path) < 0) {
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (!virFileExists(path)) {
|
|
Pablo Greco |
40546a |
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
Pablo Greco |
40546a |
+ _("blkio device weight is valid only for bfq or cfq scheduler"));
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (virCgroupGetValueRaw(path, &value) < 0)
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (virStrToLong_ui(value, NULL, 10, weight) < 0) {
|
|
Pablo Greco |
40546a |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
Pablo Greco |
40546a |
+ _("Unable to parse '%s' as an integer"),
|
|
Pablo Greco |
40546a |
+ value);
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ return 0;
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
@@ -1156,41 +1205,58 @@ virCgroupV1GetBlkioIoDeviceServiced(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
static int
|
|
Pablo Greco |
40546a |
virCgroupV1SetBlkioDeviceWeight(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
- const char *path,
|
|
Pablo Greco |
40546a |
+ const char *devPath,
|
|
Pablo Greco |
40546a |
unsigned int weight)
|
|
Pablo Greco |
40546a |
{
|
|
Pablo Greco |
40546a |
VIR_AUTOFREE(char *) str = NULL;
|
|
Pablo Greco |
40546a |
VIR_AUTOFREE(char *) blkstr = NULL;
|
|
Pablo Greco |
40546a |
+ VIR_AUTOFREE(char *) path = NULL;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
- if (!(blkstr = virCgroupGetBlockDevString(path)))
|
|
Pablo Greco |
40546a |
+ if (!(blkstr = virCgroupGetBlockDevString(devPath)))
|
|
Pablo Greco |
40546a |
return -1;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
if (virAsprintf(&str, "%s%d", blkstr, weight) < 0)
|
|
Pablo Greco |
40546a |
return -1;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
- return virCgroupSetValueStr(group,
|
|
Pablo Greco |
40546a |
- VIR_CGROUP_CONTROLLER_BLKIO,
|
|
Pablo Greco |
40546a |
- "blkio.weight_device",
|
|
Pablo Greco |
40546a |
- str);
|
|
Pablo Greco |
40546a |
+ if (virCgroupV1PathOfController(group, VIR_CGROUP_CONTROLLER_BLKIO,
|
|
Pablo Greco |
40546a |
+ "blkio.weight_device", &path) < 0) {
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (!virFileExists(path)) {
|
|
Pablo Greco |
40546a |
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
Pablo Greco |
40546a |
+ _("blkio device weight is valid only for cfq scheduler"));
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ return virCgroupSetValueRaw(path, str);
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
static int
|
|
Pablo Greco |
40546a |
virCgroupV1GetBlkioDeviceWeight(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
- const char *path,
|
|
Pablo Greco |
40546a |
+ const char *devPath,
|
|
Pablo Greco |
40546a |
unsigned int *weight)
|
|
Pablo Greco |
40546a |
{
|
|
Pablo Greco |
40546a |
VIR_AUTOFREE(char *) str = NULL;
|
|
Pablo Greco |
40546a |
VIR_AUTOFREE(char *) value = NULL;
|
|
Pablo Greco |
40546a |
+ VIR_AUTOFREE(char *) path = NULL;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
- if (virCgroupGetValueStr(group,
|
|
Pablo Greco |
40546a |
- VIR_CGROUP_CONTROLLER_BLKIO,
|
|
Pablo Greco |
40546a |
- "blkio.weight_device",
|
|
Pablo Greco |
40546a |
- &value) < 0) {
|
|
Pablo Greco |
40546a |
+ if (virCgroupV1PathOfController(group, VIR_CGROUP_CONTROLLER_BLKIO,
|
|
Pablo Greco |
40546a |
+ "blkio.weight_device", &path) < 0) {
|
|
Pablo Greco |
40546a |
return -1;
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
- if (virCgroupGetValueForBlkDev(value, path, &str) < 0)
|
|
Pablo Greco |
40546a |
+ if (!virFileExists(path)) {
|
|
Pablo Greco |
40546a |
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
Pablo Greco |
40546a |
+ _("blkio device weight is valid only for cfq scheduler"));
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (virCgroupGetValueRaw(path, &value) < 0)
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (virCgroupGetValueForBlkDev(value, devPath, &str) < 0)
|
|
Pablo Greco |
40546a |
return -1;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
if (!str) {
|
|
Pablo Greco |
40546a |
--
|
|
Pablo Greco |
40546a |
2.22.0
|
|
Pablo Greco |
40546a |
|