1
0
Fork 0

scheduler: group.* options: Process threads as well

Previously threads were not touched when processing group.* options.

Reproducer:
$ cat > a.c << EOF
 #define _GNU_SOURCE
 #include <pthread.h>
 #include <unistd.h>

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=00: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 <olysonek@redhat.com>
This commit is contained in:
Ondřej Lysoněk 2018-06-02 17:08:04 +02:00
parent c1bc257563
commit 7bb6ff4d4d

View file

@ -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):