From 7bb6ff4d4da42de7a51466ba58cc94d5effe3cba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= Date: Sat, 2 Jun 2018 17:08:04 +0200 Subject: [PATCH] scheduler: group.* options: Process threads as well MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously threads were not touched when processing group.* options. Reproducer: $ cat > a.c << EOF #define _GNU_SOURCE #include #include void *foo(void *unused) { pause(); return NULL; } int main(void) { pthread_t t; pthread_create(&t, NULL, foo, NULL); pthread_setname_np(t, "a.out"); pause(); return 0; } EOF $ gcc a.c -pthread $ mkdir /etc/tuned/test $ cat > /etc/tuned/test/tuned.conf << EOF [scheduler] group.foo=0:o:0:1:a.out EOF $ ./a.out & $ tuned-adm profile test $ for proc in /proc/$(pgrep a.out)/task/*; do taskset -p $(basename $proc); done pid 29052's current affinity mask: 1 pid 29053's current affinity mask: f <<< should be 1 Signed-off-by: Ondřej Lysoněk --- tuned/plugins/plugin_scheduler.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tuned/plugins/plugin_scheduler.py b/tuned/plugins/plugin_scheduler.py index 32612f9..582f0ad 100644 --- a/tuned/plugins/plugin_scheduler.py +++ b/tuned/plugins/plugin_scheduler.py @@ -126,6 +126,10 @@ class SchedulerPlugin(base.Plugin): cmd = self._get_cmdline(proc) pid = proc["pid"] processes[pid] = cmd + if "threads" in proc: + for pid in proc["threads"].keys(): + cmd = self._get_cmdline(proc) + processes[pid] = cmd except (OSError, IOError) as e: if e.errno == errno.ENOENT \ or e.errno == errno.ESRCH: @@ -446,9 +450,9 @@ class SchedulerPlugin(base.Plugin): if event: read_events = True if event.type == perf.RECORD_COMM: - self._add_pid(instance, int(event.pid), r) + self._add_pid(instance, int(event.tid), r) elif event.type == perf.RECORD_EXIT: - self._remove_pid(instance, int(event.pid)) + self._remove_pid(instance, int(event.tid)) @command_custom("ps_whitelist", per_device = False) def _ps_whitelist(self, enabling, value, verify, ignore_missing):