68 lines
2.2 KiB
Diff
68 lines
2.2 KiB
Diff
From cb154a1d153edf2c399493a4336aebdccdc628f5 Mon Sep 17 00:00:00 2001
|
|
Message-Id: <cb154a1d153edf2c399493a4336aebdccdc628f5@dist-git>
|
|
From: Pavel Hrdina <phrdina@redhat.com>
|
|
Date: Mon, 1 Jul 2019 17:07:27 +0200
|
|
Subject: [PATCH] vircgroup: introduce virCgroupV2AddTask
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
In cgroups v2 we need to handle threads and processes differently.
|
|
If you need to move a process you need to write its pid into
|
|
cgrou.procs file and it will move the process with all its threads
|
|
as well. The whole process will be moved if you use tid of any thread.
|
|
|
|
In order to move only threads at first we need to create threaded group
|
|
and after that we can write the relevant thread tids into cgroup.threads
|
|
file. Threads can be moved only into cgroups that are children of
|
|
cgroup of its process.
|
|
|
|
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
(cherry picked from commit 48572f8825f2bbd7dabb5afb34efbf7afa2f7302)
|
|
|
|
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
|
|
|
|
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
Message-Id: <d6fb582c80903fc7725e2dd15165bd167c916f04.1561993100.git.phrdina@redhat.com>
|
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
---
|
|
src/util/vircgroupv2.c | 15 +++++++++++++++
|
|
1 file changed, 15 insertions(+)
|
|
|
|
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
|
|
index b5fad47ca0..6ffb5ce786 100644
|
|
--- a/src/util/vircgroupv2.c
|
|
+++ b/src/util/vircgroupv2.c
|
|
@@ -432,6 +432,20 @@ virCgroupV2Remove(virCgroupPtr group)
|
|
}
|
|
|
|
|
|
+static int
|
|
+virCgroupV2AddTask(virCgroupPtr group,
|
|
+ pid_t pid,
|
|
+ unsigned int flags)
|
|
+{
|
|
+ int controller = virCgroupV2GetAnyController(group);
|
|
+
|
|
+ if (flags & VIR_CGROUP_TASK_THREAD)
|
|
+ return virCgroupSetValueI64(group, controller, "cgroup.threads", pid);
|
|
+ else
|
|
+ return virCgroupSetValueI64(group, controller, "cgroup.procs", pid);
|
|
+}
|
|
+
|
|
+
|
|
virCgroupBackend virCgroupV2Backend = {
|
|
.type = VIR_CGROUP_BACKEND_TYPE_V2,
|
|
|
|
@@ -449,6 +463,7 @@ virCgroupBackend virCgroupV2Backend = {
|
|
.pathOfController = virCgroupV2PathOfController,
|
|
.makeGroup = virCgroupV2MakeGroup,
|
|
.remove = virCgroupV2Remove,
|
|
+ .addTask = virCgroupV2AddTask,
|
|
};
|
|
|
|
|
|
--
|
|
2.22.0
|
|
|