Blame SOURCES/tuna-Decide-whether-to-isolate-a-thread-based-on-PF_.patch

d2f14d
From 6f0a2ef512aeb2e4a16a561673c95568a8780713 Mon Sep 17 00:00:00 2001
d2f14d
From: Arnaldo Carvalho de Melo <acme@felicio.ghostprotocols.net>
d2f14d
Date: Tue, 9 Jun 2015 16:08:44 -0300
d2f14d
Subject: [PATCH 11/15] tuna: Decide whether to isolate a thread based on
d2f14d
 PF_NO_SETAFFINITY
d2f14d
d2f14d
We were avoiding moving kernel threads, for isolation purposes it is better
d2f14d
to check /perf/PID/stat's 'flag' big mask for PF_NO_SETAFFINITY instead.
d2f14d
d2f14d
Requested-by: Luiz Capitulino <lcapitulino@redhat.com>
d2f14d
Cc: Clark Williams <williams@redhat.com>
d2f14d
Cc: Guy Streeter <streeter@redhat.com>
d2f14d
Cc: Jeremy Eder <jeder@redhat.com>
d2f14d
Cc: Jiri Kastner <jkastner@redhat.com>
d2f14d
Cc: John Kacur <jkacur@redhat.com>
d2f14d
Cc: Marcelo Tosatti <mtosatti@redhat.com>
d2f14d
Signed-off-by: Arnaldo Carvalho de Melo <acme@felicio.ghostprotocols.net>
d2f14d
Signed-off-by: John Kacur <jkacur@redhat.com>
d2f14d
---
d2f14d
 tuna/tuna.py | 17 +++++++++++++----
d2f14d
 1 file changed, 13 insertions(+), 4 deletions(-)
d2f14d
d2f14d
diff --git a/tuna/tuna.py b/tuna/tuna.py
d2f14d
index 0efa84fdf314..6cd6bddd2137 100755
d2f14d
--- a/tuna/tuna.py
d2f14d
+++ b/tuna/tuna.py
d2f14d
@@ -171,6 +171,15 @@ def is_hardirq_handler(self, pid):
d2f14d
                 return int(self.processes[pid]["stat"]["flags"]) & \
d2f14d
                        PF_HARDIRQ and True or False
d2f14d
 
d2f14d
+# FIXME: move to python-linux-procfs
d2f14d
+def cannot_set_affinity(self, pid):
d2f14d
+		PF_NO_SETAFFINITY = 0x04000000
d2f14d
+		try:
d2f14d
+			return int(self.processes[pid]["stat"]["flags"]) & \
d2f14d
+				PF_NO_SETAFFINITY and True or False
d2f14d
+		except:
d2f14d
+			return True
d2f14d
+
d2f14d
 def move_threads_to_cpu(cpus, pid_list, set_affinity_warning = None,
d2f14d
 			spread = False):
d2f14d
 	changed = False
d2f14d
@@ -325,7 +334,7 @@ def isolate_cpus(cpus, nr_cpus):
d2f14d
 	ps.reload_threads()
d2f14d
 	previous_pid_affinities = {}
d2f14d
 	for pid in ps.keys():
d2f14d
-		if iskthread(pid):
d2f14d
+		if cannot_set_affinity(ps, pid):
d2f14d
 			continue
d2f14d
 		try:
d2f14d
 			affinity = schedutils.get_affinity(pid)
d2f14d
@@ -347,7 +356,7 @@ def isolate_cpus(cpus, nr_cpus):
d2f14d
 			continue
d2f14d
 		threads = ps[pid]["threads"]
d2f14d
 		for tid in threads.keys():
d2f14d
-			if iskthread(tid):
d2f14d
+			if cannot_set_affinity(ps, tid):
d2f14d
 				continue
d2f14d
 			try:
d2f14d
 				affinity = schedutils.get_affinity(tid)
d2f14d
@@ -393,7 +402,7 @@ def include_cpus(cpus, nr_cpus):
d2f14d
 	ps.reload_threads()
d2f14d
 	previous_pid_affinities = {}
d2f14d
 	for pid in ps.keys():
d2f14d
-		if iskthread(pid):
d2f14d
+		if cannot_set_affinity(ps, pid):
d2f14d
 			continue
d2f14d
 		try:
d2f14d
 			affinity = schedutils.get_affinity(pid)
d2f14d
@@ -415,7 +424,7 @@ def include_cpus(cpus, nr_cpus):
d2f14d
 			continue
d2f14d
 		threads = ps[pid]["threads"]
d2f14d
 		for tid in threads.keys():
d2f14d
-			if iskthread(tid):
d2f14d
+			if cannot_set_affinity(ps, tid):
d2f14d
 				continue
d2f14d
 			try:
d2f14d
 				affinity = schedutils.get_affinity(tid)
d2f14d
-- 
d2f14d
1.8.3.1
d2f14d