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