diff --git a/SOURCES/tuna-fix-the-check-of-PF_NO_SETAFFINITY-flag-for-thr.patch b/SOURCES/tuna-fix-the-check-of-PF_NO_SETAFFINITY-flag-for-thr.patch new file mode 100644 index 0000000..4ead67a --- /dev/null +++ b/SOURCES/tuna-fix-the-check-of-PF_NO_SETAFFINITY-flag-for-thr.patch @@ -0,0 +1,107 @@ +From 92aa193749be6d1e531e05abef22b9092c577bb3 Mon Sep 17 00:00:00 2001 +From: Daniel Bristot de Oliveira +Date: Fri, 27 Nov 2015 16:36:54 -0200 +Subject: [PATCH] tuna: fix the check of PF_NO_SETAFFINITY flag for threads + +commit 95c4e2ad2603cd29af1357c0ceb780da8dc161cc upstream + +The following is the commit that caused the regression +commit 29fbb6e82357c87be652c6717ef52d808ec0af78 +tuna: Decide whether to isolate a thread based on PF_NO_SETAFFINITY + +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. + +Committer note: + +Before, doing: + + # tuna --cpu 3 --isolate + # tuna -t firefox -CP + thread ctxt_switches + pid SCHED_ rtpri affinity voluntary nonvoluntary cmd + 14838 OTHER 0 0,1,2 873954 27498 firefox + 14857 OTHER 0 0,1,2,3 3 1 Gecko_IOThread + 14858 OTHER 0 0,1,2,3 1 0 Link Monitor + 14859 OTHER 0 0,1,2,3 126717 12214 Socket Thread + + +So it affected just the main thread, all the children remained with +their existing affinity mask. + +After the patch: + + # tuna --cpu 3 --isolate + # tuna -t firefox -CP + thread ctxt_switches + pid SCHED_ rtpri affinity voluntary nonvoluntary cmd + 14838 OTHER 0 0,1,2 877488 27583 firefox + 14857 OTHER 0 0,1,2 3 1 Gecko_IOThread + 14858 OTHER 0 0,1,2 1 0 Link Monitor + 14859 OTHER 0 0,1,2 126933 12235 Socket Thread + + +Signed-off-by: Daniel Bristot de Oliveira +Tested-by: Arnaldo Carvalho de Melo +Cc: Jiri Kastner +Cc: John Kacur +Cc: Luiz Capitulino +Cc: Tuna +Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1286221 +Signed-off-by: Arnaldo Carvalho de Melo +Resolves: rhbz#1286221 +Signed-off-by: John Kacur +--- + tuna/tuna.py | 13 +++++++++++-- + 1 file changed, 11 insertions(+), 2 deletions(-) + +diff --git a/tuna/tuna.py b/tuna/tuna.py +index 3c30f03ea134..1de63b07a5ee 100755 +--- a/tuna/tuna.py ++++ b/tuna/tuna.py +@@ -181,6 +181,15 @@ def cannot_set_affinity(self, pid): + except: + return True + ++# FIXME: move to python-linux-procfs ++def cannot_set_thread_affinity(self, pid, tid): ++ PF_NO_SETAFFINITY = 0x04000000 ++ try: ++ return int(self.processes[pid].threads[tid]["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 +@@ -357,7 +366,7 @@ def isolate_cpus(cpus, nr_cpus): + continue + threads = ps[pid]["threads"] + for tid in threads.keys(): +- if cannot_set_affinity(ps, tid): ++ if cannot_set_thread_affinity(ps, pid, tid): + continue + try: + affinity = schedutils.get_affinity(tid) +@@ -425,7 +434,7 @@ def include_cpus(cpus, nr_cpus): + continue + threads = ps[pid]["threads"] + for tid in threads.keys(): +- if cannot_set_affinity(ps, tid): ++ if cannot_set_thread_affinity(ps, pid, tid): + continue + try: + affinity = schedutils.get_affinity(tid) +-- +2.4.3 + diff --git a/SPECS/tuna.spec b/SPECS/tuna.spec index 6968af6..4a14c5c 100644 --- a/SPECS/tuna.spec +++ b/SPECS/tuna.spec @@ -3,7 +3,7 @@ Name: tuna Version: 0.11.1 -Release: 10%{?dist} +Release: 12%{?dist} License: GPLv2 Summary: Application tuning GUI & command line utility Group: Applications/System @@ -26,6 +26,7 @@ Patch14: CLI-Do-not-show-column-headers-when-not-outputting-t.patch Patch15: Fix-behavior-for-dot-inside-proc-sys-path.patch Patch16: Correct-a-typo-in-the-net.ipv4.ipfrag_time-help-stri.patch Patch17: spec-Show-where-the-original-source-comes-from-in-co.patch +Patch18: tuna-fix-the-check-of-PF_NO_SETAFFINITY-flag-for-thr.patch URL: http://userweb.kernel.org/~acme/tuna/ # Real source is now at git://git.kernel.org/pub/scm/utils/tuna/tuna @@ -82,6 +83,7 @@ priority is changed, be it using tuna or plain chrt & taskset. %patch15 -p1 %patch16 -p1 %patch17 -p1 +%patch18 -p1 %build @@ -137,6 +139,14 @@ rm -rf %{buildroot} %doc docs/oscilloscope+tuna.pdf %changelog +* Tue Dec 22 2015 John Kacur - 0.11.1-12 +- rebuilt for rhel-7.2.z +Resolves: rhbz#1293353 + +* Mon Dec 21 2015 John Kacur - 0.11.1-11 +- tuna-fix-the-check-of-PF_NO_SETAFFINITY-flag-for-thr.patch +Resolves: rhbz#1286221 + * Thu Jun 25 2015 John Kacur - 0.11.1-10 - dropped the git housekeeping patch, not relevant here - docs-Remove-stray-a.patch