summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@felicio.ghostprotocols.net>2015-06-09 16:08:44 -0300
committerArnaldo Carvalho de Melo <acme@felicio.ghostprotocols.net>2015-06-09 16:08:44 -0300
commit29fbb6e82357c87be652c6717ef52d808ec0af78 (patch)
tree925f1ec9d560b20069f56da1421a0a36401d1372
parent21c9b91feadf33d6d7be5b4d311eef2dfde5bfaf (diff)
downloadtuna-29fbb6e82357c87be652c6717ef52d808ec0af78.tar.gz
tuna: Decide whether to isolate a thread based on PF_NO_SETAFFINITY
We were avoiding moving kernel threads, for isolation purposes it is better to check /perf/PID/stat's 'flag' big mask for PF_NO_SETAFFINITY instead. Requested-by: Luiz Capitulino <lcapitulino@redhat.com> Cc: Clark Williams <williams@redhat.com> Cc: Guy Streeter <streeter@redhat.com> Cc: Jeremy Eder <jeder@redhat.com> Cc: Jiri Kastner <jkastner@redhat.com> Cc: John Kacur <jkacur@redhat.com> Cc: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@felicio.ghostprotocols.net>
-rwxr-xr-xtuna/tuna.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/tuna/tuna.py b/tuna/tuna.py
index 0efa84f..6cd6bdd 100755
--- a/tuna/tuna.py
+++ b/tuna/tuna.py
@@ -171,6 +171,15 @@ def is_hardirq_handler(self, pid):
return int(self.processes[pid]["stat"]["flags"]) & \
PF_HARDIRQ and True or False
+# FIXME: move to python-linux-procfs
+def cannot_set_affinity(self, pid):
+ PF_NO_SETAFFINITY = 0x04000000
+ try:
+ return int(self.processes[pid]["stat"]["flags"]) & \
+ PF_NO_SETAFFINITY and True or False
+ except:
+ return True
+
def move_threads_to_cpu(cpus, pid_list, set_affinity_warning = None,
spread = False):
changed = False
@@ -325,7 +334,7 @@ def isolate_cpus(cpus, nr_cpus):
ps.reload_threads()
previous_pid_affinities = {}
for pid in ps.keys():
- if iskthread(pid):
+ if cannot_set_affinity(ps, pid):
continue
try:
affinity = schedutils.get_affinity(pid)
@@ -347,7 +356,7 @@ def isolate_cpus(cpus, nr_cpus):
continue
threads = ps[pid]["threads"]
for tid in threads.keys():
- if iskthread(tid):
+ if cannot_set_affinity(ps, tid):
continue
try:
affinity = schedutils.get_affinity(tid)
@@ -393,7 +402,7 @@ def include_cpus(cpus, nr_cpus):
ps.reload_threads()
previous_pid_affinities = {}
for pid in ps.keys():
- if iskthread(pid):
+ if cannot_set_affinity(ps, pid):
continue
try:
affinity = schedutils.get_affinity(pid)
@@ -415,7 +424,7 @@ def include_cpus(cpus, nr_cpus):
continue
threads = ps[pid]["threads"]
for tid in threads.keys():
- if iskthread(tid):
+ if cannot_set_affinity(ps, tid):
continue
try:
affinity = schedutils.get_affinity(tid)