Discussion:
[PATCH] tuna: fix the check of PF_NO_SETAFFINITY flag for threads
Arnaldo Carvalho de Melo
2015-11-27 19:09:36 UTC
Permalink
Tuna checks if PF_NO_SETAFFINITY is set on /proc/PID/stat's 'flag'
field to verify if it is possible to migrate a process/thread.
This is working fine for process, but not for threads.
For threads, the file /proc/TID/stat is being checked, but this file
does not exist as the stat file of a thread is at /proc/PID/task/TID/stat.
Hence, the check was failing and threads were not being migrated.
This patch adds a function to check thread's stat file, and this
function is called to verify the PF_NO_SETAFFINITY flag for
threads.
From visual inspection:

Acked-by: Arnaldo Carvalho de Melo <***@redhat.com>

I'll add this upstream and push.

Thanks!

- Arnaldo
---
tuna/tuna.py | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/tuna/tuna.py b/tuna/tuna.py
index 3c30f03..1de63b0 100755
--- a/tuna/tuna.py
+++ b/tuna/tuna.py
return True
+# FIXME: move to python-linux-procfs
+ PF_NO_SETAFFINITY = 0x04000000
+ return int(self.processes[pid].threads[tid]["stat"]["flags"]) & \
+ PF_NO_SETAFFINITY and True or False
+ return True
+
def move_threads_to_cpu(cpus, pid_list, set_affinity_warning = None,
changed = False
continue
threads = ps[pid]["threads"]
continue
affinity = schedutils.get_affinity(tid)
continue
threads = ps[pid]["threads"]
continue
affinity = schedutils.get_affinity(tid)
--
2.5.0
Loading...