From: Kamalesh Babulal Date: Thu, 1 Jun 2023 11:11:42 +0000 (+0000) Subject: ftests: add support to replace idle_thread of systemd scope X-Git-Tag: v3.1.0~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b399c56e26ffc46c301a820f446cef7ad6885528;p=thirdparty%2Flibcgroup.git ftests: add support to replace idle_thread of systemd scope 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 Signed-off-by: Tom Hromatka --- diff --git a/tests/ftests/cgroup.py b/tests/ftests/cgroup.py index 23ef9ca9..57fb2a70 100644 --- a/tests/ftests/cgroup.py +++ b/tests/ftests/cgroup.py @@ -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') diff --git a/tests/ftests/process.py b/tests/ftests/process.py index b2cdcf6e..d03de98f 100644 --- a/tests/ftests/process.py +++ b/tests/ftests/process.py @@ -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)