]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
ftests: add support to replace idle_thread of systemd scope
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Thu, 1 Jun 2023 11:11:42 +0000 (11:11 +0000)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 21 Jun 2023 16:11:19 +0000 (10:11 -0600)
Allow replacing the default idle_thread during process classification
into a cgroup using cgclassify by introducing replace_id flag, that
when unset(default) has no effect on the process created into systemd
scope cgroup, when set replaces the default idle_thread with the
process being created.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
tests/ftests/cgroup.py
tests/ftests/process.py

index 23ef9ca91d676626cdded8a8a81f4009c2a3f9c9..57fb2a70d31f381798db44f4b8c5da8695039ffc 100644 (file)
@@ -459,13 +459,16 @@ class Cgroup(object):
 
     @staticmethod
     def classify(config, controller, cgname, pid_list, sticky=False,
-                 cancel_sticky=False, ignore_systemd=False):
+                 cancel_sticky=False, ignore_systemd=False, replace_idle=False):
         cmd = list()
 
         if not config.args.container:
             cmd.append('sudo')
         cmd.append(Cgroup.build_cmd_path('cgclassify'))
 
+        if replace_idle:
+            cmd.append('-r')
+
         if ignore_systemd:
             cmd.append('-b')
 
index b2cdcf6e9422525c060744ce8fb113f2fd5907ec..d03de98f0f1d4a78dc9bb36df512da4c45680e09 100644 (file)
@@ -118,7 +118,8 @@ class Process(object):
                                  cgclassify=True, ignore_systemd=False, replace_idle=False):
         if cgclassify:
             child_pid = self.create_process(config)
-            Cgroup.classify(config, controller, cgname, child_pid, ignore_systemd=ignore_systemd)
+            Cgroup.classify(config, controller, cgname, child_pid,
+                            ignore_systemd=ignore_systemd, replace_idle=replace_idle)
         else:
             # use cgexec
 
@@ -147,14 +148,16 @@ class Process(object):
             thread.start()
 
     def create_threaded_process_in_cgroup(self, config, controller, cgname,
-                                          threads=2, cgclassify=True, ignore_systemd=False):
+                                          threads=2, cgclassify=True, ignore_systemd=False,
+                                          replace_idle=False):
 
         p = mp.Process(target=self.create_threaded_process,
                        args=(config, threads, ))
         p.start()
 
         if cgclassify:
-            Cgroup.classify(config, controller, cgname, p.pid, ignore_systemd=ignore_systemd)
+            Cgroup.classify(config, controller, cgname, p.pid,
+                            ignore_systemd=ignore_systemd, replace_idle=replace_idle)
 
         self.children.append(p)
         self.children_pids.append(p.pid)